Skip to content

Jozefpodlecki/Snake

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🐍 WebAssembly Snake Game

rustc wasm-bindgen codecov

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.

🚀 Features

  • 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.

🛠️ Technology Stack

  • Rust → Game logic and WebAssembly bindings
  • WebAssembly (WASM) → Runs the Rust code in the browser
  • React (TypeScript) → Frontend UI
  • WebGL2 → Graphics rendering
  • JS/WASM Interopwasm_bindgen for Rust-JS communication

📜 How It Works

Game Loop

  1. The game initializes a WebGL2 rendering context.
  2. The snake moves automatically, and the player controls its direction using the keyboard.
  3. When the snake eats food, it grows in size.
  4. If the snake collides with itself, the game resets.
  5. The game runs inside a requestAnimationFrame loop for smooth performance.

🕹️ How to Play

  1. Open the game in a browser.
  2. Use arrow keys to move the snake.
  3. Eat food to grow longer.
  4. Avoid hitting the walls or yourself.
  5. Pause the game by opening the settings panel (top-left three-dot menu).

📦 Installation & Setup

1️⃣ Clone the Repository

git clone https://github.com/Jozefpodlecki/Snake

2️⃣ Build the WebAssembly Module

Run the following command inside the game directory:

cd game
wasm-pack build --target web --out-dir ../web/snake-game --debug

3️⃣ Install Dependencies & Start the Web App

Navigate to the web directory and start the development server:

cd web
npm install
npm run dev

📜 Credits

About

Snake game with Rust/Webassembly

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages