04-26-2005, 03:25 PM
Hi I am having problems with lookup tables in my game. Basically , I would want to use precalculated values instead of calculating it on the fly.
This would be tbe init code:
Why would this fail:
And this not:
Actually, it does not give me an error, but the effect of the two codes is a lot different. With Luts, some of the sprites "jump" off the desired position. :*(
Thanks in advance!
This would be tbe init code:
Code:
dim pm_sin as single ptr
dim pm_cos as single ptr
pm_sin = callocate(len(single) * 360)
pm_cos = callocate(len(single) * 360)
for i = 0 to 359
pm_sin[i] = sin(i * 3.141593 / 180)
pm_cos[i] = cos(i * 3.141593 / 180)
next i
Why would this fail:
Code:
dim angle as integer
angle = ( m_angle + i * (STEPSEGMENT - 2) )
if angle > 359 then angle = angle - 360
.ps_followers[i].m_x = MainEnemy.m_x + 24 + (pm_cos[ angle ] * 70)
.ps_followers[i].m_y = MainEnemy.m_y + 28 + (pm_sin[ angle ] * 60)
And this not:
Code:
dim angle as single
angle = ( m_angle + i * (STEPSEGMENT - 2) ) * 3.141593 /180
if angle > 359 then angle = angle - 360
.ps_followers[i].m_x = MainEnemy.m_x + 24 + cos(angle) * 70
.ps_followers[i].m_y = MainEnemy.m_y + 28 + sin(angle) * 60
Actually, it does not give me an error, but the effect of the two codes is a lot different. With Luts, some of the sprites "jump" off the desired position. :*(
Thanks in advance!