Jump to content

Calculating 2D rotation with 8 directions

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1
Groogy

Groogy

    Programmer

  • Members
  • PipPipPipPip
  • 183 posts
Hi!

I'm currently doing a method that is supposed to return a direction constant(8 different valid directions) just by receiving the delta-coordinates from the current position. (-1,-1) would be UPLEFT for example.

Currently I just use comparison and then return the right constant but I think from my time using RPGMakerVX RGSS2 that somewhere in all the code there was a move(x,y) method that did the same thing but calculated the direction with math which I guess would make the whole process more efficient.

Problem is that I don't really know how to do this with only the allowed integral values of 0-7. I remember good ol' cos and sin from school but don't think RPGMakerVX used that in their system... Although RPGMakerVX only have 4 directions so probably have to be different from their way.

Help appreciated. Thanks!

#2
mbridges

mbridges

    Learning Programmer

  • Members
  • PipPipPip
  • 33 posts
I'm sorry, but i can't help you. Maybe you could try posting in the section in what language your programming to get more responses!
Good luck!

#3
Groogy

Groogy

    Programmer

  • Members
  • PipPipPipPip
  • 183 posts
I would but they don't seem to have a Ruby programming forum here.