Skip to content

An asteroids-like twinstick shooter written in Rust using Piston and Legion.

Notifications You must be signed in to change notification settings

Tomboyo/rust-rocks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

76 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust Rocks

An Asteroids-like game built for fun using the Piston framework and Legion.

Demo gif

Controls

Only xbox-pattern gamepad controls are currently supported. I use a Logitech F710 for testing.

Use the d-pad to navigate menu options, the left thumbstick to accelerate, the right thumbstick to aim, and the right bumper to shoot. Press start to pause and unpause.

Compile & Run

You must install the SDL2-devel (fedora) package or equivalent on your distribution. Afterwards, cargo run will build and run the game.

Design

The Piston framework establishes our main game loop by generating events that our game responds two. By default, Piston generates two "update" events and one "render" event per second, in addition to player-driven input events. main.rs instantiates one of several instances of Scene to process those events; the implementation chosen dictates what part of the game the player is interacting with. Scenes define three callbacks to respond to different categories of events: The update callback advances game state over time, the render callback paints current game state to the canvas, and on_event handles all other events (such as controller input). Scenes communicate important events back to the main loop using an event bus; based on those events, the main loop changes the active Scene.

The Title and Score scenes are rudimentary, since they contain very little state or logic. Their only purpose is to navigate the player to and from the Game scene, where almost all of the game takes place.

The Game scene simulates the player, asteroids, and bullets that make up the game proper. We use Legion to manage all of the simulation, to include entity state and physics rules. Entities in the simulation are compositions of Components, each of which has associated with it a set of rules. Those rules are captured by Systems, which impose behavior on components every update step. For example, an asteroid is an entity with several components that store its position in space, what entities it can collide with, and how it collides with other entities. Every update, the different systems update all entities with appropriate components in order to move those entities through space, or figure out which ones have collided with one another.

Acknowledgements

The player ship sprite used by earlier versions of Rust Rocks is the "speedship" sprite created by MillionthVector (source) and distributed under creative-commons 4.0. The current version of Rust Rocks uses a sprite derived from speedship.

Rust Rocks uses the "Press Start 2P" font by Cody "CodeMan38" Boisclair (cody@zone38.net), distributed under the SIL Open Font License, Version 1.1. A copy of the license may be found next to the font file at resources/press-start-2p/LICENSE.txt.

About

An asteroids-like twinstick shooter written in Rust using Piston and Legion.

Topics

Resources

Stars

Watchers

Forks

Languages