I'm confused about the game speed

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
Sheepolution
Party member
Posts: 264
Joined: Mon Mar 04, 2013 9:31 am
Location: The Netherlands
Contact:

I'm confused about the game speed

Post by Sheepolution »

When I was testing out some movement code, I figured out that the Love2D engine is extremely fast. I mean as in its fps.

When giving a speed of 10 to the player and moving around, it seems like the engine runs 100 frames per second. So I decided to print the fps, which resulted into 1.

So then I decided to use deltatime, and by adding deltatime the game went from extremely fast to extremely slow. Now I need to give my player a speed of 100 to make him move with decent speed. But when I printed deltatime, it resulted in 1.6

I'm really confused right now. To make the question more clear and for me to have a clear answer. How do I make a timer of 15 seconds.

Code: Select all

--60 being the frames per seconds
timer = 15 * 60
timer = timer - 1 * 60
PS: I noticed that on a friends computer the engine runs slower.
User avatar
Jasoco
Inner party member
Posts: 3725
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: I'm confused about the game speed

Post by Jasoco »

Here's a rule of thumb. Delta Time lets your objects move at a constant pace. You simply specify how far you want it to move, or how much of so and so value the object needs, over the course of 1 second.

If you want an object to move at 200 pixels per second, use object.x = object.x + object.speed * dt. This will make the object have moved 200 pixels by the time 1 second is done.

If you don't use dt, your game will have fluctuating speeds on different machines because some run faster than others or slower than others.

For example, in your code above, replace the 60 with dt. Because games won't always run at a constant 60FPS, and even if they do, each frame might be slightly more or less than 1/60th of a second due to other processes on the machine.
User avatar
Sheepolution
Party member
Posts: 264
Joined: Mon Mar 04, 2013 9:31 am
Location: The Netherlands
Contact:

Re: I'm confused about the game speed

Post by Sheepolution »

Oh so that's how it works!

So always using delta and count it as 1 second? Got it!
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 4 guests