shadow_engine_2d

Crates.ioshadow_engine_2d
lib.rsshadow_engine_2d
version2.0.1
created_at2025-10-27 00:06:41.024466+00
updated_at2025-10-27 00:06:41.024466+00
descriptionA modern, high-performance 2D game engine built in Rust with ECS, physics, particles, audio, and more
homepagehttps://shadowteamengine-design.github.io/shadowengine2dwebsite/
repositoryhttps://github.com/shadowteamengine-design/ShadowEngine2d
max_upload_size
id1902042
size197,654
(shadowteamengine-design)

documentation

https://docs.rs/shadow_engine_2d

README

🦎 Shadow Engine 2D

Shadow the Axolotl

A modern, high-performance 2D game engine built in Rust

Crates.io Documentation License: MIT Rust

WebsiteDocumentationExamplesDiscord

Powered by Shadow the Axolotl 🖤


✨ Features

Shadow Engine 2D is a complete 2D game engine with everything you need to build amazing games:

🎮 Core Systems

  • Entity Component System (ECS) - Clean, intuitive architecture for game objects
  • GPU Rendering - Hardware-accelerated graphics with WGPU (Vulkan, DirectX 12, Metal)
  • Input Handling - Keyboard and mouse support with easy-to-use API
  • Time Management - Delta time and frame-independent movement

⚡ Physics

  • ShadowPhysics2D - Custom-built physics engine
    • Gravity and force simulation
    • Box and circle colliders
    • Collision detection and response
    • Dynamic and kinematic rigid bodies
    • Realistic physics behavior

🎨 Graphics & Effects

  • Sprite Rendering - Fast, batched sprite rendering with colors
  • Texture System - Load PNG, JPG, and other image formats
  • Particle System - Stunning visual effects
    • Continuous and burst emission modes
    • Built-in presets (explosion, fire, smoke)
    • Customizable emitters with gravity and velocity
  • Camera System - Professional camera controls
    • Smooth following with configurable speed
    • Zoom in/out functionality
    • Camera shake effects
    • Bounded camera movement

🖼️ UI System

  • Flexible UI Components
    • Panels with customizable borders
    • Interactive buttons with hover states
    • Progress bars
    • Anchor-based positioning (Center, TopLeft, TopRight, etc.)

🔊 Audio System

  • Sound Effects - Play multiple sounds simultaneously
  • Background Music - Looping music with volume control
  • Supported Formats - WAV, OGG, MP3, FLAC
  • Volume Control - Per-sound and global volume adjustment

🚀 Quick Start

Installation

Add Shadow Engine 2D to your Cargo.toml:

[dependencies]
shadow_engine_2d = "2.0.1"

Your First Game

use shadow_engine_2d::prelude::*;
use winit::keyboard::KeyCode;

fn main() {
    let mut engine = Engine::builder()
        .title("My Game")
        .size(1280, 720)
        .build();

    // Spawn player with physics
    let player = engine.world_mut().spawn();
    if let Some(entity) = engine.world_mut().entity_mut(player) {
        entity.add(Transform::new(0.0, 0.0));
        entity.add(Sprite::new(50.0, 50.0).with_color(Color::CYAN));
        entity.add(RigidBody::dynamic());
        entity.add(Collider::box_collider(50.0, 50.0));
    }

    // Game loop
    engine.run(|world, input, time| {
        let speed = 300.0;
        let dt = time.delta();

        for entity in world.entities_mut() {
            if let Some(transform) = entity.get_mut::<Transform>() {
                if input.key_pressed(KeyCode::KeyW) {
                    transform.position.y -= speed * dt;
                }
                if input.key_pressed(KeyCode::KeyS) {
                    transform.position.y += speed * dt;
                }
                if input.key_pressed(KeyCode::KeyA) {
                    transform.position.x -= speed * dt;
                }
                if input.key_pressed(KeyCode::KeyD) {
                    transform.position.x += speed * dt;
                }
            }
        }
    });
}

📚 Examples

Shadow Engine 2D comes with comprehensive examples:

Basic Game

cargo run --example basic_game

Simple player movement with WASD controls.

Physics Demo

cargo run --example physics_demo

Platformer with gravity, jumping, and collisions.

Particles & Camera

cargo run --example particles_camera_demo

Particle effects with camera following and zoom.

UI Demo

cargo run --example ui_demo

Health bars, buttons, and UI panels.

Audio Demo

cargo run --example audio_demo

Sound effects and background music.


🎯 Core Concepts

Entity Component System

Shadow Engine 2D uses an intuitive ECS architecture:

// Spawn an entity
let entity_id = world.spawn();

// Add components
if let Some(entity) = world.entity_mut(entity_id) {
    entity.add(Transform::new(100.0, 200.0));
    entity.add(Sprite::new(32.0, 32.0).with_color(Color::RED));
    entity.add(RigidBody::dynamic());
}

// Query entities
for entity in world.entities() {
    if let Some(transform) = entity.get::<Transform>() {
        println!("Position: {:?}", transform.position);
    }
}

Physics System

let physics = PhysicsSystem::new();

// Create a dynamic body
entity.add(RigidBody::dynamic()
    .with_velocity(Vec2::new(100.0, 0.0))
    .with_mass(2.0)
    .with_drag(0.1));

entity.add(Collider::box_collider(50.0, 50.0));

// Update physics in game loop
physics.update(world, dt);
let collisions = physics.detect_collisions(world);
physics.resolve_collisions(world, &collisions);

// Apply forces
if let Some(body) = entity.get_mut::<RigidBody>() {
    body.apply_force(Vec2::new(1000.0, 0.0));
    body.apply_impulse(Vec2::new(0.0, -500.0)); // Jump!
}

Particle System

let mut particle_system = ParticleSystem::new();

// Create particle emitter
let emitter_id = world.spawn();
if let Some(entity) = world.entity_mut(emitter_id) {
    entity.add(Transform::new(0.0, 0.0));
    entity.add(ParticleEmitter::explosion());
    // or ParticleEmitter::fire()
    // or ParticleEmitter::smoke()
}

// Update particles
particle_system.update(world, dt);

Camera System

let mut camera = Camera::new();

// Follow an entity
camera.follow(player_id);
camera.follow_speed = 5.0;

// Zoom
camera.zoom(1.5);

// Camera shake
camera.shake(10.0, 0.5); // intensity, duration

// Update camera
camera.update(world, dt);

Audio System

let mut audio = AudioSystem::new().unwrap();

// Load sounds
audio.load_sound("jump", "assets/sounds/jump.wav").unwrap();
audio.load_sound("coin", "assets/sounds/coin.wav").unwrap();

// Play sound effects
audio.play_sound("jump").unwrap();
audio.play_sound_with_volume("coin", 0.7).unwrap();

// Background music
audio.play_music("assets/music/background.mp3").unwrap();
audio.set_music_volume(0.5);
audio.pause_music();
audio.resume_music();

UI System

// Create a health bar
let health_bar = world.spawn();
if let Some(entity) = world.entity_mut(health_bar) {
    entity.add(UITransform::new(Anchor::TopLeft)
        .with_offset(Vec2::new(20.0, 20.0)));
    entity.add(UIProgressBar::new(200.0, 30.0)
        .with_value(0.75)
        .with_color(Color::GREEN));
}

// Create a button
let button = world.spawn();
if let Some(entity) = world.entity_mut(button) {
    entity.add(UITransform::new(Anchor::Center));
    entity.add(UIButton::new());
    entity.add(UIPanel::new()
        .with_size(Vec2::new(200.0, 60.0))
        .with_color(Color::BLUE));
}

🎨 Asset Loading

Textures

// Load from file
let texture = Texture::load(&device, &queue, "assets/player.png").unwrap();

// Load from bytes (embedded)
let bytes = include_bytes!("../assets/enemy.png");
let texture = Texture::from_bytes(&device, &queue, bytes, "enemy").unwrap();

// Sprite sheets
let spritesheet = SpriteSheet::new("characters", 32, 32);
let (u1, v1, u2, v2) = spritesheet.get_uv_coords(0);

Audio

Supported formats: WAV, OGG, MP3, FLAC

audio.load_sound("explosion", "assets/sounds/explosion.wav").unwrap();
audio.play_sound("explosion").unwrap();

🛠️ Building from Source

# Clone the repository
git clone https://github.com/yourusername/shadow_engine_2d.git
cd shadow_engine_2d

# Build the library
cargo build --release

# Run examples
cargo run --example basic_game
cargo run --example physics_demo
cargo run --example particles_camera_demo
cargo run --example ui_demo
cargo run --example audio_demo

# Run tests
cargo test

📦 Dependencies

Shadow Engine 2D is built on top of excellent Rust crates:

  • winit - Cross-platform window creation
  • wgpu - Modern graphics API (Vulkan, DirectX 12, Metal)
  • glam - Fast math library
  • rodio - Audio playback
  • image - Image loading and processing
  • glyphon - Text rendering

🎯 Roadmap

  • Entity Component System
  • GPU Rendering
  • Physics System
  • Particle System
  • Camera System
  • UI System
  • Audio System
  • Texture Loading
  • Animation System
  • Tilemap/Level Editor
  • Networking (Multiplayer)
  • Save/Load System
  • Scene Management
  • Asset Hot Reloading
  • Mobile Support (iOS/Android)
  • WebAssembly Support

📄 License

Shadow Engine 2D is licensed under the MIT License - see the LICENSE file for details.


👨‍💻 About the Creator

Darian Jones - Age 14, Rust Developer

Shadow Engine 2D was created as a passion project to make 2D game development in Rust accessible, powerful, and fun. Inspired by Shadow the Axolotl, this engine aims to provide a clean API without sacrificing performance or features.

  • 🦀 Rust enthusiast
  • 🦎 Exotic animal lover (especially axolotls!)
  • 🍕 Food adventurer
  • 🎮 Game engine developer

"Building games should be fun, fast, and safe. That's why Shadow Engine 2D exists!"


🙏 Acknowledgments

  • Shadow the Axolotl 🦎 - Official mascot and inspiration
  • The Rust community for amazing libraries and support
  • All contributors and users of Shadow Engine 2D

📞 Contact & Community


Made with 🖤 by Darian Jones

Powered by Shadow the Axolotl 🦎

⭐ Star us on GitHub if you like Shadow Engine 2D!

Commit count: 0

cargo fmt