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

add exercise #1

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

add exercise #1

wants to merge 3 commits into from

Conversation

mvdelcampo
Copy link

I added my implementation of the exercise, although I am not sure the part with WebAssembly works fine.

Comment on lines +118 to +124
thread::sleep(time::Duration::from_secs(1));

loop {
universe.tick();
universe.draw_grid();
next_frame().await; // // submit our render calls to our screen
thread::sleep(time::Duration::from_secs(1));
Copy link

@IAvecilla IAvecilla Mar 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't work with WASM because of the usage of thread::sleep.This is a good way to control the frames per second (FPS) running the app normally but fails to run in the browser. There is an issue on the macroquad lib asking how to achieve this compiling for WASM not-fl3/macroquad#380 (TLDR: there's a workaround but it's not supported on the lib). Right now it would be okay to allow the app runs freely without limiting the FPS when compiling for WASM. You can add #[cfg(not(target_arch = "wasm32"))] above both sleep calls to tell the compiler to execute that lines unless it's compiling for WASM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants