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

Author Topic: player speed  (Read 1999 times)

0 Members and 1 Guest are viewing this topic.

paupav

  • Full Member
  • ***
  • Posts: 156
    • View Profile
    • Email
player speed
« on: July 05, 2014, 12:29:00 pm »
Ok, I wanna create simple snake game, and I'm stuck.
And I've wanted to ask you how do you create variable that defines player's speed.
E.g I wanna make my snake moves 15 blocks every second. Do you use clock somehow?

This is how I did it before, but that's messy way of doing that:
http://en.sfml-dev.org/forums/index.php?topic=15009.msg105920#msg105920

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: player speed
« Reply #1 on: July 05, 2014, 01:10:03 pm »
The answer to your question can be found in every basic physics textbook. Speed is distance travelled per unit time.
And yes, you would use a clock to keep track of time passed.

Edit: I recently made a simple example of a bouncing ball. Take a look - maybe it'll help you :)
« Last Edit: July 05, 2014, 02:45:02 pm by Jesper Juhl »