Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/johnthagen/rust-belt

:rocket: Asteroids-like arcade game implemented in Rust ✨
https://github.com/johnthagen/rust-belt

arcade-game graphics opengl piston rust video-game

Last synced: 3 days ago
JSON representation

:rocket: Asteroids-like arcade game implemented in Rust ✨

Awesome Lists containing this project

README

        

![Rust Belt](./assets/images/rust-belt-logo.png)

[![GitHub Actions][github-actions-badge]](https://github.com/johnthagen/rust-belt/actions)
[![GitHub Releases][github-release-svg]][github-release]

`rust-belt` is a 2D video game inspired by the classic
[Asteroids](https://en.wikipedia.org/wiki/Asteroids_(video_game)) arcade game,
featuring an [original soundtrack :musical_score:](assets/music). It is implemented using the
[Rust](https://www.rust-lang.org/) game engine, [Piston](https://www.piston.rs/).

![Rust Belt](./videos/rust-belt-game-play.gif)

# Requirements

## Prerequisites

1. The latest stable release of Rust.
1. Install [`rustup`](https://www.rust-lang.org/install.html).

2. `rust-belt` uses [`piston-music`](https://github.com/PistonDevelopers/music) to play music.
`piston-music` depends on two third-party non-Rust libraries, [SDL2](https://www.libsdl.org/)
and [SDL2_mixer](https://github.com/libsdl-org/SDL_mixer). Install instructions are provided
below.

## Windows

Select to proceed with either the MSVC or GNU toolchain.

### MSVC (Recommended)

1. Ensure you are using the latest stable 64-bit MVSC toolchain with `rustup show`
(`stable-x86_64-pc-windows-msvc`).
2. Ensure you have installed the [Build Tools for Visual Studio](https://aka.ms/buildtools)
as instructed by `rustup` during install.
3. [Download](https://github.com/libsdl-org/SDL/releases) the latest 2.0.x SDL2 MSVC development
library (`SDL2-devel-2.0.x-VC.zip`).
4. Unpack and copy all `.lib` files from `SDL2-devel-2.0.x-VC\SDL2-2.0.x\lib\x64\` into a folder.
If the `LIB` system environment variable does not exist, create it. Add that folder path to
`LIB`.
5. Copy `SDL2.dll` into the `rust-belt` project folder, next to `Cargo.toml`.
6. [Download](https://www.libsdl.org/projects/SDL_mixer/release/) the latest 2.0.x SDL2_mixer MSVC
development library (`SDL2_mixer-devel-2.0.x-VC.zip`).
7. Unpack and copy all `.lib` files from `SDL2_mixer-devel-2.0.x-VC\SDL2_mixer-2.0.x\lib\x64` into
the same folder added in step 4 that was added to the `LIB` system environment variable.
8. Copy `SDL2_mixer.dll` and `libmpg123-0.dll` into the `rust-belt` project folder, next to
`Cargo.toml`.

### GNU/MinGW-w64

1. Ensure you using the latest stable 64-bit GNU ABI toolchain with `rustup show`
(`stable-x86_64-pc-windows-gnu`).
2. Install [MSYS2](https://www.msys2.org/).
3. In an MSYS2 terminal: `pacman --sync mingw-w64-x86_64-gcc`
4. Add `C:\msys64\mingw64\bin` to system `PATH`.
5. [Download](https://github.com/libsdl-org/SDL/releases) the latest 2.0.x SDL2 MinGW development
library (`SDL2-devel-2.0.x-mingw.tar.gz`).
6. Unpack and copy all `.lib` files from `SDL2-devel-2.0.x-mingw\SDL2-2.0.x\x86_64-w64-mingw32\lib`
into a folder. If the `LIBRARY_PATH` system environment variable does not exist, create it. Add
that folder to `LIBRARY_PATH`.
7. Copy `SDL2.dll` into the `rust-belt` project folder, next to `Cargo.toml`.
8. [Download](https://www.libsdl.org/projects/SDL_mixer/release/) the latest 2.0.x SDL2_mixer MinGW
development library (`SDL2_mixer-devel-2.0.x-mingw.tar.gz`).
9. Unpack and copy all `.lib` files from
`SDL2_mixer-devel-2.0.x-mingw\SDL2_mixer-2.0.x\x86_64-w64-mingw32\lib\` into the same folder
added in step 6 that was added to the `LIB` system environment variable.
10. Copy `SDL2_mixer.dll` and `libmpg123-0.dll` into the `rust-belt` project folder, next to
`Cargo.toml`.

## Mac OSX

1. Install [Homebrew](https://brew.sh/) (by default this will install `gcc` via Xcode development
tools).
2. `brew install sdl2`
3. `brew install sdl2_mixer --with-flac --with-fluid-synth --with-libmikmod --with-mpg123`

## Ubuntu

1. `sudo apt install libsdl2-dev libsdl2-mixer-dev`

## Build and Run

To build:

```bash
$ cargo build
```

To run:

```bash
$ cargo run --release
```

## How to Play

Keyboard | Menu | Game
---------------- | ----------- | -------------------
W | Up | Accelerate Forward
S | Down | Accelerate Backward
A | | Rotate left
D | | Rotate right
Space | Select | Shoot
X | | Return to Menu
Esc | Exit | Exit

# Maintainers

* [@johnthagen](https://github.com/johnthagen)
* [@mcdenhoed](https://github.com/mcdenhoed)

Special thanks to [@aochagavia](https://github.com/aochagavia) for
[rocket](https://github.com/aochagavia/rocket), which provided many examples to pull from.

## Music

Music composed by [@johnthagen](https://github.com/johnthagen). All rights reserved.

Sound from [freesound.org](https://www.freesound.org/).

[github-actions-badge]: https://github.com/johnthagen/rust-belt/workflows/build/badge.svg

[github-release]: https://github.com/johnthagen/rust-belt/releases
[github-release-svg]: https://img.shields.io/github/release/johnthagen/rust-belt.svg