I was hoping I could get some feedback on performance of my animations overall. It could just be me but I keep getting a bit of lag despite being at 60FPS constantly.
Objects on screen seem to tear a little bit.
Here is my game loop:
//clocks and times used to get custom game loop working
sf::Clock clock;
sf::Time timeSinceLastUpdate = sf::Time::Zero;
//setting g_GameState to be intro on run
g_GameState = 0;
//main loop to run the entire length of games
//life
while (g_Window.isOpen())
{
sf::Time dt = clock.restart();
timeSinceLastUpdate += dt;
while(timeSinceLastUpdate > TIME_PER_FRAME)
{
timeSinceLastUpdate -= TIME_PER_FRAME;
processEvents();
update(TIME_PER_FRAME);
}
updateFPSCounter(dt);
render();
}
It's this performance issue I'd like any feedback or advice on.
Also, if anyone thinks I could do collision detection better as well, could you give me any pointers?
For the player paddles I use this to update their movement:
//Not using deceleration
//so setting mVelocity as 0 each time
mVelocity.x = 0;
mVelocity.y = 0;
//Handle if player keys are pressed to move up
//or down
if(mIsMovingUp){
mVelocity.y = -mSpeed;
}
else if(mIsMovingDown){
mVelocity.y = mSpeed;
}
//move the play based on current mVelocity size
this->move(mVelocity * elapsedTime.asSeconds());
sf::Window::setVerticalSyncEnabled(true);
already? \$\endgroup\$