Giter VIP home page Giter VIP logo

rust-rocks's Introduction

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 ([email protected]), 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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.