Roguelike Tutorial: Up-to-Date and Literate
aimlesslygoingforward.com
aimlesslygoingforward.com
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.
Also I'd recommend the subreddit[1] to anyone interested.
[0]http://www.roguebasin.com/index.php?title=Complete_Roguelike...
> High Fantasy is the vanilla ice cream of video game themes
https://www.goldenkronehotel.com/wp/2018/08/01/things-i-hate...
> We have lots and lots of fantasy dungeon crawlers, so naturally if you want to really distinguish your project, go for any unique theme that’s not a fantasy dungeon crawler.
https://www.gridsagegames.com/blog/2018/10/how-to-make-a-rog...
https://www.gridsagegames.com/blog/gsg-content/uploads/2018/...
I know what you mean to say but good fantasy tries as hard to be "realistic" (in terms of plausibility and internal consistency) as good science fiction.
Although in terms of providing recognizable game mechanics that resonate with a genre, fantasy is definitely easier thanks to the influence of D&D.
This is also where most of the core mechanics come from -- dungeoneering, permadeath, the lack of interest in keeping your character alive & the lack of interest in things like backstory and what-not, the general weapon mechanics (eg [+1, +2] for accuracy, damage bonus) and combat rules, etc.
In this context, anything but fantasy would be surprising
If this is the reaction to the theme in the Rust tutorial that the original post talks about, that's because it's basically a port of the classic Python+libtcod one. It implements the same game, but walks the reader through doing it in Rust.
I (not OP but the author of the article and the Rust tut) wanted to use the same game & structure so folks can compare and contrast. A lot of folks are coming from Python or are familiar with libtcod. Plus it's trained generations of RL devs for better or worse.
If you do want to see roguelike creators experimenting, check out the annual Seven Day Roguelike Challenge[1]. Lots of absolutely amazing stuff keeps coming out of that, including most of my favourites.
[1]: http://www.roguebasin.com/index.php?title=Seven_Day_Roguelik...
http://tomassedovic.github.io/roguelike-tutorial/
https://github.com/tomassedovic/roguelike-tutorial
There are no official builds you can download since this is something you're supposed to read and follow along, building your own game in the process.
I have made my own "proper" roguelike (moved away from libtocd, but kept Rust) but that was unrelated to the post.
(I'm the author of the article, but not the OP)
> the workflow could be better. In the example above, we had to define the function body, prelude, if statement, else statement and both if/else blocks.
> It would be much better if we could inverse this: defining the whole function block with holes for the if/else blocks that the code generation would put in.
The original CWEB and newer NOWEB do handle these things a bit better - sections can be defined and included in any order, and sections can define which file their in.
It lends itself particularly well to laying out a program "top down", ie:
We define the utility ctof as consisting of a c file: ctof.c.
It has the following structure:
standard header includes
defining constants for conversion
defining the function ctof that converts a float value of degrees Celsius to Fahrenheit, returning a float
A help procedure that prints help
A main function that parses command line parameters, and conditionally call the help procedure or ctof function... Etc
Then can go on to define the inner bit of ctof first (the calculation).
In general literate programming is very nice. It can be a bit of a challenge when breaking out small sections (we define a loop that iterates over an array like so...) - because of scoping issues - if the programming language discourages many small (max 10 lines) functions/procedures.
At that point the literate system itself takes on the role of a macro assembler of sorts - which can work with old school "structured programming" - short programs, well defined global state (a few array/lists, a few "in" and "out" global variables).
See eg: http://literateprogramming.com/cweb_download.html (historic relevance)
http://leoeditor.com/ (not sure if it's alive - an interesting idea in "all literate, all the time"
https://www.cs.tufts.edu/~nr/noweb/ modern-ish take on literate programming - if you want LaTeX for the document part
Finally, the most pragmatic variant I'm aware of - literate markdown tangle - which might be close enough to what's in op to encourage a port:
The Markdown one seems interesting too.
I'll probably stick with this for stuff where there's some expectation of drive-by contributions (the tutorial has seen a bunch, it was one of the motivations behind this) because requiring additional tooling can often be a bar that's too high.
Agreed on the general literate programming note. I'm not sure I'll ever pick it up for something that doesn't have an obvious accompanying article/book to come with it, but if I ever write another tutorial or something, I'll definitely use it from the beginning.
But knowing what's out there is definitely important (and AsciiDoctor is extensible so these things could probably be added as plugins).