| Crates.io | shadow_engine_2d |
| lib.rs | shadow_engine_2d |
| version | 2.0.1 |
| created_at | 2025-10-27 00:06:41.024466+00 |
| updated_at | 2025-10-27 00:06:41.024466+00 |
| description | A modern, high-performance 2D game engine built in Rust with ECS, physics, particles, audio, and more |
| homepage | https://shadowteamengine-design.github.io/shadowengine2dwebsite/ |
| repository | https://github.com/shadowteamengine-design/ShadowEngine2d |
| max_upload_size | |
| id | 1902042 |
| size | 197,654 |
A modern, high-performance 2D game engine built in Rust
Website • Documentation • Examples • Discord
Powered by Shadow the Axolotl 🖤
Shadow Engine 2D is a complete 2D game engine with everything you need to build amazing games:
Add Shadow Engine 2D to your Cargo.toml:
[dependencies]
shadow_engine_2d = "2.0.1"
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;
}
}
}
});
}
Shadow Engine 2D comes with comprehensive examples:
cargo run --example basic_game
Simple player movement with WASD controls.
cargo run --example physics_demo
Platformer with gravity, jumping, and collisions.
cargo run --example particles_camera_demo
Particle effects with camera following and zoom.
cargo run --example ui_demo
Health bars, buttons, and UI panels.
cargo run --example audio_demo
Sound effects and background music.
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);
}
}
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!
}
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);
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);
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();
// 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));
}
// 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);
Supported formats: WAV, OGG, MP3, FLAC
audio.load_sound("explosion", "assets/sounds/explosion.wav").unwrap();
audio.play_sound("explosion").unwrap();
# 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
Shadow Engine 2D is built on top of excellent Rust crates:
Shadow Engine 2D is licensed under the MIT License - see the LICENSE file for details.
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.
"Building games should be fun, fast, and safe. That's why Shadow Engine 2D exists!"
Made with 🖤 by Darian Jones
Powered by Shadow the Axolotl 🦎
⭐ Star us on GitHub if you like Shadow Engine 2D!