Add example of FrameRateLimitConfig RON file to API/Pong Tutorial set up step

(Hyper Sonic) #1

I was adding a FrameRateLimit to my app and tried to move the config to a file following: FrameRateLimitConfig doc

I noticed there is no example of using the FrameRateLimitConfig in the doc, nor in amethyst-repo/examples. I made one myself based on the example in frame_limiter doc but new users may benefit from a concrete example (I guess it’s trivial to convert a struct into a RON for more advanced users, but it took me some time to find out).

It could also be added to the Pong Tutorial in Setting up the project (either using with_frame_limit or with_frame_limit_config + a RON) since other config files are made in that step. Also, the tutorial never mentioned that the default FPS was 144 so it surprised me when I debugged the timer, as I was expecting 30 or 60FPS.

By the way, here is my frame_limiter.ron for those looking for an example:

(
	strategy: SleepAndYield(Duration(secs: 0, nanos: 2000000)),
	fps: 60,
)

# usage
.with_frame_limit_config(frame_limit_config)

equivalent to

.with_frame_limit(
        FrameRateLimitStrategy::SleepAndYield(Duration::from_millis(2)),
        60,
    )
1 Like
(Nathan) #2

Nice! I think adding a concrete example to the API docs is an excellent suggestion. The goal of the Pong example is:

To get a better feeling for how Amethyst works…

…and framerate is definitely a fundamental aspect of running a game, so I think it fits in there too.

Will you create a pull request with the additions?

1 Like