On Tuesday, January 13, 2004 at 18:56, Glenn Saunders wrote:
>>With factional speeds and some small sine/cosine tables that shouldn't
>>be a problem anymore.
> Could you explain how those tables would be used?
The easy way:
First you decide how many angles you want and what should be the ball
speed.
For each angle you need two values, one for the x- and one for the
y-speed. Each values consists out of two bytes to store fractional speeds.
E.g. the ball speed should be 3 pixel/frame, for an angle of 30° you
get a speed of 1.5/2.6 (x/y) pixels/frame. Converted into fractional
values you get 1/128 and 2/153.
Then you need 4 RAM bytes for the ball, 2 bytes for x and y each
(hi/low).
In each frame you simply add the values from the table to the current
values and use only the higher bytes for displaying the ball.
The advanced way:
Various optimizations are possible, e.g. the sine/cosine tables can
overlap and you don't need the values for the whole circle.
Have fun!
Thomas
_______________________________________________________
Thomas Jentzsch | *** Every bit is sacred ! ***
tjentzsch at web dot de |
----------------------------------------------------------------------------------------------
Archives (includes files) at http://www.biglist.com/lists/stella/archives/
Unsub & more at http://www.biglist.com/lists/stella/