DEV Community

moonwalker
moonwalker

Posted on

How Games Maintain Consistent Speed Across Different Devices

Our game wants to rotate something at 3 radians/second on every device. Let's see how this works at different framerates.

For a device running at 60 FPS:

Delta time (time for 1 frame) = 0.0167 seconds
Rotation covered in 1 frame = 0.0167 * 3 (radians/second) = 0.05 radians
Total rotation in 60 frames = 0.05 * 60 = 3 radians

For a device running at 30 FPS:

Delta time (time for 1 frame) = 0.033 seconds
Rotation covered in 1 frame = 0.033 * 3 (radians/second) = 0.1 radians
Total rotation in 30 frames = 0.1 * 30 = 3 radians

The key insight here is that based on FPS, the amount of rotation that happens in a single frame changes. For higher FPS it's lower (smaller steps), and for lower FPS it's higher (bigger steps).

But the total rotation over one second remains the same: 3 radians.

This is why we use delta time - it ensures consistent motion regardless of the device's frame rate. Instead of applying rotation (3 radians/second) directly per frame, we calculate the appropriate rotation for each frame by multiplying our desired rate by delta time (seconds/frame).

So time dependency becomes frame dependency that resolves itself on each device.

Image of Docusign

Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs