HaxeFlixel / HaxeFlixel/flixel
Use a float to represent game ticks
Nobody has claimed this yet.
- Dominant language
- Haxe
- Stars
- 2.2k
- Forks
- 522
- Avg merge
- 34m
- Merged PRs (30d)
- 1
Description
This is a breaking change!
Flixel currently uses Flash/OpenFL's Lib.getTimer() method to determine the game ticks. This method returns the current time, in miliseconds, as an integer. Because of this, it's also not entirely precise as it cuts off the decimal portion.
If we wanted to measure the delta time of a 60fps frame, we'd get 16ms instead of the ~16.667ms it actually took. As the framerate gets higher, we lose more and more precision, and past 500fps we can't accurately determine the delta time anymore.
I will note that internally Flixel already calculates the deltatime as a float (_elapsedMS is a float):
https://github.com/HaxeFlixel/flixel/blob/c32ab91babccfff4515665db3358168af70496c6/flixel/FlxGame.hx#L461-L463... so this change would only need to be done on FlxGame.getTimer(), FlxG.game.ticks and anything else that deals with ticks.
EDIT: Originally I was thinking of swapping Lib.getTimer() out for a more precise timer, like haxe.Timer.stamp(), but it turns out Lime shadows and makes it point to Lib.getTimer(), making it useless... Will have to check in with the OpenFL guys and then see what could be done
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in flixel/FlxGame.hx around the existing _elapsedMS calculation and inspect FlxGame.getTimer(), FlxG.game.ticks, and other tick consumers. Check how Lime/OpenFL exposes Lib.getTimer(), then confirm that affected tick values preserve fractional milliseconds and that all consumers remain consistent.
Written by the indexing model from the issue text.
Assessment
- Domain
- game-dev
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100