SFML community forums

Help => General => Topic started by: PewPew on August 06, 2016, 07:28:08 am

Title: Spike lag
Post by: PewPew on August 06, 2016, 07:28:08 am
I keep having this spike lag on my pong game

here is the code

while (window.isOpen())
        {
                window.setFramerateLimit(60);
                sf::Event event;
                dt = deltatime.getElapsedTime().asSeconds();
               
                update(event,dt);
                while (window.pollEvent(event))
                {
                        if (event.type == sf::Event::Closed || sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))
                                window.close();
                }
                if (mClock.getElapsedTime().asSeconds() >= 1.f)
                {
                        mFps = mFrame;
                        mFrame = 0;
                        mClock.restart();
                       
                }

                ++mFrame;
                //std::cout << mFps << std::endl;

                this->deltatime.restart();
                window.clear(color);
                player->Render(window);
                ball->Render(window);
                window.display();
       

        }

IM guessing its the deltatime. But I dont see the connection. My computer is a medium gaming rig so I shouldnt have this lag spike.
Title: AW: Spike lag
Post by: eXpl0it3r on August 06, 2016, 12:24:15 pm
And what is "this lag spike"?
Title: Re: Spike lag
Post by: PewPew on August 10, 2016, 07:19:41 am
Every time I move the paddle theres this spike lag happening. Same as the ball. Might be my computer but it doesnt seem to be like that on monogame.
Title: Re: Spike lag
Post by: Mr_Blame on August 10, 2016, 04:21:07 pm
What is in update function
Title: Re: Spike lag
Post by: Jesper Juhl on August 10, 2016, 10:15:03 pm
Maybe you should define "spike lag"...

You made up the term, now explain to us what it means. What exactly is a "spike lag"?
Title: Re: Spike lag
Post by: jamesL on August 10, 2016, 10:44:43 pm
start by moving
window.setFramerateLimit(60);
outside the loop