diff --git a/README.md b/README.md index 4cfba98..43efacb 100644 --- a/README.md +++ b/README.md @@ -1,48 +1,47 @@ # Pac-Man -[![Tests Status][badge-test]][test] [![Build Status][badge-build]][build] [![If you're seeing this, Coveralls.io is broken again and it's not my fault.][badge-coverage]][coverage] [![Online Demo][badge-online-demo]][demo] [![Last Commit][badge-last-commit]][commits] +[![Tests Status][badge-test]][test] [![A project just for fun, no really!][badge-justforfunnoreally]][justforfunnoreally] [![Build Status][badge-build]][build] [![If you're seeing this, Coveralls.io is broken again and it's not my fault.][badge-coverage]][coverage] [![Online Demo][badge-online-demo]][demo] [![Last Commit][badge-last-commit]][commits] +[badge-justforfunnoreally]: https://img.shields.io/badge/justforfunnoreally-dev-9ff [badge-test]: https://github.com/Xevion/Pac-Man/actions/workflows/tests.yaml/badge.svg [badge-build]: https://github.com/Xevion/Pac-Man/actions/workflows/build.yaml/badge.svg [badge-coverage]: https://coveralls.io/repos/github/Xevion/Pac-Man/badge.svg?branch=master -[badge-demo]: https://img.shields.io/github/deployments/Xevion/Pac-Man/github-pages?label=GitHub%20Pages [badge-online-demo]: https://img.shields.io/badge/GitHub%20Pages-Demo-brightgreen [badge-last-commit]: https://img.shields.io/github/last-commit/Xevion/Pac-Man +[justforfunnoreally]: https://justforfunnoreally.dev [build]: https://github.com/Xevion/Pac-Man/actions/workflows/build.yaml [test]: https://github.com/Xevion/Pac-Man/actions/workflows/tests.yaml [coverage]: https://coveralls.io/github/Xevion/Pac-Man?branch=master [demo]: https://xevion.github.io/Pac-Man/ [commits]: https://github.com/Xevion/Pac-Man/commits/master -A faithful recreation of the classic Pac-Man arcade game written in Rust. This project aims to replicate the original game's mechanics, graphics, sound, and behavior as accurately as possible while providing modern development features like cross-platform compatibility and WebAssembly support. +A faithful recreation of the classic Pac-Man arcade game, written in Rust. + +This project aims to replicate the original game's mechanics, graphics, sound, and behavior as accurately as possible while providing modern development features like cross-platform compatibility and WebAssembly support. The game includes all the original features you'd expect from Pac-Man: -- [x] Classic maze navigation and dot collection +- [x] Classic maze navigation with tunnels and dot collection - [ ] Four ghosts with their unique AI behaviors (Blinky, Pinky, Inky, and Clyde) -- [ ] Power pellets that allow Pac-Man to eat ghosts +- [x] Power pellets that allow Pac-Man to eat ghosts - [ ] Fruit bonuses that appear periodically - [ ] Progressive difficulty with faster ghosts and shorter power pellet duration - [x] Authentic sound effects and sprites -This cross-platform implementation is built with SDL2 for graphics, audio, and input handling. It can run on Windows, Linux, macOS, and in web browsers via WebAssembly. +This cross-platform implementation is built with SDL2 for graphics, audio, and input handling. It can run on Windows, Linux, macOS, even web browsers via WebAssembly. ## Why? -Just because. And because I wanted to learn more about Rust, inter-operability with C, and compiling to WebAssembly. +[Just for fun.][justforfunnoreally] And because I wanted to learn more about Rust, inter-operability with C, and compiling to WebAssembly. -I was inspired by a certain code review video on YouTube; [SOME UNIQUE C++ CODE // Pacman Clone Code Review](https://www.youtube.com/watch?v=OKs_JewEeOo) by The Cherno. +Originally, I was inspired by a certain code review video on YouTube; [SOME UNIQUE C++ CODE // Pacman Clone Code Review](https://www.youtube.com/watch?v=OKs_JewEeOo). For some reason, I was inspired to try and replicate it in Rust, and it was uniquely challenging. It's not easy to integrate SDL2 with Rust, and even harder to get it working with Emscripten. -For some reason, I was inspired to try and replicate it in Rust, and it was uniquely challenging. +I wanted to hit a lot of goals and features, making it a 'perfect' project that I could be proud of. -I wanted to hit a log of goals and features, making it a 'perfect' project that I could be proud of. - -- Near-perfect replication of logic, scoring, graphics, sound, and behaviors. No hacks, workarounds, or poor designs. -- Written in Rust, buildable on Windows, Linux, Mac and WebAssembly. Statically linked, no runtime dependencies. +- Near-perfect replication of logic, scoring, graphics, sound, and behaviors. No hacks, workarounds, or poor designs. Well documented, well-tested, and maintainable. +- Written in Rust, buildable on Windows, Linux, Mac and WebAssembly. Statically linked, no runtime dependencies, automatically built with GitHub Actions. - Performant, low memory, CPU and GPU usage. -- Online demo, playable in a browser. -- Completely automatic build system with releases for all platforms. -- Well documented, well-tested, and maintainable. +- Online demo, playable in a browser, built automatically with GitHub Actions. ## Experimental Ideas @@ -72,9 +71,10 @@ I wanted to hit a log of goals and features, making it a 'perfect' project that Since this project is still in progress, I'm only going to cover non-obvious build details. By reading the code, build scripts, and copying the online build workflows, you should be able to replicate the build process. +- Install `cargo-vcpkg` with `cargo install cargo-vcpkg`, then run `cargo vcpkg build` to build the requisite dependencies via vcpkg. + - This is only required for the desktop builds, not the web build. - We use rustc 1.86.0 for the build, due to bulk-memory-opt related issues on wasm32-unknown-emscripten. - Technically, we could probably use stable or even nightly on desktop targets, but using different versions for different targets is a pain, mainly because of clippy warnings changing between versions. -- Install `cargo-vcpkg` with `cargo install cargo-vcpkg`, then run `cargo vcpkg build` to build the requisite dependencies via vcpkg. - For the WASM build, you need to have the Emscripten SDK cloned; you can do so with `git clone https://github.com/emscripten-core/emsdk.git` - The first time you clone, you'll need to install the appropriate SDK version with `./emsdk install 3.1.43` and then activate it with `./emsdk activate 3.1.43`. On Windows, use `./emsdk/emsdk.ps1` instead. - I'm still not sure _why_ 3.1.43 is required, but it is. Perhaps in the future I will attempt to use a more modern version. diff --git a/STORY.md b/STORY.md index bb8a17a..94c29b1 100644 --- a/STORY.md +++ b/STORY.md @@ -31,7 +31,7 @@ WebAssembly. The problem is that much of this work was done for pure-Rust applications - and SDL is C++. This requires a C++ WebAssembly compiler such as Emscripten; and it's a pain to get working. -Luckily though, someone else has done this before, and they fully documented it - [RuggRouge][ruggrouge]. +Luckily though, someone else has done this before, and they fully documented it - [RuggRouge][ruggrogue]. - Built with Rust - Uses SDL2 @@ -92,7 +92,7 @@ This was weird, and honestly, I'm confused as to why the 2-year old sample code After a bit of time, I noted that the `Instant` times were printing with only the whole seconds changing, and the nanoseconds were always 0. -``` +```rust Instant { tv_sec: 0, tv_nsec: 0 } Instant { tv_sec: 1, tv_nsec: 0 } Instant { tv_sec: 2, tv_nsec: 0 } @@ -357,7 +357,7 @@ Doing so required a full re-work of the animation and texture system, and I ende So, I ended up using `unsafe` to forcibly cast the lifetimes to `'static`, which was a bit of a gamble, but given that they essentially behave as `'static` in practice, there wasn't much risk as I see it. I might re-look into my understanding of lifetimes and this in the future, but for the time being, it's a good solution that makes the codebase far easier to work with. -## Cross-platform Builds +## Implementing Cross-platform Builds for Pac-Man Since the original `rust-sdl2-emscripten` demo project had cross-platform builds, I was ready to get it working for this project. For the most part, it wasn't hard, things tended to click into place, but unfortunately, the `emscripten` os target and somehow, the `linux` os target were both failing.