Original Post
Hello.
Im doing a 2d tiled based rpg.
i was fine with per loop movment, but then i had to add a animation to all that, and it dosent look fluent.
So i went exploring and found that i need to find delta time and som other stuff.
So basicly this is my game:
Movment speed = 50; and i want to move my "X" hero position by 50 pixels each loop but i never had ani complicated math at school cant figure it out.
Screen_FPS = 60
Im doing a 2d tiled based rpg.
i was fine with per loop movment, but then i had to add a animation to all that, and it dosent look fluent.
So i went exploring and found that i need to find delta time and som other stuff.
So basicly this is my game:
int main(int argc, char* argv[])
{
while(On)
{
FPSTimer = SDL_GetTicks();
LastTime = CurentTime;
CurrentTime = SDL_GetTicks();
SpeedFactor = (CurrentTime - LastTIme) * 1000.0f;
//Events
//MainLogic
//Render
if(1000.0f / Screen_FPS > (SDL_GetTicks() - FpsTimer))
SDL_Delay(1000.0f / Screen_FPS - (SDL_GetTicks()- FpsTimer));
}
}
void Events()
{
x += (MovmentSpeed * speedfactor);
}
Movment speed = 50; and i want to move my "X" hero position by 50 pixels each loop but i never had ani complicated math at school cant figure it out.
Screen_FPS = 60