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

Author Topic: Game runs very laggy on my computer (Noticeable CPU spikes)  (Read 1406 times)

0 Members and 1 Guest are viewing this topic.

mos

  • Newbie
  • *
  • Posts: 19
    • View Profile
Game runs very laggy on my computer (Noticeable CPU spikes)
« on: March 17, 2017, 11:31:25 pm »
When I look at the monitor in Visual Studio, I see the CPU usage spiking from 1%-7% constantly. So I think some of my code is bad or I'm not doing the timing correct. I followed this tutorial:

http://gafferongames.com/game-physics/fix-your-timestep/

This is what it looks like:

https://gfycat.com/SoftLikableDairycow

As you can see, it seems like it is skipping some draw calls. I tried setting the FramerateLimit to 60, 120, and unlimited but get the same results. I tried turning on VSync but get worse performance.

My specs are: Windows 10 64-bit, nVidia 970, i7-4790k

You can download the visual studio project here (Run using x86): https://www.dropbox.com/s/o9uqarh4q3p8uap/RPGWorld.zip?dl=0

Or you can look at the code here: https://gist.github.com/anonymous/2af3c35d568324fb0a6ce8039ef42a64 The relevant code is most likely in Game.cpp where I do the timing in the function update() and Player.cpp where I do the movement.

Another thing to note is that I let someone else try the project and it ran smoothly for them. He was using a Linux machine but same graphics card. Is it Windows related? Any help would be appreciated.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10815
    • View Profile
    • development blog
    • Email
Game runs very laggy on my computer (Noticeable CPU spikes)
« Reply #1 on: March 18, 2017, 01:49:16 am »
What version of SFML are you running?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

mos

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: Game runs very laggy on my computer (Noticeable CPU spikes)
« Reply #2 on: March 18, 2017, 02:18:11 am »
SFML v 2.4.2. I am using it on Visual C++ 14 (2015) - 32-bit.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10815
    • View Profile
    • development blog
    • Email
Game runs very laggy on my computer (Noticeable CPU spikes)
« Reply #3 on: March 18, 2017, 02:35:14 am »
Can you try the latest git master version: http://www.sfml-dev.org/artifacts/by-branch/master/

We have fixed some issue with joystick polling.

If that doesn't help, I'll take a closer look at your code tomorrow.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

mos

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: Game runs very laggy on my computer (Noticeable CPU spikes)
« Reply #4 on: March 18, 2017, 03:51:19 am »
I tried it with this one: http://www.sfml-dev.org/artifacts/by-branch/master/windows-vc14-32.zip and I still get the same results.

I'm not using a joystick though and have no code to handle it (unless SFML does so automatically).
« Last Edit: March 18, 2017, 03:53:38 am by mos »