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

Author Topic: SFML Game Development Book - What is Frame-independent and Frame-Dependent  (Read 1707 times)

0 Members and 1 Guest are viewing this topic.

Uk Marine

  • Newbie
  • *
  • Posts: 8
    • View Profile
    • Email
Sorry, this might sound like a silly question but i didn't quite understand it  :-\ why do we do distance = time * speed?

Grimshaw

  • Hero Member
  • *****
  • Posts: 631
  • Nephilim SDK
    • View Profile
So that our change is relative to time, we need to put time into the equation.

For example, when you go run, you can say you traveled, for example, at 10 km/hour. As you can see, its a unit of distance relative to a unit of time.

The same happens in games, if the time isn't in the equation, you logically have movement of, let's say, 50 pixels per update(). Since the number of times update() is called in a second can easily vary, your effective speed will vary as the update rate varies as well.

However, if you track time instead of relying on the number of times update() is called, you can always ensure a fixed speed.

In practice, with that formula, your speed variable is represented by the amount of distance units per second. Since time will most likely always be < 1.0, it will scale down your speed to the desired amount of movement for each frame. Therefore, you can say that once a total of 1.0 in time has been calculated in multiple updates, you will have moved by 'speed' units.

didii

  • Full Member
  • ***
  • Posts: 122
    • View Profile
Well, this is actually very basic physics of dynamics. As Grimshaw stated, speed is expressed in distance per time-unit. Or written as a formula: v=x/t with v the velocity, x the position and t the time. Rewrite this and you get x=v*t or the exact formula you gave.

There are a couple things to note here, but there is plenty of information about dynamics on the internet. You might have simply missed the link to physics, but if you don't know, I suggest you start learning some of this before moving on. It's pretty vital.

 

anything