r/roguelikedev • u/KelseyFrog • Jul 16 '24
RoguelikeDev Does The Complete Roguelike Tutorial - Week 2
Congratulations for making it to the second week of the RoguelikeDev Does the Complete Roguelike Tutorial! This week is all about setting up the map and generating a dungeon.
Part 2 - The generic Entity, the render functions, and the map
Create the player entity, tiles, and game map.
Creating a procedurally generated dungeon!
Of course, we also have FAQ Friday posts that relate to this week's material
- #3: The Game Loop (revisited)
- #4: World Architecture (revisited)
- #22: Map Generation (revisited)
- #23: Map Design (revisited)
- #53: Seeds
- #54: Map Prefabs
- #71: Movement
- #75: Procedural Generation
Feel free to work out any problems, brainstorm ideas, share progress, and as usual enjoy tangential chatting. :)
36
Upvotes
10
u/Kyzrati Cogmind | mastodon.gamedev.place/@Kyzrati Jul 16 '24
I've been compiling the directory of participants over the first week, with links to repos and other info, and will continue to maintain that throughout the event as new folks post and update their projects going forward. Simply posting a repo in the weekly threads gets your project added.
So far this year we have 40 declared participants in my data, 15 of whom have shared public repos. A higher number of participants than at this point last year, though somewhat fewer repos--I'm sure more will be joining over the coming week, as happens each year. Not too late to join since the first week is mostly just about getting the basics set up :)
Good luck!
6
u/HexDecimal libtcod maintainer | mastodon.gamedev.place/@HexDecimal Jul 16 '24
GitHub repo - Python 3.12 - Using python-tcod & tcod-ecs
Entities are already handled well by ECS so I have no need to make the Entity class as defined in the tutorial. The tutorials Entity class breaks the open–closed principle by tying the specific data of the class to the class itself. Having to come back and modify that class as the tutorial goes on is never ideal if you want to extend the tutorials engine.
Also notable is that I won't be making an Engine class either. This class exists to help keep important objects in scope since the tutorial tried to avoid global variables. Since the Engine class is not really meant to be sub-classed it's easy enough to move its methods into simple functions. Scope issues are solved by ECS with its global registry and querying functions, whatever you can ask for is in scope. I also stopped being adverse to global scope and keep mutable globals in a dedicated module for tracking them. I generally keep the game state, the ECS registry, and the tcod context as globals.
Instead of a Map class I have a map entity which has two main components: its
MapShape, and aTilesarray. Tiles are stored as a NumPy array of indexes since ECS does not handle contiguous objects as well. Then I keep a database of tiles which I can use to get the tile data from the tile index.I decided to tweak the generation a little. Instead of randomly placing a room each time I pick an existing room and place a new room over it, then I random walk the new room until it no longer intersects with anything. This keeps the room layout more compact but the tunneling still looks like a mess when rooms walk over other rooms. I could probably clean that up by tunneling to rooms based on distance from the final placement as I've before with good results. I'll have to continue tweaking this. I have placeholder up/down stairs entities, and I set the starting player position to the up stairs placeholder.
Now that I have tiles, I handle the rendering using a tcod-camera package I've made to automatically resolve the slices needed to map the world array to the console array. Otherwise I'd constantly trip over the various edge cases of slicing the NumPy arrays.
6
u/SelinaDev Jul 16 '24
Couch-coop Roguelike
Engine: Godot 4.2 (Using GDScript)
Repo: https://github.com/SelinaDev/Roguelikedev-Tutorial-Tuesday-2024
The entity part was interesting. I chose to go with a entity component architecture. In contrast to my tutorial, all the entities and components are resources, making it easier to handle them just in code, and hopefully also making it easier later when I want to save them. I was inspired by a talk by Brian Bucklew (https://www.youtube.com/watch?v=4uxN5GqXcaA) to use a system where entities and their components could process messages (consisting of a tag and associated data). Using a two-pass process, components can first add to or modify data in a preprocess step, and then modify themselves in an execution step. E.g., a move command will send a move message with the move offset to the entity. The position component checks if the move is possible in the preprocess step, and changes the position in the execute step. This in turn triggers a message by the position component notifying other components of the position change, which for example triggers a render update in the drawable component. I'll have to see how this system performs as the game and the number of entities grows, but so far I like the flexibility of the approach.
Speaking of rendering, this part had quite a few improvements. In a previous attempt at a couch-coop roguelike I was still using Sprites and other nodes, but that was what derailed that attempt, as this becomes nigh impossible to manage once players would go to different levels. I have already started to prepare a kind of world manager in this project, and successfully moved all of the rendering to the RenderingServer. It's a bit tricky, but now I can more easily have maps and entities just in code, and render them from there, avoiding the Scene Tree altogether (I'll still use that for UI lather, though).
For the map generation I decided to try to implement the dungeon algorithm of Dungeonmans, as detailed by Jim Shepard in the book Procedural Content Generation (eds. Short and Adams). The algorithm parses hand-crafted room layouts from simple text files and attaches them to each other. Right now I only have a handfull of crafted rooms, but I hope to be able to create some more, maybe integrate doors later on, and improve some aspects of the generator (currently the dungeons are still awefully tree-like).
6
u/NyblFactory7 Jul 16 '24 edited Jul 16 '24
Game Engine: Godot
Language: C#
Video: https://www.youtube.com/shorts/KhZjTqOeDPQ (Please forgive the poor quality, I'm learning how to improve my recording quality as I go.)
I hope this isn't too far bending the rules for this. I started this a wee bit before the series started and going by my speed, I'm going to finish a bit after the series ends, so here is my progress on Part 3, from June 11th.
I usually post video progress every Tuesday. I am currently using Godot and SelinaDev's tutorial, converting it to C# as I go (this is the second time I'm completing this tutorial now). I've seen maybe 2 or 3 other people here converting her tutorial to C#, with plyr0 fully updating the tutorial in his github.
My goal is to use this to better learn Godot and see some of the pros and cons to Selina's approach. I ply C# in my day job as a senior engineer, so I'm looking to really apply some good patterns and principles to Selina's design to create a foundation for a bigger project in the future. So far, I've picked out using
Maybe<T>andResult<T>return types where Selina has usednulls.Long term, I'm looking to clean up the overall folder structure as I gravitate towards organize by feature, rather than by function. I need to be much more familiar with Selina's project before I make that kind of reorganization though.
5
u/rikuto148 Jul 16 '24 edited Jul 16 '24
Game Engine: Godot 4.2.1
Language: GDScript
Repo: https://github.com/mat148/RougeLikeDev-2024/tree/master
Video: https://imgur.com/a/YQcJtiL
Hey, you all. I've been working in Godot and mostly just doing this without a tutorial. I just wanted to let you know that I only look things up whenever you need me. All the tutorials are great; I've followed SelinaDev's in the past, from which I pulled the dungeon generation. None of the tutorials have ever clicked with me in a way that makes sense. I suspect that it concerns how the original tutorial is set up.
EDIT: I feel like this sounds like I'm throwing shade at the original tut, but I'm not I think maybe it just conflicts with the way my brain works or wants things to work?
So far, the hardest thing has been the entity turn manager. It and dungeon generation are what stopped me in the past. If anyone has any advice on that, I'd gladly take it. At the moment, my player has an area2D, which, when entities hit it, gets added to an array. Then, every turn, I get the next entity in that array and tell it to do its turn and signal when its turn is complete. Here is the schedule_manager script if you're interested.
Here's what I've got so far.
I'm working on refactoring entity turns, which weren't functioning as expected. Enemies take two turns, and things break when an enemy dies.
Things to work on next:
Weapons
5
u/jube_dev Far West RL Jul 16 '24
Language: C++ Library: gf2 Repository: https://github.com/jube/roguelike2024
This week has been quite easy thanks to the gf2 library. I improved one of the class of the library I use. I have a
GridMapthat handles a grid of any shape (orthogonal, isometric, hexagonal) and useful algorithms regarding shortest paths and fields of view (only for orthogonal maps for now). This class will be useful for next week. I still needed to store the tile in a secondary 2D array. When thinking about it, storing a tile (or more generally a tag) in a grid is something that could be useful for many usage. So I added a tag (a simple int) in theGridMapcells and I used it to store the tile used for the cell.The only difficulty is that I already have an
Entityclass in gf2, so I usedObjectinstead even if I'm not really satisfied of the name.4
u/AleatoricConsonance Lost Gardens of the Stone Heart Jul 17 '24 edited Jul 17 '24
Typescript/Rot.js tutorial.
My “repo” is "./backup/weekNumber" :-)
Notes:
4
u/KaizarNike Jul 17 '24
Local Multiplayer RL 2024
Made in: Godot 4.2.2 (GDScript)
Links: Itchio Web Release, Github
This homunculus of a RL has been stitched together from at least four projects by now, and I'm loosely following the tutorial. Local multiplayer is in! Only took me like 5-6 hours with two meal breaks and a walk. TY SelinaDev for the idea and the Godot tutorial, even tho I quail at ECS programming and mostly do without.
Can't wait to add enemies, as their pathfinding made my Breath of the Rogue fail. Also if anyone lives with gaming friends, I'd love to have some playtesters beyond my family.
See yall next week!
3
u/EquivalentFroyo3381 Jul 16 '24
hello again, just finished part 3, here is my repo https://github.com/jossse69/Python-RL, i'm wanting to add some sort of sic-if theme for my game tbh, in a complex or something, its just me thinking but anyways, good luck to anyone else and cheers!
3
u/wrkta Jul 17 '24 edited Jul 17 '24
Just finished chapter 2 of the tutorial. Github repo Been using python 3.12.4 and tcod 16.2.3 and following pretty closely with the tutorial since this is my first time doing this.
Only extra changes I have made so far is adding vi-movement keys (duh) and changing the window scaling since it was rendering way too small on my 4k screen. If anyone else is following the tutorial exactly and has been having that issue, the screen size fix is on it's own commit so it should be easy to see how to update it from my repo.
Not really enjoying using python / tcod so far. I haven't used python for a long time and have never used tcod before but I am thinking I might start fresh with something else before I get too deep. Currently considering either Godot (which I already know how to use) and Bevy (I would be learning Rust + Bevy + ECS from scratch). Obviously the latter will be a lot more difficult but it seems more interesting.
3
u/IndieAidan Jul 17 '24
Untitled Godot Roguelike
Managed to get a little bit of time to get some version of dungeon generation made with Wave Function Collapse (WFC). It is using the Alexey Bond WFC plugin (I think), so most of the hard work was already done. There seem to be three WFC plugins in the Asset Library, though this seemed to be the one that worked best for me.
My sample map I made is super basic and I probably need to confine things more as it is currently not producing the type of map I want in the end. But it is cool to have my guy move around these random maps. Mostly just a little more time and effort into a better sample map, and more time with the negative sample map is all it needs, but I'm mostly doing these ones as proof of concept for myself, and will put more TLC into my main game version.
It was fun to run into a "bug" of running into invisible walls all the time, which turned out to just be the hidden Sample and Negative-Sample tile maps with their collisions layers still working.
I also like that I can do some prefab on the final map before WFC and that you can have Scenes incorporated into your tilemaps, and therefore incorporated into the procgen. So things like a Scene for a wall torch that requires more specialized functionality can be generated with WFC. Or doors etc.
To go with the lighting system, I've started making just pixelated circles in Aseprite to make the required shapes to give a torch with a, say, light radius of 10 tiles.
Repo will eventually get added!
3
u/MKijowski Jul 18 '24
Unnamed roguelike | Github | Part 2&3 commit | Play! (master branch)
During my initial rush I've implemented few weeks ahead, so the last week I have been focusing on movement "feel" as I wanted just moving around the map to be fun. I've added few small animations and tweaked timings for a bit, but finally I were able to get close to what I wanted.
I'm certainly not a novice programmer, but I'm fairly new at this and so far it has been fun. I'm currently around implementing part 7, but I suspect that coming weeks my progress will slow down a bit and the progression will catch up to me :)
My plan going forward is to "speedrun" to the end of tutorial and then each week focus on extending that week's themes. I would also like to try refactoring to a more "hip" approach at some time (ecs or event based system)
Game controls
qweasdzxc - movement
o - generate new dungeon
kl; - try it out :)
3
u/avinashv Jul 18 '24
Caverns of the Shadow Queen | Rust/bracket-lib/legion | GitHub | Week 2 Commit
I find the initial weeks terribly boring, so I speed ran the first three weeks until the basic framework was there. This book does that most of the rogue like tutorials that are based on the canonical ones do, which is have insane re-writes and refactors. I have been very patiently looking forward to u/Hexdecimal to complete their revision of the Python tutorial into a more modern approach without so much redundant work in it.
I think for now I like legion more than specs. The book seems to omit a messaging log entirely which is absolutely wild for a roguelike but I guess that gives me an opportunity to figure out how to implement that myself.
3
u/haveric Jul 19 '24 edited Jul 19 '24
Neil the Seal - Godot 4 GDScript | Github Repo | Playable in Web (F1 to generate a new map)
Most of the infrastructure issues I had last week have been resolved, so now I can easily add more components and entities while still using Godot's resources. I'm also using the addon "Godot Resource Groups" to allow dynamically loading entities and components from folders, saving me time defining which ones are possible to use and avoids any issues with exporting dynamic resources. One of the main pain points I ran into with /u/SelinaDev's tutorial before this was entities and components having a separate definition. It seems both of us have gone the direct route of having them be their own resources, so I'm excited to see how well it works by the end. I almost abandoned resources entirely in favor of pure json, but I think I've got an approach that utilizes Godot's resources quite well and still has the potential to use json for modding potential later.
My first pass at creating towns was to just randomly place horizontal and vertical roads, filling in the rest with houses and grass. While it worked for testing, the roads felt pretty bland, so I ended up using a basic BSP algorithm, which splits the area into random "halves", changing direction of each split until it gets to a desired minimum size. The resulting towns look a lot better and have more variety to street layout. For now, I am placing single tile placeholder houses and some grass in the remaining non-road tiles, but plan to add a variety of larger buildings/features before next week. I also plan to add a beach/water starting area on a random side of the town to add some more variety and give the player a safer entry into town.
The artist I'm working with had some unexpected time to work on some assets, so other than the houses that are being used as placeholders, it is already starting to look pretty good.
Overall, I'm feeling pretty good about using Godot now that I'm past the major pain points setting up the ECS architecture and am looking forward to how this game turns out and seeing what everybody else is doing this as well.
3
u/bartholin_wmf Jul 19 '24
Started the whole thing here, basically just following the tutorial on Python 3.10.12 with a few changes (I've flipped wall and floor generation because I realized it generated cool random "cities" and then found a way to put me outside the village). I've sort of an idea for an aesthetic first, with this archipelago that leans into South and Southeast Asia in the 1500s and 1600s, and the Europeans that came over for trade, and sort of a pastiche of that with maybe also some Pirate and Mesoamerican influences here and there. But that's so much more than what I have now.
3
u/ChizaruuGCO Jul 19 '24
Game Engine: Unity Engine
Language: C#
Repo: TBA
Making use of ECS and NetCode to make a 2D multiplayer roguelike, will I finish it? I hope so.
It's a huge undertaking because I will be making another tutorial series, but it won't be week by week. I made that mistake last time and I still get questions two years later about being too fast or code not being performant..
So I'll be taking my time to iron out issues while making sure that the progress is visible to the public, I'll have it running on Unity Gaming Services for community testing at some point, probably at the halfway point. (Unity is kinda generous with the "Free" tier)
2
u/Taco_Chop Jul 18 '24
Wisest Wizard Language - Python 3.9 GitHub Repo
So I've picked up on a tutorial game I started making three years ago and never finished. Before I left off with it all those years ago, I had just finished figuring out a way to set different tiles to represent dungeon walls depending on their location. Was it the most efficient and effective way to do it? Absolutely not, but I was quite proud of myself for figuring it out. I'm currently on part 6 and I'm trying to refamiliarize myself with python enough to start expanding on the tutorial again. I'm slowly getting there.
2
u/LukesFather2011 Jul 18 '24
Github Repo - I'm just following this tutorial using python like it recommends. It's what I am the most familiar with. I've been brainstorming ideas for what I want it to evolve into, but for now I'm just sticking to the basics until I gain some confidence. I'm hoping to take my first real step into this community and make something that people will actually want to play.
2
u/KCEHOBYTE bedivere Jul 21 '24
Rust + tcod | GitHub
The hardest part about this week was to find time I guess. As it's all about learning some Rust for me the strategy is to read a bit of tutorial, understand what they are about to implement and then jump in and try to do it myself, after that works I can jump back and see what did I do differently. I got familiar with the borrowing and ownership more or less so pretty happy with my progress so far.
2
u/systemchalk Jul 21 '24
Late to the party on this one, but it was the closest I've ever gotten to seeing this event start and having an intention to join in. Thank you for hosting the event.
I'm just doing a very vanilla run through the tutorial (Python 3.12 + python-tcod), looking up things I don't understand as I go, and updating it whenever there seem to be warnings and the like.
Links:
GitHub Repo
Youtube playlist as a commitment mechanism (the tutorial likely does not benefit from the 'audio book' format but there you have it)
2
u/jonathansharman Jul 21 '24
Coincidentally I started working on an unnamed roguelike a couple months back, using Rust and ggez. I'm using this event as motivation to make some progress!
I'd already gotten as far as very simple level generation, line-of-sight (using this amazing symmetric shadowcasting tutorial), and some aimlessly wandering enemies with basic bump combat.
This weekend, in the spirit of Part 3 of the tutorial, I've been working on making my level generator less terrible. I drew a little inspiration from this Brogue interview, but I'm still going to keep things really simple for now. I've ensured that all rooms are reachable, but the hallway layout could use improvement.
2
u/PainFadeDown Jul 22 '24 edited Jul 23 '24
GitHub repository - I'm using python/tcod & tcod-ecs
Right up against the deadline, I've achieved a sufficient result, which is by no means optimal. In the tutorial, at this point I'd have a very rogue-y dungeon with a bunch of rooms and corridors. I deviated in order to create a more unique map and learn new techniques. Even creating a very simply cave-like map has been a significant undertaking, especially given the timeframe and my skill level. This is the result so far.
I'm essentially still generating a dungeon in the way the tutorial shows, but I'm letting a couple of cellular automata pass over that to make the map more organic and smooth. This has sometimes resulted in one of the rooms being closed off, so I implemented a flood fill to search for and connect isolated regions.
It's my intention to add a little variety in colours and glyphs eventually but this is the minimum state I wanted to get my first map generator to be in.
For those cloning the repo, if the controls are not made obvious to you from the code: numpad 1-9 will move the player, F1 will regenerate the map, Escape will quit the game.
Map generation right now is very slow, too slow for my liking. I think the main reason for that is my implementation of flood fill, but I was running out of time for the deadline and my head is already spinning with all I've learned.
Honestly, this is probably overbuilt for the part of the tutorial this week addresses, but I had intended to expand on some specific portions as we got to them to get out of my comfort zone and learn new skills. I've definitely achieved that, and I can definitely see the road ahead is still long.
2
u/Old_Pops_94 Jul 22 '24
Portals of Balor | Github Repo | Week 2 Stopping Point
This week I didn't get as much done as I'd wanted, and I ended up more or less following the Rusty Roguelike tutorial verbatim. I had envisioned branching out into Chapter 4, where he refactors the map code, builds a test harness, and starts working through some more interesting maps. But I had less free time than I thought I'd have.
I'm hoping in the coming week to be able to get some interesting monsters into the mix, and if I have time go back and jump to the more interesting maps portion.
2
u/vrolnek Jul 23 '24
github | part 3
Successful implementation of the basic dungeon generator.
I'm using ECS through beast, a Common Lisp wrapper.
Calling raylib from CL has yet to prove problematic.
2
u/justjr112 Jul 17 '24 edited Jul 17 '24
I am receiving this this error:
File "c:\Users\Johnny\Documents\games\rouge.py\main.py", line 4, in <module>
from engine import Engine
File "c:\Users\Johnny\Documents\games\rouge.py\engine.py", line 7, in <module>
from game_map import GameMap
ImportError: cannot import name 'GameMap' from 'game_map' (c:\Users\Johnny\Documents\games\rouge.py\game_map.py)
steps to fix the problem:
rewrote the code twice.
asked chatgtp to correct any errors: nothing every thing came back "fine"
infinity checked the names of the files.
I am using visual studio code.
can share the code if needed. thank you for the help.
edit: https://github.com/justjr113/roguepyweek2/tree/main/rouge.py
2
u/leomartius Jul 18 '24 edited Jul 18 '24
I'm in! I have already completed the python-tcod tutorial on my own, so these last couple of weeks I studied some collateral technologies like pyinstaller and mypy while following along with the tutorial.
Still, I'm not sure if I should just jump the gun and start working on my own little project while trying to keep up with the forum schedule.
0
u/[deleted] Jul 17 '24
[deleted] — view deleted comment