Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Spike lag  (Read 3449 times)

0 Members and 1 Guest are viewing this topic.

PewPew

  • Newbie
  • *
  • Posts: 22
    • View Profile
Spike lag
« 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.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
AW: Spike lag
« Reply #1 on: August 06, 2016, 12:24:15 pm »
And what is "this lag spike"?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

PewPew

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: Spike lag
« Reply #2 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.

Mr_Blame

  • Full Member
  • ***
  • Posts: 192
    • View Profile
    • Email
Re: Spike lag
« Reply #3 on: August 10, 2016, 04:21:07 pm »
What is in update function

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Spike lag
« Reply #4 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"?

jamesL

  • Full Member
  • ***
  • Posts: 124
    • View Profile
Re: Spike lag
« Reply #5 on: August 10, 2016, 10:44:43 pm »
start by moving
window.setFramerateLimit(60);
outside the loop

 

anything