Game Development with Rust and WebAssembly, published by Packt
This is the code repository for Game Development with Rust and WebAssembly, published by Packt.
Learn how to run Rust on the web while building a game
The Rust programming language has held the most-loved technology ranking on Stack Overflow for 6 years running, while JavaScript has been the most-used programming language for 9 years straight as it runs on every web browser. Now, thanks to WebAssembly (or Wasm), you can use the language you love on the platform that's everywhere.
This book covers the following exciting features:
If you feel this book is for you, get your copy today!
<img src="https://raw.githubusercontent.com/PacktPublishing/GitHub/master/GitHub.png" alt="https://www.packtpub.com/" border="5" />
You're currently looking the main branch of this repository, which represents the "completed" state of this book. I say completed because development on this branch is ongoing - specifically the challenges cited in the book are being implemented here. If you want to see the end state of any chapter those are stored as tags, such as https://github.com/PacktPublishing/Game-Development-with-Rust-and-WebAssembly/tree/chapter_1.
Following is what you need for this book:
This game development book is for developers interested in Rust who want to create and deploy 2D games to the web. Game developers looking to build a game on the web platform using WebAssembly without C++ programming or web developers who want to explore WebAssembly along with JavaScript web will also find this book useful. The book will also help Rust developers who want to move from the server side to the client side by familiarizing them with the WebAssembly toolchain. Basic knowledge of Rust programming is assumed.
With the following software and hardware list you can run all code files present in the book (Chapter 1-11).
Chapter | Software required | version | OS required |
---|---|---|---|
(1 - 11) | Rust Toolchains via Rustup | 1.57.0 | Any OS |
(1 - 11) | NodeJS | 16.13.0 | Any OS |
(1 - 11) | Rust Compile target wasm32-unknown-unknown | NA | NA |
I use https://asdf-vm.com to install Node and a .tool-versions file is present but you don't have to. Instructions for creating a new project are found in the book (chapter 1) but the project can also be setup by cloning this repository and running the commands for building and running. Speaking of that:
npm install
Will install the Node dependencies (primarily WebPack). Don't worry you don't have to think about those much.
npm start
Will compile the application to Wasm and start a server, running it at localhost:8080 by default. This will also ensure wasm-pack
is setup and running and run cargo build
.
npm run build
Creates a release build and puts it in the dist
directory.
npm run test
You can use a lot of the cargo
commands as well - but those do not go through the process of bundling up the built assembly for distribution.
This branch is setup for continuous deployment with GitHub Actions, as is the tag for chapter_10. Something to keep in mind when forking the repository. The current production version of this game can be found at:
https://rust-games-webassembly.netlify.app
At the end of the book (Further Resources and What's Next?) there are six challenges for you, the reader. I'll be completing them on and off my stream, and making a note here when they are complete.
Challenge #6:
We also provide a PDF file that has color images of the screenshots/diagrams used in this book. Click here to download it.
The Code in Action videos for this book can be viewed at https://bit.ly/3uxXl4W.
Eric Smith is a software crafter with over 20 years of software development experience. Since 2005, he's worked at 8th Light, where he consults for companies big and small by delivering software, mentoring developers, and coaching teams. He's a frequent speaker at conferences speaking on topics such as educating developers and test-driven development, and holds a master's degree in video game development from DePaul University. Eric wrote much of the code for this book live on his Twitch stream. When he's not at the computer, you can find Eric running obstacle races and traveling with his family.
If you have already purchased a print or Kindle version of this book, you can get a DRM-free PDF version at no cost.
Simply click on the link to claim your free PDF.