Expand description
Rusty Engine is a simple, 2D game engine for those who are learning Rust. Create simple game prototypes using straightforward Rust code without any advanced 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.
§Quick Start Example
You start by importing rusty_engine::prelude::*
, define your own GameState
struct,
create a Game
, set up your game, and then call
Game::run
.
use rusty_engine::prelude::*;
// Define a struct to hold custom data for your game (it can be a lot more complicated than this one!)
#[derive(Resource)]
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, 0.1);
// 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;
}
}
§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.
Modules§
- audio
- Facilities for interacting with audio, including:
AudioManager
,MusicPreset
, andSfxPreset
- game
- keyboard
- Facilities for dealing with keyboard input
- mouse
- Facilities for dealing with mouse input
- physics
- Rusty Engine’s custom collision detection implementation.
- prelude
- sprite
- text
Constants§
- DOWN
- The rotation (in radians) for a sprite to face down
- EAST
- The rotation (in radians) for a sprite to face east
- LEFT
- The rotation (in radians) for a sprite to face left
- NORTH
- The rotation (in radians) for a sprite to face north
- NORTH_
EAST - The rotation (in radians) for a sprite to face north east
- NORTH_
WEST - The rotation (in radians) for a sprite to face north west
- RIGHT
- The rotation (in radians) for a sprite to face right
- SOUTH
- The rotation (in radians) for a sprite to face south
- SOUTH_
EAST - The rotation (in radians) for a sprite to face south east
- SOUTH_
WEST - The rotation (in radians) for a sprite to face south west
- UP
- The rotation (in radians) for a sprite to face up
- WEST
- The rotation (in radians) for a sprite to face west