This is a Snake game built using Rust and WebAssembly (WASM), with a React frontend. The game runs efficiently in the browser using WebGL2 for rendering.
- WebAssembly-Powered: The game logic is written in Rust and compiled to WebAssembly for high performance.
- React Integration: A React frontend handles game settings and user interactions.
- WebGL2 Rendering: Uses WebGL2 for smooth and efficient graphics.
- Rust → Game logic and WebAssembly bindings
- WebAssembly (WASM) → Runs the Rust code in the browser
- React (TypeScript) → Frontend UI
- WebGL2 → Graphics rendering
- JS/WASM Interop →
wasm_bindgen
for Rust-JS communication
- The game initializes a WebGL2 rendering context.
- The snake moves automatically, and the player controls its direction using the keyboard.
- When the snake eats food, it grows in size.
- If the snake collides with itself, the game resets.
- The game runs inside a requestAnimationFrame loop for smooth performance.
- Open the game in a browser.
- Use arrow keys to move the snake.
- Eat food to grow longer.
- Avoid hitting the walls or yourself.
- Pause the game by opening the settings panel (top-left three-dot menu).
git clone https://github.com/Jozefpodlecki/Snake
Run the following command inside the game
directory:
cd game
wasm-pack build --target web --out-dir ../web/snake-game --debug
Navigate to the web
directory and start the development server:
cd web
npm install
npm run dev