Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manual Content: delta_time() example should not use hardcoded microseconds value #8700

Closed
gm-bug-reporter bot opened this issue Dec 14, 2024 · 3 comments
Assignees
Labels
docs-bug GameMaker Manual Bugs
Milestone

Comments

@gm-bug-reporter
Copy link

gm-bug-reporter bot commented Dec 14, 2024

Description

The manual's example of delta time is incorrect and will confuse users not used to programming with delta time in mind.

Image

Expected Change

The example should be corrected to:

var _dt = delta_time / game_get_speed(gamespeed_microseconds);
speed = spd * _dt;

Manual Link

https://manual.gamemaker.io/monthly/en/#t=GameMaker_Language%2FGML_Reference%2FMaths_And_Numbers%2FDate_And_Time%2Fdelta_time.htm

Which version of GameMaker are you reporting this issue for?

IDE v2024.8.1.171 Runtime v2024.8.1.218

Which operating system(s) are you seeing the problem on?

Windows 10.0.19045.0

ba0f23b0-fb20-46d3-bf0c-301c6a91b8cb

@gm-bug-reporter gm-bug-reporter bot added the docs-bug GameMaker Manual Bugs label Dec 14, 2024
@YYDan YYDan changed the title Manual example for delta_time is incorrect Manual Content: delta_time() example is incorrect Dec 16, 2024
@YYDan YYDan changed the title Manual Content: delta_time() example is incorrect Manual Content: delta_time() example should not use hardcoded microseconds value Dec 16, 2024
@stuckie stuckie moved this from Triage to Backlog in Team Workload Dec 16, 2024
@DragoniteSpam
Copy link

The example is "correct," but it lacks context.

In a 60 fps game, the manual example resolves to 16_666 / 1_000_000, or 0.016, which is fine if spd is a value defined in units/second.

Your example resolves to 16_666 / 16_666, or 1, which is fine if spd is a value defined in units/frame.

Ideally the manual should explain both.

@mistletoe
Copy link

It be simpler to simply have a hard-coded standard value.

I've been using globals like these:

global.microSecond = 1000000.0;
global.microSecondOverOne = 1/global.microSecond;//Used when we want to use this as a cheap multiplier, etc.

There should probably be some standard variables, like

micro_second = 1000000.0;
micro_second_over_one = 1/1000000.0;

It's arguable that there should be a micro_second_per_step, as well, which is just returning game_get_speed(gamespeed_microseconds). It's just syntactic sugar, though.

For most games, this value's set once and only once, but it gets tricky when you're doing things like time warping, etc.

@YYBartT YYBartT moved this from Backlog to In Progress in Team Workload Dec 19, 2024
@YYBartT YYBartT added this to the 2024.13 milestone Dec 19, 2024
YYBartT added a commit to YoYoGames/GameMaker-Manual that referenced this issue Dec 20, 2024
…nds value

YoYoGames/GameMaker-Bugs#8700

* Changed the code example to use game_get_speed(gamespeed_microseconds) and clarified that the base speed should also be expressed in pixels per step
* Small changes to game_get_speed() page
YYBartT added a commit to YoYoGames/GameMaker-Manual that referenced this issue Dec 20, 2024
…onds value

YoYoGames/GameMaker-Bugs#8700

* Added a second example that explains how the original example can be used with a base speed in pixels per second
* Tiny fixes on the "speed" function page
@YYBartT
Copy link

YYBartT commented Dec 20, 2024

Changed the ratio _dt in the code example to delta_time / game_get_speed(gamespeed_microseconds). Added the original code example as Example 2, since the multiplication does convert a base speed in pixels per second to one in pixels per step in that case.

@YYBartT YYBartT closed this as completed Dec 20, 2024
@github-project-automation github-project-automation bot moved this from In Progress to Done in Team Workload Dec 20, 2024
@YYBartT YYBartT moved this from Done to Ready for QA in Team Workload Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs-bug GameMaker Manual Bugs
Projects
Status: Ready for QA
Development

No branches or pull requests

4 participants