Skip to content

SaurabPoudel/slitherio-rust

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Slither.io Game in Rust

A multiplayer Slither.io-style game built with Rust, Bevy game engine, and WebSocket networking.

Architecture

This project uses a shared client-server architecture:

  • shared/: Common types and structures used by both client and server
  • server/: Game server with Bevy ECS for game logic and WebSocket networking
  • client/: Game client with Bevy rendering and WebSocket networking

Features

  • Multiplayer snake gameplay
  • Real-time WebSocket networking
  • Food consumption and snake growth
  • Collision detection (snake-to-snake and self-collision)
  • Smooth movement and rendering
  • World boundaries with wrapping

Running the Game

Start the Server

cd server
cargo run

The server will start listening on ws://127.0.0.1:8080

Start the Client

cd client
cargo run

The client will automatically connect to the server and you can start playing!

Controls

  • Arrow Keys or WASD: Control snake direction
  • ESC: Disconnect from server

Game Mechanics

  • Snakes move continuously in the current direction
  • Eating food makes the snake grow longer
  • Colliding with other snakes causes death
  • Self-collision after 5 segments causes death
  • World wraps around at boundaries

Dependencies

  • bevy: Game engine and ECS
  • tokio: Async runtime
  • tokio-tungstenite: WebSocket implementation
  • serde: Serialization for network messages
  • shared: Common game types

Project Structure

slitherio/
├── Cargo.toml          # Workspace configuration
├── shared/             # Shared library
│   ├── Cargo.toml
│   └── src/lib.rs      # Common types and messages
├── server/             # Game server
│   ├── Cargo.toml
│   └── src/
│       ├── main.rs     # Server entry point
│       ├── game.rs     # Game logic and ECS
│       └── network.rs  # WebSocket networking
└── client/             # Game client
    ├── Cargo.toml
    └── src/
        ├── main.rs     # Client entry point
        ├── render.rs   # Rendering and input
        └── network.rs  # WebSocket networking

Building

Make sure you have Rust installed, then:

# Build all workspace members
cargo build

# Build with optimizations
cargo build --release

Testing

# Run tests for all workspace members
cargo test

# Run tests for specific crate
cargo test -p shared
cargo test -p server
cargo test -p client

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages