# Develop a 2D Platformer in Rust
## Create and contribute to games made with Rust
## Page Count (your best estimate - allow 300 words to a page):
250
## Overview
This book is for people who are new to using the Rust Language and have an interest in game development. This book is also for people who may be intimidated by Rust and are looking for a path to enter the community. We will assume the reader has basic programming knowledge (loops, conditionals, functions, etc), familiar enough with the command line to enter commands, and an understanding of arithmetic and basic kinematic motion.
The first part of this book will be an on-going example of making a 2D platformer game with a game engine called Macroquad. We will explain step-by-step how to make a simple platformer game that covers all of the concepts that new game developers need to know. At the end of every chapter we will provide a prompt to allow the reader to take a break from the book to work on their code on their own.
The second part of the book will teach readers how they can use the knowledge in the previous part to contribute to an already existing game called Fish Fight. First we will go over some important examples from the code to give the reader an understanding of the games structure. Then, we will walkthrough an example contribution to the game where we cover the necessary steps and etiquette (git, github, issues, forking, branching, pull request, code review, etc ).
Both of us developed our knowledge of Rust primarily through game development. We both still remember many of the hurdles we encountered with Rust and game development and how we dealt with and learned from them. We can empathize with new Rust game developers and we are hoping to help them get over these many hurdles through this book.
## Outline
1. Setup
* Installing Rust
* Cargo
* Clippy
* rust-fmt
* VSCode + Extensions
* Rust Analyzer
2. Hello World
* Create a window with a title
* Draw shapes and get familiar with coordinate system
* Writing text to the screen
* Basic user input
3. Creating a character
* Drawing a sprite to the window
* Hook up user input to the sprite
* Scaling, translating, rotating
4. Creating a world
* Move the character horizontally
* Acceleration when input pressed
* Deceleration when input not pressed
* Gravity
* Make the character fall
* Acceleration in -y direction
* Collisions
* Create platform for the player to fall on
* Introduce hitboxes
* Jumping
* Allow the character to move vertically
* Give character initial velocity in the +y direction
* Gravity then applies bringing the player back down
* Add another platform that can be jumped to
5. Creating meaning
* Define the objective of the game we will be creating:
* A simple "escape room"
* Find a key and bring it to a location to trigger a "win" condition.
* Focus on hard-coding the level
* Go over spawning in some items the player can interact with
* Summary of implementation
1. Implement picking up items
2. Play a sound when player picks up key
3. Picking up the key will make it disappear from the level and update the game state where the player is currently carrying it
4. Finally, when the player (carrying the key) overlaps with a certain location on the window update the game state to "win"
6. Creating Adversity
* Enemies
* Combat
* Prefabs
7. Animation (adds some juice!)
* Idle
* Running
* Walking
* Jumping
8. Menu and UI
* Save
* Volume
9. ECS chapter
* Overview on what it is
* hecs
* Examples of refactoring parts of code to ECS
* Then provide them with fully refactored code
10. Fish Fight Case Study
* Go over selected examples from code
* Movement
* Collisions
* Navigating menus
11. Fish Fight Contribution Walkthrough
* Getting setup
* Picking a simple issue using GitHub
* Overview of forking, cloning, and committing code
* Build and run local copy of Fish Fight
* Submitting a pull request
12. Conclusion
* Other engines
* bevy
* godot
* tetra
* bracketlib
* Other projects
* theta wave
* veloren
* Physics engines
* rapier
## Bios
**Micah Tigley** is a front-end web developer who loves to tinker on open-source software projects and create exciting things with them. She also likes to learn about game development and share her experiences with others. At RustConf 2020, Micah gave a talk on her experiences learning about the Amethyst game engine - an engine written with the Rust programming language. She’s also given another talk at RustFest 2020 on her experience working on an open-source game, Theta Wave, also developed with the Amethyst engine. And just recently, Micah has been involved with the open-sourced game, Fish Fight, by providing thorough, user-friendly developer documentation.
**Carlo Supina** works at a startup where he designs and builds Tethered UAVs. He has experience in a wide variety of subjects including metalworking, 3D design, electronics, and programming. In his free time, he runs a website where he posts programming and electronics tutorials. His first taste of Rust was for a school project where he programmed a robot using embedded Rust. From there, he continued his journey into Rust through game development. Carlo created an open source game called Theta Wave with the Amethyst engine. More recently, Carlo has been contributing to Fish Fight, and creating other games with Bevy.