Home rust-game Classwork TV production Tech Skills Projects

Allen MacFarland's Website

Capstone proposal

FOSS Video Game to Spur the Adoption of Rust

Allen MacFarland

Fossil Ridge STEM Academy

12/16/2021


Table of contents

Table of contents        2

Executive summary        3

Statement of problem        4

The problem:        4

Background:        5

Explanation:        6

Technical approach        7

Prerequisites:        7

Learning:        7

Design criteria:        7

Testing:        8

Sustainability:        8

Project management        9

Deliverables        11

Budget        12

Team qualifications        13

References        14


Executive summary

        If this proposal is accepted, a FOSS (free as in freedom) video game will be developed using Rust and rg3d which will help adoption of the Rust programming language. Rust is the language of the future because of its speed and memory security, and only needs a few projects to adopt it to start a virtuous cycle of Rust adoption.

        This project won’t require any budget, but it will require a few programmers and a graphic designer/programmer. None of these people need to be particularly experienced in programming, as we plan to spend the first 2 months learning Rust.

        We have a very flexible timeline, so it will be easy to fit our project to the time allotted.


Statement of problem

The problem:

        Rust is an object-oriented programming language developed as the spiritual successor to C and C++. Compared to languages like Java and Python, it is much faster, as it has the same very fast bare metal performance as C and C++. Compared to C and C++, it is more memory safe due to its ownership system and has various small conveniences because it’s not 35+ years old. (Dreimanis, 2020)

        In Rust, variables are immutable by default. This means they replace the code they are used in during compilation, which allows for easy modifications and low memory usage. For example, if you write:

  1. fn main() {
  2.   let x = 5;
  3.   println!("{}", x)
  4. }

The compiler turns it into:

  1. fn main() {
  2.   println!("{}", 5)
  3. }

But in something like:

  1. fn main() {
  2.   let mut x = 5;
  3.   println!("{}", x);
  4.   x = x + 3;
  5.   println!("{}", x);
  6. }

Rust keeps the variable in memory because it is set to be mutable and changes.

        Rust has memory safety because it ties deletion of variables to their owner in an ownership system. A variable is deleted when the compiler detects that it’s owner is no longer going to be called. For example:

  1. fn main() {  // s does not exist here here, it’s not yet declared
  2.         let s = "hello";  // s exists from this point forward
  3.         // do stuff with s
  4. }  // s is no longer going to be used, so the compiler deletes it

This avoids the need to manually delete “s” like in C or C++, which avoids memory leaks, but it also avoids a performance-intensive garbage collection program that uses complicated procedures to decide when it can get rid of a variable in memory, like in Python. This system is called ownership, because all properties of “s” are deleted with “s”. (Klabnik, Nichols, n.d.)

Rust can also integrate somewhat painlessly with C or C++ libraries, making it their ideal successor. Unfortunately, Rust has seen very little adoption due to a vicious cycle of low Rust adoption leading to nobody wanting to be an early adopter leading to low Rust adoption. Rust needs more projects to demonstrate how powerful it is.

Background:

        gfx-rs is a Rust library used to render GPU-accelerated 3D spaces onto a 2D screen with Vulcan, DirectX, Metal, or OpenGL (geertbleyen, 2021). Code written without a library like this will render using the CPU, which is very inefficient, and will not produce anywhere near the performance required for a game.

        rg3d is a 3D fully featured game development engine written for Rust. It makes gfx-rs much more user-friendly by abstracting further from gfx-rx. (rg3d, n.d.) It will be used for this project. gfx-rs would be better for this project, but we’re time limited, so we’ll use rg3d.

Explanation:

My project, making a game in Rust, will demonstrate the viability of the programming language, which will help transition the world to Rust, which will finally eliminate memory leaks and improve performance.

It will probably be a first person shooter game, however, this may change based on my team’s taste in video games.

GitHub will be used so that group members can work on the project at the same time. GitHub allows users to upload all of the changes they made to their code at once and release history. It also encourages splitting work into multiple files, which is necessary for collaboration.

The first 2 months of the project will be dedicated to teaching all group members how to use Rust and rg3d because these are very complicated.


Technical approach

Prerequisites:

We will need Rust(cargo), an IDE that supports Rust, and Blender. Group members can pick their own IDE based on personal taste. All of these are FOSS, so getting school permission to install these on school computers should be easy. Blender is already available on school computers.

        We will need access to computers in the computer lab because school-issued laptops have very slow compilation times. This project can, however, be worked on at home on computers with more powerful CPUs.

        We will try and find a Rust mentor at CSU. A list of potential mentors can be found here. Alternatively, we might try and ask one of the guys at System76 in Denver who make the Linux distro Pop_OS!, and are working on the new Rust-based Linux DE to mentor us. We can ask our mentor or figure out any problems that we might encounter.

Learning:

        The first 2 months of our project will be dedicated to everyone learning Rust. Rust is a complicated language with many quirks that require experience to navigate around. The most efficient way to learn to code is to write lots of code with only official documentation, even when most of it doesn’t work, so that’s what we’ll do for the first 2 months.


Design criteria:

This game should:

Testing:

        The majority of testing can be done by group members by compiling and running the program on their own machines. If there is time remaining, we will ask people in other groups to test our game and give feedback. Feedback will be judged on how easy it is to implement and potentially implemented into our code.

Sustainability:

        One of the advantages of a computer program is that it doesn’t take up space, and one of the advantages of Rust is that it doesn’t usually break things. Therefore future groups can continue to use it. Additionally, having a video game on the STEM Academy website would be a great way to convince prospective students to join the STEM Academy.


Project management

Figure 1: Our project has a flexible timeline that allows us to easily increase or decrease the scope depending on how fast we finish our code.

We will split our code into many files so that each file can be worked on individually via GitHub. Each task will be completed at roughly the same time, and nobody is assigned to anything specific. Members will work on whatever files make the most sense to them.

This project has 3 major milestones that come before the first flag where we will decide how to continue our project:

  1. All team members have a decent understanding of Rust. It’s very difficult to expand or troubleshoot code you don’t understand, so this won’t be done in parallel. (6-8 weeks)
  1. We will first make a simple command line program to solve a math problem (½ week)
  2. We will then use a basic library like Qt to learn how to use libraries in rust (2 weeks)
  3. We will then use rg3d to make a simple scene to render with a camera that moves (4 weeks)
  1. A basic movement system will be developed along a flat plane. (2 weeks, done in parallel)
  1. The player should be able to move with WASD, jump with space, and look around with the mouse.
  2. A flat plane should be drawn to allow the player to walk on top of
  3. Shooting shouldn’t have an animation yet, but a bullet should be fired in the center of the screen by clicking with the mouse.
  1. A full level should be developed (2 weeks, done in parallel)
  1. Enemies should fire at the player
  2. Enemies should be able to kill the player if the player is shot too many times.
  3. Enemies should die upon being shot.
  4. There should be places the player must jump on to complete the level
  5. Basic animations for most actions should be in place

Deliverables

        A Rust-based cross-platform Vulcan FOSS game and it’s source code will be delivered. The game will be a demonstration of the benefits of developing games in Rust which can spur the adoption of Rust for gaming.

User testing results for this game will be delivered alongside the game.


Budget

        This project will not require any budget because FRHS has computers, and that’s all we need.

Cost

Name

Description

$0

Computers

1 computer will be needed for each group member, however these are already in the tech lab.

$0

Rust

Rust is open-source and free as in freedom

$0

Pycharm IDE

Pycharm has an open source version that is free as in freedom


Team qualifications

        Team qualifications are very flexible, as we will have 2 months to learn any necessary skills. Not all slots need to be filled, and more programmers would lead to a higher quality product

Role

Qualifications

Programmer / Graphics designer

  • Some knowledge of some programming language,
  • Some knowledge of a 3D modeling software like Blender.
  • Being interested in this project!

Programmer

  • Decent knowledge of a programming language, preferably, but not necessarily, Rust
  • Being interested in this project!

Programmer

  • Decent knowledge of a programming language, preferably, but not necessarily, Rust
  • Being interested in this project!

Programmer

  • Decent knowledge of a programming language, preferably, but not necessarily, Rust
  • Being interested in this project!


References

geertbleyen (n.d.), gfx-rs. GitHub repository. Retrieved Dec 14, 2021, from https://github.com/gfx-rs/gfx 

Gints Dreimanis (2020, August 19), Introduction to Rust. Serokell. Retrieved Dec 14, 2021, from https://serokell.io/blog/rust-guide 

rg3d (n.d.), rg3d Cheat/Guide Book. rg3d contributors. Retrieved Dec 14, 2021, from https://rg3d-book.github.io/introduction.html 

Steve Klabnik and Carol Nichols (n.d.), The Rust Programming Language. Retrieved Dec 14, 2021, from https://doc.rust-lang.org/book/