r/roguelikedev • u/KelseyFrog • Jul 29 '25
RoguelikeDev Does The Complete Roguelike Tutorial - Week 3
Keep it up folks! It's great seeing everyone participate.
This week is all about setting up a the FoV and spawning enemies
Display the player's field-of-view (FoV) and explore the dungeon gradually (also known as fog-of-war).
Part 5 - Placing Enemies and kicking them (harmlessly)
This chapter will focus on placing the enemies throughout the dungeon, and setting them up to be attacked.
Of course, we also have FAQ Friday posts that relate to this week's material.
- #12: Field of Vision(revisited)
- #41: Time Systems(revisited)
- #56: Mob Distribution
- #70: Map Memory
Feel free to work out any problems, brainstorm ideas, share progress and and as usual enjoy tangential chatting. :)
12
u/WeeklySoft Jul 29 '25
Here is my parts 4 and 5 in C++ and flecs.
The biggest difference from the tutorial is that I don't have entities inside my map. Instead I created a realtionship where a monster is a child of the map. This lets me use a relationship query to find all entities on the map.
11
u/GrishdaFish Ascension, the Lost Horizon Jul 29 '25
Roguelikedev tutorial in Python with my own engine (Horizon Engine) + libtcod.
Discord
Git Repo
Not much has changed since the last update, since I have been pretty far ahead, but looks like this week I'll have some work to do. But, I added a welcome pop up, auto generated a ton of docstrings where missing, fixed a few bugs, added some extra logging on the C++ side of the engine and a few other minor things.
Unfortunately, I got pulled into the blackhole that is Eve Online by a few guys in my discord. Oopsie.
For the most part, I've been following the tutorial on RogueBasin, but I have been looking at the one in the topic and it looks like its going for a full ECS style system.
Personally, I'm not a fan of ECS, although I do like composition. In my main project, I do a mix of Composition and Inheritence and I like the way things work. I'm not saying ECS is bad, or my way is better, it just makes more sense in my brain. So I'm likely going to deviate quite a bit from the tutorial, while still following along.
I've also decided that I want to turn this into a roguelike of a very old game (from 1995!) I used to play when I was a kid, Mordor: The Depths of Dejenol. I was actually part of the remake MordorXp and although that project never finished, I can use my experience on that project and playing the game to give it a bit of a roguelike twist. It won't need much, since many of the mechanics and elements are very similar. I'm thinking of calling it DejenolRL or something of the sort.
9
u/AleF2050 Jul 29 '25
repo
I'm appreciating the current result of the tutorial as i'm starting to see the visuals in a proper way. In addition i've added a visual enhancement which consists of entities facing direction when they make a move on the horizontal axis of the map. It's starting to feel more alive as it goes on that i really love it. The downside of Part 6, however, was that following the tutorial in that section felt very tiring due to the devastating amount of refactoring going on.
For now, this week i'm putting my project on hold until the next week starts since i've been very onwards with the tutorial up until the end of Part 6 so i'll be instead focusing on trying to program something original instead!
9
u/vicethal McRogueFace Engine Jul 30 '25 edited Jul 30 '25
McRogueFace Still In The Race
here's "part 6a": https://i.imgur.com/nZ1DF4T.gif
We've got collisions! We've got field-of-view! We've got primitive enemy pathfinding logic...! Enemies have their own field of view, and they're each custom.
I'd say this is me encountering my first "architectural" difficulty of the tutorial, and I've decided to break the TCOD tutorial parts 5/6 stuff I was working on into more parts for McRogueFace.
My concern is that the turn structure with animation is kinda rigid on the controls, and what I'm going for is seamlessness - I want to be able to hold the arrow key and get continuous little hops from the on-screen dudes. Technically I don't care if the enemies finish their animations, I just want their destination square to be known. In other words, the simple animation of sliding from square-to-square complicates the turn tracking mechanics quite a bit.
I got around this in my jam games so far by just not animating movement, and allowing pieces to instantly move (enemies too). It was effectively "always" the player's turn at every user input cycle. So I'm carefully pondering now how much I want to fret over this, or I should just leave as "kinda weird but good enough" for right now.
...who am I kidding, this is not good enough for now. I don't think I'm supposed to be able to juke the enemies like that, it's either a weak pathfinding choice or a flaw in the turn cycle that allows player motion to occur faster than enemy turns can complete
edit: performance improved a lot with Djikstra: https://i.imgur.com/8Ez8tfV.gif
Also makes them instantly quite scary, emerging from the shadows to pursue me
8
u/nwb712 Jul 29 '25 edited Jul 29 '25
Hello everyone! I may have gotten a tiny bit ahead an finished the whole tutorial already.
I'm now focused on replacing the existing systems with something a little more involved in order to make an actual game of it.
I want to focus on creating allies out of scavenged parts with stats determined by which parts were used. I was originally thinking of restricting the parts to different types, but I think I'll go a little more free-form with it and let the player use whatever combination of 3 parts for example. I haven't implemented any of this mechanically yet so still just a design in my head.
To lay the groundwork for the above, I've just implemented a rudimentary dice based damage system, tweaked defense mitigation, and added the ability to dodge attacks. Of course the numbers are made up in just a few minutes so there's no semblance of balance yet.
Additionally, I have grouped Actors into enemies vs allies and added a basic allied follower AI which attacks enemies when it can see them, but otherwise follows the player. In the process of tweaking the new AI I added the ability to non player actors to calculate their own FOV with different radii possible. I still need to add allied FOV to the visible array so that vision can be shared.
Next I will want to implement some basic parts and give the player the ability to construct allies out of them. So will need to add a new class of items, configure loot drops from the enemies and add them to the map, and add in the interface for creating said allies.
I'm having a great time with this and I definitely feel like I'm understanding a lot more than I did in previous attempts.
repo here
EDIT: Forgot to mention I am building based off the Python tcod tutorial
7
u/TechniMan Jul 30 '25
Following along in TypeScript with ROT.js! GitHub | Playable
This year, I've not been following a tutorial directly, instead using my years of experience doing Tutorial Tuesday and doing the TypeScript one last year, and of course peeking through my code from last year to help along :)
I've been fairly busy of late but thankfully have found some time to get cracking, and I've implemented up to Field of View and have formal Actions! Might get an InputHandler next to move that bit of code out of the Engine's update, then of course there's generating enemies!
Also, the world generated is a large open area with lots of boulders blocking view. I was inspired by playing a lot of Helldivers II, and am going to take inspiration from some parts of how that game works. The barren, rocky landscape is a "first draft" of the mapgen, to get a feel of it for now, but later on I'd like to build it in large "chunks" which could be one of a few different styles of landscape, from completely empty, to rocky like it is now, maybe one that's even more rocky, and of course some chunks with structures in the middle like either an abandoned human outpost or a bug base to be destroyed.
I'm quite excited for the idea to be realised, I have a big page of notes for how I'll translate some things to roguelike, hoping to get back into a regular daily routine to work on it and see the vision through to the end!
6
u/scanlanhand Jul 29 '25 edited Jul 29 '25
I'm following the Python + libtcod tutorial using Zig + Raylib bindings.
My goal is to practice Zig along the way in a fun way. Right now i'm not focusing too much on code quality, but on achieving every tutorial week's goal.
The experience so far has been great with both the language and the tutorial, which seems quite easy to port. But i'm expecting to have harder time with FoV and other stuff that libtcod already provides. I'm in the mood of writing some blog posts on this but i think i will wait for the end of the project and write a post-mortem. We'll see.
Keep up with the great work everyone!
Github Link
6
u/Rakaneth Jul 29 '25
Repo, week2 branch
I am having some difficulty actually with week2 stemming from my tileset. It doesn't have enough wall tiles. I am deciding if I want to switch tilesets to one with a single wall tile, or write all the extra code I'll need to possibly make my current tileset work. When I move to week 3, I'll merge
week2and start a newweek3branch.6
u/starmade-knight Jul 29 '25
repo
Well, I didnt make a post last week for some personal reasons, but here's my post for this week. I'm finding it hard to deviate from the tutorial because every time I do, I worry that I'm making a decision that will conflict with the tutorial later on in a way that will make me revert a lot of progress. So I'm going by the book for now, focusing on trying to understand the code I'm copying.
6
u/Bommel48 Jul 30 '25
repo | LUA, LÖVE
Part 4 and 5 are done: gif
I am not following the tutorial too strictly, which has resulted in the entity handling being a bit of a mess right now but it's sufficient for the time being I guess.
It was cool to see how easy basic FOV was, I thought it would take me much longer.
5
u/sird0rius Jul 29 '25 edited Jul 29 '25
I wrote a devlog with a lot of pictures about my week 2 progress here and the web build is "playable" on itch. This week looks very interesting! I've already started implementing some things for explorable tiles and I'm trying to understand some FoV algorithms right now.
Repo
5
u/enc_cat Rogue in the Dark Jul 29 '25
Had little time do dedicate to week 2 so did not implement all I had in mind. Still, I got decently-shaped caves (guaranteed to be connected) with some patches of vegetation. Eventually would like to add water and chasms, but for now this will do.
Screenshot of cave proc-gen
Now off to parts 4 and 5, which are going to require thinkering with FOV and hex grids!
5
u/Giant_Purple_Octopus Jul 30 '25
Made it to week 3. Slowly remembering everything I forgot about python in the process. Only had time to follow the tutorial last week without a lot of room for experimentation. But hopefully this week I can get parts 4 and 5 done then circle back to messing with the dungeon generation.
5
u/Nuzcraft Aug 01 '25
joining in using prism and love2d - here is my repo, I'm just getting started
5
u/matzieq Aug 01 '25
Ok, part 4 and 5 done, repo here. Not too much here, some nice Python flexing in data transformations, where I'm like "whaaa? you can do that?" One thing I don't understand is why is it a good idea to do all those shenanigans with creating a spawn method within the entity class which copies itself, but we need a special library for that, because we need a deep copy, and then we create the entities and they copy themselves and my head is spinning... I mean, if we create the entities by calling the constructors, then... why don't we just call the constructors when spawning them? Anyway, it's starting to look like a game. I also changed the font and colors to look more like crawl, because that's my comfort game, although I'm one of the -2.7 people on Earth who prefer Linley's Crawl to Stone Soup.
But I'm enjoying the process and the relaxed pacing so much, that I've decided to follow the tutorial once again in parallel in a language I barely know - C++. Here's the repo. Moreover, I'm using Raylib, but just for rendering, input, and some helpers like text formatting. I intend to implement all of the roguelike algorithms myself (or steal them from others after studying them). Here's my story, which started on Wednesday.
Part 0: I used a template I've built earlier (and I have no idea what for, but I'm glad I did) which gives me a nice base - Raylib compiled for mac, windows and linux, as I use all three 😱, and a makefile which compiles everything for the appropriate platform. For Windows I'm using w64devkit, which is a great portable Unix shell with basic utilities, like gcc, g++ and gdb. I compiled a hello world to make sure it worked, and it did.
Part 1: I ripped the renderer from the skeleton I had with the template, modified it a little bit and got an @ moving in no time. I also decided to make it just a namespace with functions instead of a class with static methods.
Part 2: So the way I program C++ may be a little bit unorthodox, as I'm using it more like C with some quality of life improvements. From C++ I take strings, vectors (because I don't want to deal with allocating and reallocating memory for arrays) and also namespaces and the simplified struct declaration, without typedef. And yes, I'm only using structs with only data inside, which are declared in a single header file called "models.hpp", and then declare functions that operate on those structs. So this is how I coded the entity, rendering and map. But I don't want you to get the wrong idea that I subscribe to some weird notions of how things should be programmed or that I'm deliberately shooting myself in the foot for no reason. I'm doing this for two main reasons: 1) Separating logic from state will make it easier for me to serialize the state at the later stage to save it to a file, 2) I'm just a dumb barbarian whose head starts overheating when it comes to OOP, my brain just doesn't work that way and I can't reason about an OOP program, because I have no idea what's going on. So look at my code at your own risk.
Part 3: Nothing to see here. The generator is essentially the same as in the Python tutorial, I just had to get rid of the generators and shorthands and do everything more explicitly. Which I do prefer most of the time, because as much as I like clever code, I prefer to know exactly what's going on.
Part 4: I ripped a Bresenham LOS routine from my semi-failed attempt at making a roguelike in C which I started about two years ago. It failed not because it was written in C, but because after implementing rudimentary combat and a logger I was left with a "now what?". I wanted to write a roguelike in pure C, but I had no idea what game it was going to be. Now the Bresenham routine is funny, because you can spend all the time you want staring at the code and you'll have no idea how it works - but recently I watched a very enlightening youtube video which explains the algorithm "from scratch". You basically have to start at the beginning, and then use some algebraic shenanigans to simplify the equations until you basically get the algorithm as presented in the code. At its core it's actually very simple. This is one of the things I missed in the original tutorial, as the thing that interests me the most in roguelike development is diving into all the algorithms, field of view, procgen, AI etc. and seeing how all this works "under the hood". Using a library and calling a function called "bresenham" doesn't cut it for me. But I understand that I'm a special nutcase, not everyone finds these things fun, some people just want to write a game, and that's probably less of a wasted time than what I'm attempting here. But hey, it's a hobby. So sue me.
Part 5: Again, nothing too interesting to see here, although to spawn enemies I just created helper functions to return appropriate structs. At a later stage I'd like to maybe store the enemy data in a JSON file or a Lua table, and just parse that and use it to spawn appropriate enemies, but let's finish with the tutorial first, then I'll worry about expanding. With the ADHD it's entirely possible that by that time I'll lose interest, which is unfortunate, but you have to learn to live with it or you go crazy.
Overall, I'm having a lot of fun with this project. I'm learning a lot about C and C++, which is nice, I've also tried command line debuggers (gdb on Debian and lldb on Mac), and they work surprisingly well, I was able to quickly find the problems and remedy them. I know that all this stuff may be bread and butter for some of you, but to me, a currently-between-jobs web app developer, it's pretty much uncharted waters, and the fact that I'm still afloat makes me exceedingly happy. I'm optimistic about the future, as my previous failed RL also has nice routines for Dijkstra maps and pathfinding, so of course I'm going to reuse that. I'm even thinking about turning this into a tutorial, as you learn a lot more when teaching others, but with my weird coding style I have no idea if this is something that someone would find useful. Let me know if you do.
And for now, I'm setting sail and going forward, to part 6. It's going to be a while before I arrive. What's that? Vanilla Javascript on canvas? Hmm...
4
u/hyppocratees Jul 30 '25
repo
I finished catching up part 3 and also did part 4 and 5 in C++.
I diverged a bit from the tutorial by putting the generation and management of entities in it's own class.
I will probably have to refactor some part to avoid potential bug in the coming week but I will do it when I'm required to. I still have a lingering bug where sometimes no entities get generated but I will fix that before doing next week
4
u/vicethal McRogueFace Engine Jul 31 '25 edited Aug 01 '25
https://github.com/TStand90/tcod_tutorial_v2/compare/master...jmccardle:tcod_tutorial_v2:master
hopefully won't be rude of me to summon /u/KelseyFrog , /u/hexdecimal , and /u/Kyzrati - and hopefully won't be an overly controversial use of generative AI
I'm working on generating fixes to the TCOD Python 3 tutorial
I think I'm finished through part 6, and there are some bugs to deal with in parts 7 through 13, but it's mostly dumb/easy fixes, just slightly inconvenient to revise because I'm not just fixing the code, but "rewriting history" by cherry picking commits to keep the tutorial steps separate and working at every point.edit - its done, looks great nowI was inspired by https://www.reddit.com/r/roguelikedev/comments/1mb26vq/libtcod_python_3_recommended_tutorial_code_is/
Do you guys think there's a pathway for me to get this onto rogueliketutorials.com or should I just put it up on a github.io page? I haven't started editing the tutorial text - because I couldn't find a source for the lesson pages themselves.
3
u/the_space_mans Aug 02 '25
Bit late to the party, but I finally got around to finishing parts 4 and 5 (repo here). I was sidetracked in a major way by implementing Protocols and ducktyping in the input_handlers.py section (see this commit). It was a major hurdle for me, but I finally figured it out with help from the r/roguelikes discord. Special thanks to Nolshine for the assist! This game is really starting to look like a game.
3
u/hiecaq Aug 03 '25
repo
I don't have much to say about this week's content, but for FoV I read about u/Kyzrati's brute force Bresenham raycast model so I tried that, because I'm curious about its performance and its quality of outcome. It turns out to be really acceptable. I think I can stick with this solution for the near future as long as I carefully plan when FoV is updated.
3
u/sird0rius Aug 03 '25 edited Aug 03 '25
Week 3 dev gallery | web build | repo
Week 3 done. I implemented FoV using an algorithm I had already used in the past for pathfinding, which weirdly enough contains an FoV pass. I'm not sure how it compares to the others explained here but it looks pretty similar to shadow casting. Basically it uses a breadth-first-search to mark vision and whenever it finds a wall it checks if it's a corner (looking at neighbors). If it is, it draws a Bresenham line behind it, marking the tiles as FoV blocked so they won't get visited after.
The simple version only uses one line from the player to the center of the corner tile. The slightly better version draws two lines to edges of the tile (where the tile is actually viewed as a circle of a configurable radius). So with a small tile radius like 0 vision is very expansive, and with a full radius of 0.5 it is very narrow (similar to diamond walls in the article).
I also added different enemies, a minimap and cleaned up animations so movement feels smoother now.
3
u/SelinaDev Aug 04 '25
Bit late, but here's my post for week 3, for both part 4 and part 5.
Field of View basically reuses the same algorithm as in my tutorial. Field of view is now just a dictionary in
MapData, and the part that updates it is a component. This plays very well with the system of messages between component, because the update just has to listen to messages about position changes. Similarly, the drawable component also just listens to those to then check inMapDatawhether the entity is in view or not. Once I get to items I will expand that a little with a component that modifies that process so that some entities will draw at the location you remember them in, even if they're not in view.Part 5 was relatively easy, as most things were in place already. I did include a little editor script that helps me pack all entities and tiles in a single resource containing two dictionaries, which means I can just load that "database" and get the entities within by key in the dungeon generation. Other than that I just had to introduce a movement blocker component and check for it in the move action.
Overall this week was pretty easy. Next week (for which I have the code almost ready) is a bit more complicated, because I'm applying the same modularity of components to the AI.
3
u/Old_Pops_94 Aug 04 '25
Dungeons of Go
Github | Tutorial Wiki | itch.io
I was anticipating this week being difficult because of the lack of FOV support directly in raylib. However, after doing some digging I found a really nice go library that worked (almost) seamlessly with the setup I had going, and let me calculate FOV almost as easily as if it were natively part of Raylib! Part of me wanted to implement the FOV algorithm myself, but this library was implementing the same algorithm I was planning to implement off of RogueBasin. I figured for the tutorial it didn't make sense, and if there was a stable implementation out there I might as well use it!
There were also some performance considerations I needed to work out. This is a bit of a "learning Raylib better" exercise for myself, and last week's "render every tile as a texture" performed very differently from the FOV implementation. With some tweaks I cover in the tutorial wiki, I was able to get much better (and more consistent) performance between desktop and web builds!
3
u/PainFadeDown Aug 05 '25
repo | tech: Python 3 / tcod
This week didn't see too many differences in my own codebase from the tutorial. The new actions from part 5 play nicely with the
ProtocolI'm using instead of the abstract base class from the tutorial. I've not run into any problems with implementing mob spawning. Eventually I would like to experiment with different map generation, and maybe a more complex time system.The mapgen I may experiment with before getting through the tutorial because it should be possible to write a separate generator without affecting the rest of the codebase too much. Time system I'll probably leave for after getting through it.
This is what progress is looking like. I've tweaked the colour pallete and the font a bit more.
1
u/tormodh Aug 06 '25
Repo
This, I mean last, week I got back to work after vacation. It kind of took some energy out of me. I did get a few monsters into the map, and coded "kick them harmlessly", though I didn't connect it to my room prefabs. Yet.
My plan is to find a bit more energy in week 4 and backfill a bit :)