Skip to content

An implementation of Conway's Game of Life in Rust using the Bevy engine.

License

Notifications You must be signed in to change notification settings

Sanubir/game-of-life-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

game-of-life-rs

An implementation of Conway's Game of Life in Rust using the Bevy engine.

Game of Life

Table of contents

Requirements

Some free space

Before you start, make sure you have enough free space on your disk. The use of the Bevy engine departs this from a small "Hello, World!" program, combining that with Rust itself and all the crates that need to be compiled, it will take up over 1 GB of space just for those.

Rust toolchain

First you need to install the Rust toolchain. You can do this by following the instructions on the official website.

The recommended way to install Rust is using rustup, which comes down to running the following command in your terminal:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Bevy dependencies

For compiling Bevy, you need to install the following dependencies on Linux:

Ubuntu/Debian:

sudo apt-get install g++ pkg-config libx11-dev libasound2-dev libudev-dev libxkbcommon-x11-0

Fedora:

sudo dnf install gcc-c++ libX11-devel alsa-lib-devel systemd-devel

Bevy with Wayland

If using Wayland, you will also need to install the following:

Ubuntu/Debian:

sudo apt-get install libwayland-dev libxkbcommon-dev

Depending on your graphics card, you may have to install one of the following: vulkan-radeon, vulkan-intel, or mesa-vulkan-drivers

Fedora:

sudo dnf install wayland-devel libxkbcommon-devel

Note

If you are using a different distribution, another operating system, or have any other issues with dependencies, please refer to the Bevy setup guide.

Building and running

After fulfilling the requirements, get the source code by e.g. cloning this repository:

git clone https://github.com/Sanubir/game-of-life-rs

Change the working directory to the project's root:

cd game-of-life-rs

To run the project, simply use Cargo:

cargo run --release

The first run will take some time, as Cargo will download and compile all Bevy dependencies.

After the compilation is done, the window should pop up with the simulation running (the grid is randomized on startup).

Controls

In the simulation, you can interact with the cells using the mouse and keyboard. The controls are listed below.

  • Space - Pause/Unpause the simulation
  • Left Click - Make a cell alive
  • Right Click - Kill a cell
  • Middle Click - Toggle a cell state
  • C - Clear the grid
  • Q/ESC - Quit

Development

When playing around and making frequent changes to the code, you can use the --features bevy/dynamic_linking flag to speed up the rebuild process significantly:

cargo run --features bevy/dynamic_linking

The provided flag will compile bevy as dynamic library, preventing it from having to be statically linked each time you rebuild your project. This is a very impactful time decrease when doing frequent changes, but it will increase the initial compilation time.

Warning

It will also increase the compiled crates size to almost 5GB!

License

This project is licensed under the GPL-3.0 license. See the LICENSE file for more information.

About

An implementation of Conway's Game of Life in Rust using the Bevy engine.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages