Sprites following an angle
Root / Programming Questions / [.]
UltraPhoenix4Created:
Is is possible to make a sprite face a certain angle and then go forward along that angle? If so, how?
Are angles in SmileBASIC calculated in degrees or radians? Or is there a way to select which it uses?The SIN and COS functions require radians (as do other trig functions). SPROT, on the other hand takes degrees. Perska's code is a nice example of converting from polar coordinates into Cartesian x-y. If you choose an angle for the sprite to go, however, you have to be careful about the y-direction. An angle of zero degrees will have COS (0) which should yield +1 sending the sprite DOWNWARD in screen coordinates. Similarly, selecting 45 degrees for the angle will send the sprite directly "southeast". In an application where I have similar code I used -COS(RAD(ANGLE)) to invert typical polar coordinates for the screen. In Perska's code sample one could use DEC instead of INC to achieve the same Y inversion (depending on your application).