by otikik · 6y ago · 0 comments
In addition to the (very good!) tutorial on the OP by Tomas Sedovic, I wanted to mention the rust roguelike tutorial by Herbert Wolverson / The Bracket:
http://bfnightly.bracketproductions.com/rustbook/
The main difference is that on this case they use rltk_rs, a pure-rust library for roguelike development, instead of libtcod. It is also way, way longer.
I don't know how/if Hervert has even attempted at solving the issues mentioned by Tomas with regards to repetition / code generation and literate programming.
In addition to it being a pure Rust library (which does make a difference when you get started, but also when you try to distribute your game) it compiles to WebAssembly as well meaning you can use the same code to produce a game that runs on the desktop and the web. And the tutorial covers much more ground as well, including ECS for those interested.
And finally, both the tutorial and tcod-rs are barely maintained anymore. I try to address questions/fix serious issues from time to time, but the chances of this seeing any significant developments in the future are very slim. The RLTK stuff is actively maintained and developed.
(I'm not the OP, but I did write the linked post, the tutorial -- which is based on the classic Python+libtcod one as well as started tcod-rs)
&s.to_string()
which is an expression that could be shortened to just s. (Specifically, s has type &str, calling to_string() on it converts it to a String, and borrowing it allows it to be coerced back to a &str but now with unnecessary copying.) Elsewhere (this from Chapter 3) it has explanations like> Copy and Clone allow this [type] to be used as a "value" type (that is, it just passes around the value instead of pointers)
which is also not a correct explanation, or at least is a misleading one: things can still be passed by value even without Copy and Clone and without any pointers at all. (Arguably, he meant, "You can share the value without using borrows," but that's not what the explanation said.)
That said, all this is nitpicky (and I suspect that Herbert would be receptive to feedback along these lines—I just haven't had a chance yet to provide it!) because the tutorial's explanation of roguelike-writing is still very good, and in fact I've been following it as a guide for writing a tutorial on top of a different Rust library myself! But I do want to warn about using it as a model for learning Rust specifically.