I'm thrilled to announce that I've written an introductory book about Rust, and it's now in print: Hands-on Rust: Effective Learning through 2D Game Development and Play. It's available in full-color paperback and e-book from The Pragmatic Publisher, worldwide online book distributors, and your local bookseller (ask for ISBN 978-1680508161).
You can browse the source code in this github repo.
I truly started to love Rust when I created the Rust Roguelike Tutorial. I'd used a lot of languages in the past, my most recent being C++ ---and Rust felt like the power of C++ combined with clever systems to make it harder to shoot my feet off. Ever since I started writing BASIC in the 1980s (on a BBC Micro), I've found that writing small games is the best way for me to learn. As much as I try, I just can't digest a big manual and start being productive---programming really gels for me when I try and make something, frequently referring to the manual and online groups. Rust is nicely documented, and the community is awesome. I quickly found I could get stuck, ask for help, and people appeared with PRs fixing my issue AND explaining where I became confused.
Hands-on Rust is my attempt to share my preferred way to learn a language, so it teaches game development carefully intertwined with Rust concepts and practical examples that use them. Targeted at readers who have a little experience with other languages (enough to understand variables and basic control flow), it starts at the beginning with Rust and brings the reader up to intermediate concepts. It's deliberately pragmatic in its approach: it teaches concepts as part of working examples (source code is provided for most steps along the way), inviting you to follow along and learn the concepts by using them.
There is a little overlap with the Roguelike Tutorial, but Hands-on Rust is 100% new code and work. The tutorial is designed to make a good roguelike; the book is designed to teach Rust.
Hands-on Rust starts out helping you to install the Rust toolchain, teaching Cargo, Clippy and basic development workflow. Then it dives into some console-based examples designed to teach control flow, variable management and basic IO. That's enough to make your first game, so we dive straight into making Flappy Dragon---a Flappy Bird clone. It starts out in ASCII mode, gradually adding features in a step-by-step hands-on fashion.
Then the book starts on its big example, a roguelike-style dungeon crawler. You'll cover:
- Writing a design document.
- Organizing your code and making a simple map to walk around---with graphics.
- Getting started with ECS (it uses Legion), and composing entities from components.
- Understanding control flow and state management by making the game turn-based.
- Add health and simple combat, solidifying your understanding of systems and introducing traits.
- Implement end-game states (winning and losing).
- Add field-of-view support, which is really teaching you how to consume traits.
- Utilize various procedural generation techniques to build your maps, while learning to wrap your generators in your own traits.
- Theming your map, which is a bit about graphics, and also about solidifying your understanding of traits.
- Add inventory and power-ups, showing you one approach to inventory management in an ECS.
- Design multi-level dungeons, with stairs.
- Add data-driven design to your game, defining your games' entities in TOML and learning to use Serde to read and process it.
- Finishing touches including packaging your game.
Not everything I wanted to cram into the book made it, due to page constraints (publishers don't like it when you hand in a War and Peace size tome), so expect some additional content to appear on hands-on-rust.com.
One question that comes up a lot: there is some overlap between the book and the Roguelike Tutorial. The book is 100% new content, but since they both deal with a roguelike game---some overlap is inevitable. The tutorial is focused on making a roguelike, while the book is all about teaching Rust, and making the learning process fun.
Thanks for being such a wonderful community; the friendly, inclusive nature of the Rust community really made getting into Rust fun and easy.