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

Author Topic: move.xxx runs crazy fast sometimes  (Read 3378 times)

0 Members and 2 Guests are viewing this topic.

etixpp

  • Jr. Member
  • **
  • Posts: 82
    • View Profile
    • FoxFire Development Website
    • Email
move.xxx runs crazy fast sometimes
« on: June 01, 2013, 06:46:46 pm »
Hello, i got a problem, i have a player sprite and i let him move, this is just fine, i use move(2,0 ) and so on for w a s d and he runs but thing is, sometimes he has a few seconds, where he runs crazy fast, and then normal again... hast somebody a clue what can cause that?

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: move.xxx runs crazy fast sometimes
« Reply #1 on: June 01, 2013, 07:54:18 pm »
You have to make the movement dependent on the passed time. That is, measure the time using sf::Clock and multiply the velocity vector of your object with it.

Alternatively you use a fixed time. A simple way to achieve this is setting the framerate limit or enabling v-sync in sf::RenderWindow. Before you ask how to do this, have a look at the documentation.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

hayer

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
Re: move.xxx runs crazy fast sometimes
« Reply #2 on: June 02, 2013, 01:01:28 am »
May I suggest that you watch this;

It is a series of videos on math related to game development  :)

etixpp

  • Jr. Member
  • **
  • Posts: 82
    • View Profile
    • FoxFire Development Website
    • Email
Re: move.xxx runs crazy fast sometimes
« Reply #3 on: June 02, 2013, 04:07:02 am »
nah that wasn´t the problem ,the thing was that me dumby had the keypull in the eventloop, changed it to the mainloop and now works just fine^^