Skip to main content
GameDev.net gamedev.net
🔒 Locked

Grid Navigation

Started by SpaceBoy Jun 26, 2004 at 12:15 PM 0 replies 450+ views
Original Post
SpaceBoy
SpaceBoy
I am currently working on a prototype for a 2D naval game that will involve 19th century warships. Each player will fight his/her ship on a 2D grid. Now, I admit, my math is (more than) a bit rusty... so be gentle. What I need to do is no the shipd Heading. Course 000 or 061, for example. The direction of the heading is where I apply the speed to the XY coordinates to update its position for each game tick. So, if I have a ship sailing on course 045 and moving 10 grid points per tick, how do I solve for its new XY position? I also need to do the opposite and solve for a directional bearing from my location. For example, if I am at position 200,125 and my target is at position 100,100 what is his bearing relative to me?
Empirical
Empirical
NewX=X+cos(Heading);
NewY=Y+sin(Heading);

If the heading is on degrees you need to convert

Heading=HeadingInDegrees*0.0174532925f;

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.