Rust - Tic Tac Toe
~/ ../
About
Having read about Rust for a while now; “memory safety features”, “near machine performance”, “compile time checks”, and “strong types” are common praise. Those are great, and definitely drew me to Rust, but there are some simple comforts as well:
- Toolchain Manager: rustup makes it easy to switch between compiler versions (stable, nightly, and cross compilers).
- Package Manager: Cargo is the official Rust package manager.
- Testing: “cargo test” run tests and eventually benchmarks.
- Code Formatting: “cargo fmt”
- Doc Generation: “cargo doc”
There is something to be said for having an obvious place to start, out of the box. Being brand new to Rust, it was nice to skip some side-quests and get to work.
Why Tic Tac Toe?
My son is learning to enjoy problem solving and using technology. What better way to encourage this than building a game and changing it to his preference? Keeping it simple allowed us to create something quickly and not get bored.
Cross Platform
Tic Tac Toe runs on Windows, Linux, x86_64, ARMv8, and OpenPOWER (ppc64le). Using the Piston game engine, which relies on SDL2 bindings for Rust, made this pretty straight forward.
Source Code
gitlab.com/nashimus/tic-tac-toe
Bug Hunting
I reported a bug in Piston/graphics. When drawing an arc 2*PI or 6.28 radians long, the circle dissappeared. As a work around, subtracting 0.00001 from the angle resulted in the circle being visible.
Sven was super nice and very quick to resolve the issue.
Gameplay Video
Assets
Thanks to OpenGameArt.org, we didn’t have to create our own audio assets:
- Music::BackgroundMusic
- Sound::WinGame sfx_sounds_powerup3.wav
- Sound::LoseGame sfx_sounds_negative1.wav
- Sound::Stalemate sfx_deathscream_human5.wav
- Sound::Click sfx_coin_single3.wav
Conclusion
I have barely scratched the surface of Rust, but have found it easy to get started and it was a joy building this with my son. He enjoyed choosing the sounds, music, and colors. Most importantly, he enjoys playing the game he helped create.
Created: