A rust exercise to be done in a coding dojo.
The goal is to create a small intro.
Give participants some Rust insight that will give them motivations to learn more. This is also an experimentation to know if this approach could help people to start and learn Rust.
- Create a starfield.
โ ๏ธ (0,0) is not the screen center.- Stars are darker and smaller in the center of the screen.
- Advice refactor to use modules.
- Create a sinus, rainbow scrolling text.
- Advice refactor to use a builder pattern.
- Clone the project
git clone https://github.com/uggla/dojo3
- Go to the project directory
cd dojo3
-
Install Rust following the instructions here.
Tips: the rustup method is the simplest one.
-
Install required library for macroquad
- Ubuntu system dependencies
apt install pkg-config libx11-dev libxi-dev libgl1-mesa-dev libasound2-dev
- Fedora system dependencies
dnf install libX11-devel libXi-devel mesa-libGL-devel alsa-lib-devel
- Windows and MacOS system
No dependencies are required for Windows or MacOS
- Run
cargo run --release
-
Follow the above instruction of the native build.
-
Install basic-http-server
cargo install basic-http-server
- Add the wasm32 compilation target
rustup target add wasm32-unknown-unknown
- Run
cargo build --target wasm32-unknown-unknown --release
- Serve the files and open the browser
basic-http-server
xdg-open http://127.0.0.1:4000