I am having problems moving an object in the direction of the angle that Its moving in. I can't see whats wrong with it, but the output is definitely wrong.
Here where I declare and create an object:
Here I initialize some variables:Code:struct Sprite { float x, y; int w, h; int r, g, b; float angle, speed; }; typedef struct Sprite Sprite; Sprite thing;
With an angle of 90 degrees it should move downwards, but I'm finding it moves to the left as well (as if around 110 degrees or so). Heres where I move it:Code:thing.x=320; thing.y=240; thing.w=10; thing.h=10; thing.r=255; thing.g=0; thing.b=0; thing.angle=90; thing.speed=2;
Can anyone see whats going wrong here?Code:float dx, dy; dx=cos(thing.angle); dy=sin(thing.angle); thing.x+=(thing.speed*dx); thing.y+=(thing.speed*dy);



LinkBack URL
About LinkBacks


