• Stars
    star
    366
  • Rank 116,547 (Top 3 %)
  • Language
    Rust
  • Created over 4 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

2D game engine for learning Rust

Rusty Engine

Rusty Engine is a simple, 2D game engine for those who are learning Rust. Create simple game prototypes using straightforward Rust code without needing to learning difficult game engine concepts! It works on macOS, Linux, and Windows. Rusty Engine is a simplification wrapper over Bevy, which I encourage you to use directly for more serious game engine needs.

Questions, bug reports, and contributions are most welcome!

RoadRace.mp4

Documentation

Features

  • Asset pack included (sprites, music, sound effects, and fonts)
  • Sprites (2D images)
    • Use sprites from the included asset pack, or bring your own
    • Collision detection with custom colliders
  • Audio (music & sound effects)
    • Looping music
    • Multi-channel sound effects
  • Text
    • 2 fonts included, or bring your own
  • Input handling (keyboard, mouse)
  • Timers
  • Custom game state
  • Window customization

Courses

If you like Rusty Engine, please sponsor me on GitHub or on Patreon, or take one of my courses below!

The following courses use Rusty Engine in their curriculum:

Linux Dependencies (Including WSL 2)

If you are using Linux or Windows Subsystem for Linux 2, please visit Bevy's Installing Linux Dependencies page and follow the instructions to install needed dependencies.

Quick Start

You MUST download the assets separately!!!

Here are three different ways to download the assets (pick any of them--it should end up the same in the end):

  • Clone the rusty_engine repository and copy/move the assets/ directory over to your own project
  • Download a zip file or tarball of the rusty_engine repository, extract it, and copy/move the assets/ directory over to your own project.
  • (My favorite!) On a posix compatible shell, run this command inside your project directory:
curl -L https://github.com/CleanCut/rusty_engine/archive/refs/heads/main.tar.gz | tar -zxv --strip-components=1 rusty_engine-main/assets

Add rusty_engine as a dependency

# In your [dependencies] section of Cargo.toml
rusty_engine = "5.2.1"

Write your game!

// in src/main.rs
 use rusty_engine::prelude::*;

 // Define a struct to hold custom data for your game (it can be a lot more complicated than this one!)
 struct GameState {
     health: i32,
 }

 fn main() {
     // Create a game
     let mut game = Game::new();
     // Set up your game. `Game` exposes all of the methods and fields of `Engine`.
     let sprite = game.add_sprite("player", SpritePreset::RacingCarBlue);
     sprite.scale = 2.0;
     game.audio_manager.play_music(MusicPreset::Classy8Bit, 1.0);
     // Add one or more functions with logic for your game. When the game is run, the logic
     // functions will run in the order they were added.
     game.add_logic(game_logic);
     // Run the game, with an initial state
     let initial_game_state = GameState { health: 100 };
     game.run(initial_game_state);
 }

 // Your game logic functions can be named anything, but the first parameter is always a
 // `&mut Engine`, and the second parameter is a mutable reference to your custom game
 // state struct (`&mut GameState` in this case).
 //
 // This function will be run once each frame.
 fn game_logic(engine: &mut Engine, game_state: &mut GameState) {
     // The `Engine` contains all sorts of built-in goodies.
     // Get access to the player sprite...
     let player = engine.sprites.get_mut("player").unwrap();
     // Rotate the player...
     player.rotation += std::f32::consts::PI * engine.delta_f32;
     // Damage the player if it is out of bounds...
     if player.translation.x > 100.0 {
         game_state.health -= 1;
     }
 }

Run your game with cargo run --release!

example screenshot

See also the tutorial, game scenarios, code examples and the API documentation

Student Showcase

Show off the project you made with Rusty Engine! Learning Rust can be fun. πŸ˜„ Just send me a link and I'll add it to the list!

Contribution

All software contributions are assumed to be dual-licensed under MIT/Apache-2. All asset contributions must be under licenses compatible with the software license, and explain their license(s) in a README.md file in the same directory as the source files.

Asset Licenses

All assets included with this game engine have the appropriate license described and linked to in a README.md file in the same directory as the source files. In most cases, the license is CC0 1.0 Universal--meaning you may do whatever you wish with the asset.

One notable exception is some of the music files, which are under a different license and include specific attribution requirements that must be met in order to be used legally when distributed. Please see this README.md file for more information.

Software License

Distributed under the terms of both the MIT license and the Apache License (Version 2.0).

See license/APACHE and license/MIT.

More Repositories

1

ultimate_rust_crash_course

Rust Programming Fundamentals - one course to rule them all, one course to find them...
Rust
1,925
star
2

green

Green is a clean, colorful, fast python test runner.
Python
795
star
3

ultimate_rust2

The best Intermediate Rust course out there!
Rust
256
star
4

invaders

Open source terminal arcade game with audio - based off of the classic "Space Invaders"
Rust
202
star
5

rust_programming

Rust Programming: A Crash Course
68
star
6

rusty_sword_arena

Rusty Sword Arena: A Crash Course in Rust (Companion repository to the OSCON tutorial)
Rust
48
star
7

headtail

head and tail simultaneously
Rust
43
star
8

bevy_template

Compile-time optimized Bevy project template
Shell
27
star
9

rusty_sword

Rusty Sword: Game of Infamy!
Rust
14
star
10

rusty_audio

Fun & easy audio playback library.
Rust
9
star
11

bevy_rapier2d_assets

A plugin to make it easy to load 2d physics assets from disk
Rust
9
star
12

pipeviewer

Companion project for the hands-on Rust course I produced for Packt
Rust
9
star
13

shooting_stars

On a starry night, in a field, shooting stars fall from the sky...and Ferris (and his friends) compete to catch them.
Rust
9
star
14

UnrealEngineHelper

Settings, templates, workflow information. Things that help when working with UnrealEngine.
Python
6
star
15

cleancut

6
star
16

bevy_cleancut

Random utility stuff for bevy for my personal use. You're welcome to use it, too, if you like.
Rust
4
star
17

punchball

Punch Ball
Rust
4
star
18

examine

Practice creating grpc services and clients with buf.build, Rust, and tonic
Rust
3
star
19

vc

vc is an implementation of Git in Rust
Rust
3
star
20

rusty_racing

Rusty Racing: A Crash Course in Rust (Companion repository to the OSCON 2020 tutorial)
3
star
21

rusty_textui

Library for creating simple text user interfaces, like text arcade games in the terminal
Rust
3
star
22

duel

An independent re-write of the client for Rusty Sword Arena, with tags for the various stages. This repository will be deleted if RSA gets refactored.
Rust
3
star
23

bevy_pause

A very simple pause plugin for Bevy
Rust
3
star
24

shell_cmds

Port Apple's various shell commands from C to Rust
Rust
2
star
25

dotfiles

My dotfiles
Shell
2
star
26

spaceblasters

A space wars-like game prototype created for the Utah Rust User Group's mini-game jam
Rust
2
star
27

leafwingbug

Demonstrate a bug
Rust
1
star
28

rusty_time

A simple timer
Rust
1
star
29

r_circlegauntlet

Open source game using Rusty Engine: Blue circle trying to reach green circle without touching red circles
Rust
1
star
30

cirena

Circles in an arena. A simple game prototype.
Rust
1
star
31

rolling

Quick demo of a rolling game
Rust
1
star
32

typing

Playing around with teaching typing
Shell
1
star
33

chat_app

just doing a ruby on rails tutorial
Ruby
1
star