Skip to content

Latest commit

 

History

History
45 lines (28 loc) · 1.67 KB

README.md

File metadata and controls

45 lines (28 loc) · 1.67 KB

In an effort to teach myself Rust I've decided to follow along with the excellent youtube playlist reconstructing cavestory.

This project uses rust-sdl2 which binds to SDL2.

Build Status

Building w/ Cargo

This project uses Cargo to fetch dependencies and drive compilation. Make sure you have a recent version of rustc and cargo.

To build simply run: cargo build from the root of the project.

The project is structured as follows:

-- assets/ 	(assets linked to in the youtube playlist notes)
-- src/ 	(.rs files used to build the game)

For the most part this program reads much like it's C++ and C++11 counterparts.

  • Traits are used instead of extending abstract classes.

    • These are similar to interfaces in Go, Java, etc.
  • Pattern matching is leveraged where appropriate

    • For a fun head-scratcher: look at Player::load_sprite()
      • The rust compiler requires exhaustive patterns, so:
      • For every combination of (Movement, Looking, Facing) load_sprite() must return some sprite.
      • (Obviously the compiler cannot guarantee that we load the correct sprite.)
  • Reference counting is used for safely sharing pointers.


Some areas that could be improved:

  • Needless copying and allocation, espcially w.r.t using strings for map keys.
  • Remove unnecessary boxes
  • Re-evaluate usages of trait objects