
Sprites n Math
Hi i want to make a sprite move in a nice circle movement
but im having trouble with the math side heres the code im using but it does not work the sprite just goes across the screen
float ang = 0;
double DEGTORAD =0.0174532925 ;
for (int what=0;what< NUMSPRITES ; what++)
{
Player1[what].ScreenPosX += Player1[what].Speed;
Player1[what].ScreenPosY = sin(DEGTORAD*ang+(what<<1));
BltSprite(Player1[what]);
ang += 5;
}
please help me
Mel
[edited by - Melinda on December 28, 2002 12:48:59 PM]
[edited by - Melinda on December 28, 2002 12:49:31 PM]

Well, during curvilinear motion the speed changes - acceleration is pointing towards the centre of the curvature. It seems that your sprite''s speed is constant, that''s why it moves straight!
try to change the speed of each sprite, in the way you change position! (NOTE: acceleration points to the centre of the circle => it is not constant either => better use vector math for that stuff)
hope this helps
try to change the speed of each sprite, in the way you change position! (NOTE: acceleration points to the centre of the circle => it is not constant either => better use vector math for that stuff)
hope this helps

C++ RULEZ!!! :)
Player1[what].ScreenPosX += Player1[what].Speed;
Player1[what].ScreenPosY = sin(DEGTORAD*ang+(what<<1));
ok thats the prb.
You are taking the X pos and adding the speed to it.
Then you are doing a sin working with Y
for a circle you need somthing along these lines
x'' = x cos t - y sin t
y'' = y cos t + x sin t
Where t is the angle, and it will be a unit circle.
Bugle4d
Player1[what].ScreenPosY = sin(DEGTORAD*ang+(what<<1));
ok thats the prb.
You are taking the X pos and adding the speed to it.
Then you are doing a sin working with Y
for a circle you need somthing along these lines
x'' = x cos t - y sin t
y'' = y cos t + x sin t
Where t is the angle, and it will be a unit circle.
Bugle4d
~V'lionBugle4d
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement