🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Problems with movement in 2d

Started by
0 comments, last by mrman131 22 years, 11 months ago
I am having problems with the movement code in 2d enviorment. I have read the stuff on the site, and implemented what they say, but it doesn''t seem to work. When I try to move, it gives erratic results. Any help would be apprieciated. procedure TCar.move(); begin X := X + int(speed * cos(angle)); Y := Y - int(speed * sin(angle)); end;
Advertisement

Is your variable ''angle'' in radians or degrees? If it is in degrees (which I assume it is) you''ll need to do something like this:

X := X + int(speed * cos(2*3.141593*angle/360));Y := Y - int(speed * sin(2*3.141593*angle/360)); 

This topic is closed to new replies.

Advertisement