K
K
Kuusandr2019-05-28 17:00:16
Java
Kuusandr, 2019-05-28 17:00:16

Too fast fps. How to make game object movements slower?

Made a simple project with tile mechanics. There was a problem, too many fps, the main game object is moving too fast. I googled the Internet, tried to apply the advice on limiting fps (with falling asleep for the estimated time in render). Movement speed seems to be much smoother. But with this, another more sloppy problem arose, with a fps limit, the smart began to react with a noticeable delay to taps.
How to make game object move slower while maintaining fps?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
T
tsarevfs, 2019-05-28
@Kuusandr

Calculate the movement of the object based on the desired speed as dx = v * dt. To calculate dt, subtract the time stamp from the previous frame from the current time stamp.

S
SagePtr, 2019-05-28
@SagePtr

The first rule is never tie speed to FPS. I came across a game that was impossible to complete on slow hardware, because for some reason the player’s speed was tied to FPS, and the speed of game events was tied to time, as a result, if FPS was around 30, then the player simply did not have time in those places , where it was necessary to do something at speed, but the time reserve was not given.
Yes, and it's just unpleasant when everything starts to move slowly, frame skipping is much better, because it does not slow down the game, but only worsens the picture.

G
GreatRash, 2019-05-28
@GreatRash

But with this, another more sloppy problem arose, with a fps limit, the smart began to react with a noticeable delay to taps.

In all game engines, the game cycle is divided into two parts: physics processing (PhysicsUpdate, _physics_process, etc.) and logic / user input processing (Update, _process, etc.)
You need to track input inside a regular update with the highest possible fps . But it is already necessary to apply physics (i.e. move objects, etc.) using a physics update with a frame time delta.
Here is a tutorial on the topic - https://gameprogrammingpatterns.com/game-loop.html

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question