2D games in Rust workshop

Help eachother with technical issues!

Dependencies Ubuntu 18.04

sudo apt install libasound2-dev libudev-dev

You may have to run on a session using x11 (wayland did not work for me)

Dependencies archlinux

You need pulseaudio-alsa installed to have sound

sudo pacman -S pulseaudio-alsa

FAQ

I get "error: Could not compile arrayvec." on MacOS Mojave?

Upgrade your Rust version to latest Rust, 1.39.0 (I was on 1.17 when I got this error).

rustup update

on MacOS I can build and run, but got a blank window?

Blank window is expected. See README.md:

Once the game has compiled and started running, you should see a blank window. Believe it or not, that's what we want! It means the game is running and displaying successfully.

Panic when executing cargo run in Wayland

Wayland backend is broken where it doesn't support windows resizing. See this: https://github.com/ggez/ggez/issues/579. The workaround is to run it using X11.

export WINIT_UNIX_BACKEND=x11

before running cargo run.

This requires XWwayland (in arch that is sudo pacman -S xwayland)

My crab is insanely fast

Wouter Geraedts I'm figuring out how to limit the update framerate. Apparently it goes to 2500 FPS.

See the timer documentation of ggez on docs.rs. Add this to your update loop in mod.rs:

while ggez::timer::check_update_time(ctx, 60) {
    ...<logic>
}
Ok(())

Or better:

if !ggez::timer::check_update_time(ctx, 60) {
    ggez::timer::sleep(ggez::timer::remaining_update_time(ctx));
}
...<logic>
Ok(())

Music is not playing even I have added let _ = self.assets.bg_sound.play();

If you play it unconditionally it will just start over again and again, which is equivalent to it beeing silent. Check first if it is already running.

Select a repo