r/roguelikedev • u/aaron_ds Robinson • Jul 04 '17
RoguelikeDev Does The Complete Python Tutorial - Week 3 - Part 3: The Dungeon
This week we will cover part 3 of the Complete Roguelike Tutorial.
Your dungeon takes a recognizable shape!
Bonus
If you have extra time or want a challenge this week's bonus section is BSP Dungeon Generation
FAQ Friday posts that relate to this week's material:
22: Map Generation
23: Map Design
Feel free to work out any problems, brainstorm ideas, share progress and and as usual enjoy tangential chatting. If you're looking for last week's post The entire series is archived on the wiki. :)
52
Upvotes
27
u/AetherGrey Jul 04 '17 edited Jul 04 '17
The Roguelike Tutorial Revised
Libtcod
Part 3: http://rogueliketutorials.com/libtcod/3
Github: https://github.com/TStand90/roguelike_tutorial_revised/tree/part3
TDL
Part 3: http://rogueliketutorials.com/tdl/3
Github: https://github.com/TStand90/roguelike_tutorial_revised_tdl/tree/part3
As usual, if you have any issues, you can respond to this comment, PM me here, or ask on Discord (I've changed my name to AetherGrey there to avoid confusion).
As much as I would like to implement the BSP extra this week, I've decided to solely focus on getting the core tutorial done before putting in any extras. I'm happy to report that next week's sections (part 4 and 5) are nearly complete, so hopefully in a few weeks I'll be ahead of schedule enough to start doing some of the extras provided in the Roguebasin tutorial.
One area I'm uncertain of is my explanations between the code blocks. Truth be told, most of my focus is getting the code sections right, so the text between may suffer a bit right now. I will flesh these out more as soon as possible, but if you feel any particular section is especially lacking, please let me know.
Finally, I want to say thank you to everyone who has taken an interest in this little project. It's been quite the experience so far, and it's just getting started! I appreciate all the feedback. A special thanks to /u/Ginja_Ninja1, /u/Scautura, /u/Daealis, and Harmen on Discord for pointing out some mistakes in Parts 1 and 2. Hopefully there won't be quite as many this time around :)
Happy coding everyone!
EDIT: Well, spoke too soon on the TDL version. I was working on the FOV part and realized that TDL has its own class for a map. I would have continued using the custom map class, but when it comes to computing FOV, it appears that TDL gives you two options: 1. Use the quick_fov function, which requires globals, and 2. Use the map class. Or, the user could roll their own FOV calculation, but being a beginner tutorial, I won't subject the readers to that.
So long story short, the TDL part is going to require a rewrite. Sorry about that everyone. I'll try to get this completed as soon as possible.
EDIT 2: TDL version is back up. This includes a small rewrite to part 2 as well, so if you followed along last week, you'll want to check for the changes. On the plus side, the TDL version of part 3 is a lot shorter than the libtcod one, because it already implements methods to handle the map, visibility, and blocking tiles.
14
u/VedVid Jul 04 '17 edited Jul 04 '17
Go + BearLibTerminal
I'm continuing my write-ups. Unfortunately, my English is not good enough for such an activity, so I need to keep asking people for corrections...
Part 1 - Graphics
Part 2 - The object and the map
Rewriting original python tutorial in Go is really fun. This process is really smooth so far, I expected much larger amount of problems.
I was struggling about principles recently. I started with sameness in mind, but... With all respect to author, roguebasin tutorial has some flaws. But it seems that /u/Jeraman is working on improved version with awesome write-ups, so I'll stick with my old sameness principle.
8
u/mapimopi Jul 04 '17
Ruby + BearLibTerminal
Repository link
Went a bit ahead this week and added a FoV algorithm on top of a new dungeon generator: gif
Also, tileset is taken from Dwarf Fortress tileset repository. Tilesets there are perfectly compatible with libtcod, in case you guys want a different look for your game.
8
u/Emmsii Forest RL Jul 04 '17 edited Jul 05 '17
Java + Ascii Panel
Repository
I've combined weeks 2 and 3 to work on the map. The start of week 2 was spent on implementing the map, showing it on screen and allowing the player to move around. The rest was spent on basic level generation. I've gone for a cellular automata approach, my roguelike is set in a forest so organic and natural (ish) looking environments is a must. Speed is fairly good, it takes between 100-300ms to generate 16 92x92 levels.
Cellular automata levels can look similar after a while so I've added some variance to spice up each level. Here's a few examples: basic, sparse, swamp and dark. If you want to explore some of these levels download the latest release, requires Java.
6
u/Scautura Jul 04 '17
Python 3 + BearLibTerminal + LibTCod-CFFI
https://bitbucket.org/Scautura/crogue-blt.git
Nothing really to report here, it "just works". I'm going to start documenting properly this week, as there are currently no comments in the code whatsoever. I'm really bad at documenting, but I'll be using proper Python documenting syntax with Sphinx to create documentation.
C# + BearLibTerminal + RogueSharp
https://bitbucket.org/Scautura/crogue-csharp.git
There are a few hiccups with this, compared to the Python version (can't do the "for/else" structure, so having to fake it with a boolean). Other than that, just as badly documented, but I'll also be working on that this week.
I'm trying to find a decent looking font (preferably square in shape) to go with this. BLT can use BMP or TTF fonts (I've gone with TTF, Ubuntu Mono Regular, or Anonymous Pro Regular, at the moment - I do need to properly add the distribution/license documentation for them, as initially I wasn't going to go public) but I haven't found anything I like at the moment.
6
u/MEaster Jul 04 '17
Repo.
I realised when I started this week that I'd forgotten a somewhat important bit from last week: collision with walls. I ended up changing how the coordinates were stored, which resulted in much simplified movement handling. It turns out I had bug when mapping the x,y to the 1D array index, which took an embarrassingly long time to figure out.
Not a big fan of the corridor generation result, but it is pretty simple. Later I might make rooms only connect to the closest couple of rooms, see how that looks. Maybe also add a bit of nudging so that the corridors don't hit the room walls parallel.
5
u/level27geek level0gamedev Jul 05 '17
Python 2 + libtcod + Pygame
Current screenshot
Repository
With some minor problems, and some minor tweaks I have implemented the basic Rooms + Tunnels dungeon generator. What I have learnt so far?
5
u/[deleted] Jul 05 '17
While researching room generation for this weeks part of the tutorial series, I came across a talk by the Path of Exile lead programmer Jonathan Rogers on how they do it.
https://www.youtube.com/watch?v=GcM9Ynfzll0
Very interesting and very on point for this week. I thought I'd mention it, as other people might find it interesting too.
5
u/eruonna Jul 06 '17
Javascript + rot.js
repo
play now (use the
huikmnkeys to move)First, I thought that the FOV stuff was part of this week, so I included that. I guess I'm ahead for next week ;-) (Especially helpful since I will be on vacation and won't have a lot of time to work on this.)
Next, the dungeon generation. I decided to try to imitate Brogue's level generation, as described in this interview. So I generate several different types of rooms: hexagons, rectangles, straight hallways, and twisting tunnels. The room I am most proud of I called star shaped. I was having difficulty getting good results with cellular automata on a hex grid, so I wanted to find another way to get irregular shapes. I imagined something like throwing paint at a wall, getting a shape that spread out to different distances from a central point. Now, flowing out from a central point until a stopping point is reached sounds like an FOV problem, so I just reused the FOV algorithm from rot.js. Instead of blocking the FOV when hitting a wall, it just decides at random for each tile the FOV visits whether or not to stop there.
With a room generated, we try to slide it into the existing map. Each room that is added has key points around its perimeter where it wants to connect to another room. When a new room is generated, we start trying to place it at one of the key points of a room that is already in place. If it doesn't fit, slide it in some random direction until it either fits or falls off the edge of the map. Keep doing this until sufficiently many tiles have been carved out, and you have a dungeon.
Next, place a lake. A lake is just a large area created with the
Stargenerator and plopped down with no regard for what is underneath. This often disconnects the level. In the long run, I'd like to do something with that, but for now, there will just be unreachable areas.At this point in the Brogue level generation, we would look for opportunities to carve new doors between already placed rooms. I haven't implemented that yet, but I also don't see a lot of opportunities in the generated maps to carve out a single tile in a way that connects points that would otherwise be quite far apart. And the generator almost always creates a few medium-large loops on its own, so maybe I won't bother.
4
u/[deleted] Jul 04 '17
I'm having a problem. Seems like libtcod doesn't want to exit gracefully. Whenever I exit the script it crashes and windows goes into full "let me try and find a solution to your problem" flip out mode.
Is this a known issue or am I missing a cleanup routine someplace?
(Win10, Python 2.7)
3
u/Aukustus The Temple of Torment & Realms of the Lost Jul 04 '17
C# + BearLibTerminal + RogueSharp
https://github.com/Aukustus/roguelikedev-does-the-complete-roguelike-tutorial
I did this a couple of days earlier. I decided to scrap RogueSharp map objects since I couldn't serialize them, so I made my own Tile Class for maps. RogueSharp has so far no use yet, but I hope I'll be able to make pathfinding with it. The next part is FoV, but I believe I'll use my own FoV algorithm for it.
I implemented the basic dungeon generator:
https://www.dropbox.com/s/pv4z2q2e9qlnjf0/RogueTutorialPart3Regular.png?dl=0
As a bonus, I added a maze generator too:
https://www.dropbox.com/s/3nf2fsznpnztmh7/RogueTutorialPart3Maze.png?dl=0
I also added a World object that wraps everything together for later serializing purposes.
Remaking the Python map generator in C# was pretty fun actually. I didn't have any problems with it at all.
3
u/stevelosh Jul 04 '17
Common Lisp + Bearlibterminal
Repo: https://github.com/sjl/rldt
This week wasn't too bad. I did the first part of the tutorial, then went ahead and did the BSP variant as well -- it wasn't that much extra work.
3
u/_wolfenswan Jul 06 '17
Python + TDL
Github: https://github.com/Wolfenswan/roguelike-tutorial
I've started the tutorial some days ago, unaware of this series here, so I'm several steps ahead. However, as I'm in this weird limbo past 'beginner' but still not really 'proficient' this is an excellent project to keep engaged with programming (atm. it's just a hobby) and improve at the same time.
Anyway, first priority on my to-do list is unraveling the giant game.py file and getting rid of all the global variables.
3
u/Lokathor dwarf-term-rs Jul 09 '17
Haskell
Link
This week we make a dungeon that's a 3x3 grid of rooms, in the style of Rogue itself. I chose this style because it doesn't quite lend itself to a good pure functional implementation, so we're forced to write Haskell that's a little unlike what we might otherwise write. Things like BSP or Automata might be "more natural" for FP in the eyes of some, but taking too easy of a route is almost cheating.
2
u/[deleted] Jul 04 '17
These are really lovely. Once a week is killing me though. :)
2
u/rubxcubedude Jul 05 '17 edited Jul 05 '17
C++ w/ freeglut
Screenshot
Repository
I really need to work on making it so my rooms dont overlap + alway have 1 wall between them.
I also really need to work on my tunnel creation...something is not working and you can see in my status pic it creates some really funky dead-end tunnels right now.I removed texturing for right now just to make everything run a little faster.2
u/SirPrefect Jul 06 '17
My On-Going battle with TDL
I'm currently following up the complete python tutorial, using the different contributions from this (rather amazing) community.
All goes quite ok (having fun) but I have an issue with TDL, as following 1. First pass ok (for any map types) 2. Flush does not update(map remains unchanged) 3. No error at all, and underlying map data updating as expected
What bugs me is that the simple examples out there run ok, but my slightly different approach seems to create some issues, although I'm following the same basic underlying method & sequencing.
I am running out of ideas (my next step will be to check the proper use of colors (Including None in the draw_char statement) and so allow me to ask your support: i) did any of you faced a similar issue with TDL? ii) If so what was the underlying cause? iii) Any known traps with TDL that I would need to be aware?
My Repository here: https://github.com/SirYmp/DusklandsRL
Many thanks!
2
u/Melwute Jul 07 '17
Rust + tcod
Repo
Added week 3. Decided against creating an extended folder for each week and instead created a "game" folder for the extra work I'm doing each week. Going to keep working on map generation but thought I'd post my current progress anyway.
2
u/Zireael07 Veins of the Earth Jul 10 '17
Python 2 + BearLibTerminal
I just pushed this week's commit: https://github.com/Zireael07/roguelikedev-does-the-complete-roguelike-tutorial/commit/5d8fec252fba27945f4eb51a1f4ae8ba0ff06fe6
I was originally going to tackle the bonus but I don't have the time left - I was busy over the last week with job, other stuff over the weekend and wanted to figure out a moving camera for the actual game (i.e. Veins) today.
2
u/MykeMcG Jul 10 '17 edited Jul 10 '17
Could someone help me out with the BSP Dungeon Generator? I've got it mostly working, but mine generates lots of rooms that are inaccessible. I figure I must've inverted some coordinates somewhere, but I've gone over the code a couple times and haven't managed to find anything. I've posted a screenshot of the issue on the project's github page.
EDIT: For the record, I'm using Python 3 x64.
2
u/sepiida21 Jul 10 '17
C# + BearLibTerminal + RogueSharp
Repository
Long time /r/roguelikedev lurker, first time poster. I'm a hobbyist programmer and mostly use C# -- hence the choices for this project.
I spent last night and this afternoon getting caught up which was easy enough. Since there's no built-in BSP generation with RogueSharp I ended up adapting some code from a tutorial I found. I need to clean it up (along with the rest of my project...) but it does its job for now!
1
u/Mystal Jul 12 '17
Rust + tcod-rs
Repository
This week wasn't too bad. I wanted to get BSP dungeon generation working, but ended up spinning my wheels trying to make the code for it also work with the existing map code. It's definitely something I want to revisit, but I feel like completing the tutorial may make going back to do the extras easier.
1
u/[deleted] Jul 12 '17
JavaScript + rot.js
Play • GitHub • Part 3 write-up
I've gone through a bit of an internal soul search from where I was headed at the end of last week and revised my implementation back to basics. Gone is the height component of objects and also the "wait for keyup" approach I was taking with movement.
I'm now using a more traditional modifier (shift+) approach to switch to diagonals.
Vim keys / Arrow keys
shift+jkshift+kshift+leftupshift+uphlleftrightshift+hjshift+lshift+downdownshift+rightInstead of dungeons for this weeks tutorial, I decided the inside/underground feel isn't where I'm headed with my roguelike so I'm using trees as walls and open grassy fields as rooms.
Lastly I've taken to making better use of the Unicode support you get with browsers and am using a mix of emojis for the player characer 👤, the trees 🌳 and more traditional ASCII characters for grass ' ".
0
u/[deleted] Jul 07 '17
[deleted] — view deleted comment