int xvel,yvel;
if(merect.x!=goalx){if(merect.x<goalx){xvel=1;}else xvel=-1;}else xvel=0;
if(merect.y!=goaly){if(merect.y<goaly){yvel=1;}else yvel=-1;}else yvel=0;
x+=xvel*(movementspeed*((SDL_GetTicks()-lastupdate)/1000.0f));
y+=yvel*(movementspeed*((SDL_GetTicks()-lastupdate)/1000.0f));
merect.x=(int)x;
merect.y=(int)y;
printf("%f %i\n",lastupdate/1000-SDL_GetTicks()/1000,merect.x);
lastupdate=SDL_GetTicks();
SDL_GetTicks erratic motion thingy
Hey there, here's a snippet from a program I'm doing,
and for some reason the object moves erratically. Why?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement