Skip to content

Use Delta Time Instead of Approximate Time Per Frame #18

@dreweso

Description

@dreweso

Currently the game uses approximate time per frame as a simple way to make it work at multiple frame rates.
A better practice is to use the actual time between frames, which is delta time (change in time).
I already implemented dt in the Game class, it's just not used.

I think this is what needs to be done:

  • Remove APPROX_TIME_PER_FRAME and multiply constants by dt instead. For example do ship.slow_down(arg * self.dt)
  • Use it everywhere in the game (ship, projectiles, asteroids)

At the moment if the game is running at a lower frame rate than it's supposed to, the change in time will be greater than the approximate predicted change in time defined in the constant APPROX_TIME_PER_FRAME. This should result in the ship going slower than it's supposed to.

Metadata

Metadata

Assignees

No one assigned

    Labels

    asteroidsFor issues related to the asteroids game.enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions