hi ,
yz is right , I 'll explain what is that mean :
casting problem causes the calculated velocity (speed) to jump from one side of a certain integer to the other .
to avoid such behavior , add 0.5 to the cosine like
cos(direction * 3.1415926535 / 180)
change to :
[cos(direction * 3.1415926535 / 180)+.5]
in addition change 180 to 180.0 , in some compilers it maybe helpfully.
Talmash
Main Topics
Browse All Topics





by: yzPosted on 2000-05-13 at 22:46:15ID: 2807832
Could you give a exactly pair of speed and direction that can let the car move in zigzag?
Maybe you should add 0.5 to the result of cos or sin, things will be better.
like this:
car.x += (int)((speed * cos(direction * 3.1415926535 / 180)) / SCALE_FACTOR + 0.5);