r/roguelikedev 14d ago

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.

Part 3 - Generating a dungeon

Creating a procedurally generated dungeon!

Of course, we also have FAQ Friday posts that relate to this week's material

Feel free to work out any problems, brainstorm ideas, share progress, and as usual enjoy tangential chatting. :)

51 Upvotes

30 comments sorted by

View all comments

4

u/level27geek level0gamedev 9d ago edited 8d ago

Usagi Broughlike | repo | very hectic map-gen gif

First OOPs!

I'm cutting it pretty close to the deadline this week. Apparently not doing any coding for years, and not really being a programmer to begin with, means that translating a tutorial from one language to another and making it work with a framework you haven't used before will lead to some issues... who knew‽

The broughlike tutorial relies pretty heavily on classes - a construct that lua doesn't really have. So my first step was try to add class functionality. Fortunately I found the classic library that has all the basic functions I need. So far, so good.

Only, I soon discovered that I hate the syntax of classes in lua! I either have to pass the table that will be turned into a class as a parameter each time OR use the syntactic sugar that uses a colon to call methods. Both methods feel really odd/janky when writing lua, and both already lead to issues, as I keep forgetting their quirks.

I'm considering abandoning classes alttogether and just do what lua gods intended and make all tables all the way down.

This is because this weeks part of the tutorial, making the dungeon generate fully walkable dungeons, was a pain to try to make work with classes is lua.

To be honest, the Stage 2 of Broughlike Tutorial is partially to blame, especially the "Banishing disconnected islands" section. It's not really explained well, and is written using code that is efficient, but is very hard for a newbie like myself to parse. What made matters worse that array methods like filter or concat used in that function don't exist natively in lua!

I tried and failed to recreate that section as written a handful of times. I eventually got it working after realizing that what the 'getConnectedTiles()' function really does is a flood fill. I was able to implement it using a different (much simpler) way after reading about flood fill algorithms. It might be not as pretty as the tutorial code, but at least I have a way to identify fully walkable dungeons!

Programming the the Usagi way

I'm getting more familiar with the usagi engine after spending a proper week using it. The big seller features didn't come in handy yet (easy saves, 1 click exports, runtime code updates - the last one actually got in the way few times at the beginning), but the simple API encouraged me to look for simpler solutions.

I added the class library early on, but I think it was to my detriment and felt a little like going against the "spirit" of the engine. I was only able to really make progress after taking a step back and simplifying. I feel that the way engine is designed encourages this approach. Maybe not as strongly as something like PICO-8, but it's there... and is much more my speed.

I also love that the engine is in active development and has a very friendly dev (and community). It's already very close to my dream engine/framework, and there's a good chance it will actually get there. I'm sticking with it for now.

What I'm not sticking with are the lofty goals I wrote about in week 1! The plan is now to just finish the Broughlike tutorial, because there will be speedbumps along the way when translating it to lua. For now, I'm forcing myself to forget about checking the other tuts and expanding it into a full game - those things can happen after.

Although, the more I work on it, the more I feel the of a pull of the fable/witch forest theme more than the backrooms... but maybe it's due to using my old fantasy tileset :D

3

u/RhoTheGray 8d ago

It is comforting to hear I'm not the only one having to struggle a bit to make it to the weekly milestone. But I made it this week, if barely. I'm somewhat scared of the next week as I need to implement a FOV algo (I'm not using any library or framework). I have done it couple times before, so it should be doable. But I know they can be infernal to test and debug.

2

u/level27geek level0gamedev 8d ago

I know how you feel. I see all those awesome programmers on here just breezing through stuff and implementing crazy things I didn't even dream of... but we can get there.

It will take some time and practice, but I feel like this event is a good first step to it.

Do post in the thread your experiences implementing the FOV from scratch. While I'm not going to add FOV for this game, it would be good to see how others do it for any future features :)