Click here to Skip to main content
       

Algorithms

 
AnswerRe: Factorials PinmemberArash Partow25-Jun-08 2:14 
GeneralRe: Factorials PinmemberIan Uy25-Jun-08 6:26 
QuestionHow to determine the next x,y coordinate for a tank in a 2-D game... PinmemberEdmundisme18-Jun-08 8:35 
AnswerRe: How to determine the next x,y coordinate for a tank in a 2-D game... Pinmember73Zeppelin18-Jun-08 11:38 
GeneralRe: How to determine the next x,y coordinate for a tank in a 2-D game... PinmemberMatthew Butler18-Jun-08 11:44 
GeneralRe: How to determine the next x,y coordinate for a tank in a 2-D game... Pinmember73Zeppelin18-Jun-08 22:00 
GeneralRe: How to determine the next x,y coordinate for a tank in a 2-D game... PinmemberEdmundisme18-Jun-08 12:00 
AnswerRe: How to determine the next x,y coordinate for a tank in a 2-D game... PinmemberMatthew Butler18-Jun-08 11:41 
Just use basic geometry/maths...
 
nextXpos = lastXpos + speed * sin(angle);
nextYpos = lastYpos - speed * cos(angle);
 
[angle is measured from the vertical, clockwise]
 
The only things you need to remember are:
> Math.Sin and Math.Cos take the angle argument in radians not degrees.
> Sin and Cos return double precision numbers: which may round to 0 or 1 if you are using integer positions and therefore the tank will not move as you want.
 
Hope this helps.
 
Matthew Butler

GeneralRe: How to determine the next x,y coordinate for a tank in a 2-D game... PinmemberEdmundisme18-Jun-08 12:01 
JokeRe: How to determine the next x,y coordinate for a tank in a 2-D game... PinmvpCPallini18-Jun-08 21:19 
QuestionPolyline offset algorithm Pinmemberbeko16-Jun-08 21:59 
AnswerRe: Polyline offset algorithm PinmemberAlan Balkany17-Jun-08 4:07 
GeneralRe: Polyline offset algorithm Pinmemberbeko17-Jun-08 4:43 
QuestionRe: Polyline offset algorithm Pinmvp CPallini17-Jun-08 7:03 
AnswerRe: Polyline offset algorithm Pinmemberbeko17-Jun-08 8:26 
GeneralRe: Polyline offset algorithm Pinmembercp987617-Jun-08 12:10 
AnswerRe: Polyline offset algorithm PinmemberArash Partow18-Jun-08 1:22 
GeneralRe: Polyline offset algorithm Pinmemberbeko18-Jun-08 19:55 
QuestionWhat's the period of (cos ax)(sin bx)? Pinmembersherifffruitfly14-Jun-08 10:00 
AnswerRe: What's the period of (cos ax)(sin bx)? Pinmembercp987614-Jun-08 19:03 
AnswerRe: What's the period of (cos ax)(sin bx)? PinmemberMarkBrock15-Jun-08 2:00 
AnswerRe: What's the period of (cos ax)(sin bx)? Pinmvp CPallini15-Jun-08 22:02 
QuestionQuaternion to Euler Pinmember Xmen 11-Jun-08 3:08 
AnswerRe: Quaternion to Euler Pinmembercmk11-Jun-08 11:27 
GeneralRe: Quaternion to Euler Pinmember Xmen 11-Jun-08 12:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web01 | 2.8.140916.1 | Last Updated 16 Sep 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid