GameDev.net Posting Guidelines (please read before posting)
For Beginners Forum FAQs (please read before posting)
Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.
Posted 22 October 2012 - 07:47 AM
Posted 22 October 2012 - 08:10 AM
Posted 22 October 2012 - 08:23 AM
Posted 22 October 2012 - 08:36 AM
Find the relative difference between player and target in both X and Y directions (Dx and Dy)
Now if ABS(Dx) > ABS(Dy) then move first along X axis (direction is given by the sign of Dx), otherwise along Y axis.
After each movement evaluate again.
Posted 22 October 2012 - 10:51 AM
Posted 22 October 2012 - 11:16 AM
Edited by KnolanCross, 22 October 2012 - 11:17 AM.
Currently working on a scene editor for ORX (http://orx-project.org), using kivy (http://kivy.org).
Posted 22 October 2012 - 12:06 PM
Posted 22 October 2012 - 12:53 PM
Edited by KnolanCross, 22 October 2012 - 01:00 PM.
Currently working on a scene editor for ORX (http://orx-project.org), using kivy (http://kivy.org).
Posted 22 October 2012 - 07:30 PM
Posted 23 October 2012 - 07:39 AM
You can simplify Knolan's formula, and cut out the need for finding floor(), by using the float value of n instead. In the above example where you have 5 cells x and 2 cells y, you would come out with:
n = (5/2) = 2.5
so that for every time your x movement is >= 2.5 you move 1 y and store the remainder (.5) in your counter variable. I would write this up like:
Yes, that.Or do you mean you want the character to move a few cells in x axis then a few in the y axis until it reaches its destination?
Edited by Yttermayn, 23 October 2012 - 07:41 AM.
Posted 23 October 2012 - 10:07 AM
You can simplify Knolan's formula, and cut out the need for finding floor(), by using the float value of n instead. In the above example where you have 5 cells x and 2 cells y, you would come out with:
n = (5/2) = 2.5
so that for every time your x movement is >= 2.5 you move 1 y and store the remainder (.5) in your counter variable. I would write this up like:
Currently working on a scene editor for ORX (http://orx-project.org), using kivy (http://kivy.org).
Posted 28 October 2012 - 11:35 AM
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.
GameDev.net™, the GameDev.net logo, and GDNet™ are trademarks of GameDev.net, LLC.