Yes hi all fellow game devs. I have a problem with my the animation part of my code. What happens is the movement is choppy and the animation plays too fast. I know it is because i don't have a fps timer but I'm stuck. I've looked everywhere for help. so here I am. Please any help will do.
while (window.isOpen()){
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
if((event.type==sf::Event::KeyPressed && event.key.code==sf::Keyboard::Up)){
//pla.move(0,-2.f);
rec.left=0;
if(clock.getElapsedTime().asSeconds()>1.0f){
if(rec.left==48)
rec.left=0;
else
rec.left+=16;
// pla.setTextureRect(rec);
clock.restart();
}
pla.setTextureRect(rec);
//rec.left=0;