r/roguelikedev • u/aaron_ds Robinson • Jun 25 '19
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. :)
2
u/Hexxodus Jun 26 '19
Will these tutorials disappear after the weeks are done or will I be able to go back and look at them in the future?
20
u/maetl Jun 25 '19
I’ve started going through the steps in (mostly) plain JavaScript and writing up tutorial docs as I go. Part 0 and Part 1 are done. Will be working through Part 2 and Part 3 this week if I don’t run out of time.
I have a couple of goals here. The main goal is to end up with a reasonably well organised template codebase that is easy to adapt for new projects in future. Another motivation is to tidy up a bunch of loose generative code and algorithm implementations I have lying around and get various library parts and API concepts tidied up, organised and documented, which again is useful for adapting to future projects, events like 7DRL, Procjam, etc.
I’m finding that following the tutorial and writing as I go is a great way to me stay focused and forcing myself to explain each decision as if to a beginner really helps with clarity and thinking about how APIs should work.
Can’t promise that any of this is going to be useful to anyone else, but if it is, that’s an added bonus. It’s all MIT licensed so if any of the content is usable for adapting to a ROT.js/TypeScript tutorial, feel free to grab any bits you need as a starting point for rewriting. That would be amazing.
15
u/Kyzrati Cogmind | mastodon.gamedev.place/@Kyzrati Jun 25 '19 edited Jun 26 '19
Congratulations, so far there are now
5667 repos in this year's directory, a new record :DThe event gets bigger every year! (new languages, too!) Also /u/maetl and /u/nicksmaddog have started new tutorials in JavaScript and Common Lisp.
I'll be adding screenshots more towards the end for those who share them, but do share progress along the way as the content starts going in :)
15
u/Skaruts Jun 25 '19 edited Jun 25 '19
Last week I had no clue where I was going with this. I just started mindlessly following the tutorial and ended up with a 1:1 reproduction of it. All I knew was I wanted to see if I could get somewhere using Nim and libtcod. That was my initial motivation, since I've been enjoying this language quite a lot.
As I was reading about all the ways one can generate maps, I stumbled on images of cave generations that inspired me. I ended up deviating quite a bit from the tutorial with my map generation. I played around with a cellular automata, twisted the universal constants around and I ended up with a forest. I turned rocks into trees!
That forest seemed like a good place to tuck in some huts and shacks into those cozy corners, so I went along with that idea, messed around with it in REXPaint and I quite liked the outcome. So I've been trying to make it real. So far the generation is abysmally simple, I just create the forest, randomize a few houses (rectangles), randomly throw them a fake door, and slap them on top of the forest. Deforestationly simple. The future inhabitants aren't pleased. Some of them can't get to their houses or through their doors, so I got to work on that.
I also added a few extra bits, like random oak trees (or whatever they are), and grass in every floor tile that has a tree next to it (and sprinkled some random grass everywhere else).
I still have no clue where I'm going with this, but I am enjoying it. I'm sort of doing a stream of consciousness kind of thing. Sort of. Maybe I will bring life to this forest. Or maybe the forest in haunted... Or maybe both. Maybe I'll try to generate different kinds of villages, using different algorithms.
I was just now reminded by the main post here that I have all those nice FAQ Friday posts to take a good look at once again.
Anyone interested can find the repo here. I deviated from the tutorial a bit in some other code related ways, but I'll still follow the progression of it. And also use the weekly updates as a deadline, and see how I manage to keep on schedule (I never tried that before).
So now I have a few problems. I need:
to move on to parts 4 and 5...EDIT: Actually, I just realized I'm thinking a week ahead. Parts 4 and 5 are for next week. So all is fine.Would be glad to hear about what anyone reading this might think of my ideas below. Or to hear about any better ideas.
For the first one, I guess I can experiment with a suggestion someone made on discord, of generating clusters of houses (somehow), maybe centered around a point of interest (like a well), or agglomerated in some way. Or I may try to make the algorithm favor pointing the doors toward the middle of the map or the town square (which currently doesn't exist).
For the second one, I'm thinking of using an AI to carve paths from door to door (hopefully without hugging walls) after the forest and house are already in place, and then put the whole thing through the smoothing function of the cellular automata again, just to "erode" the paths enough to make them more natural and hopefully blend in with the rest.
Meanwhile, I'll also tinker with the "cave" density to find a nice balance of open areas and natural pathways.
The third one, I haven't even thought much about it. It's not really a pressing matter yet. I think some of the houses (like the inn and the well and the smithy's) will likely be prefabs, if I can figure out how to work with the .xp reader for nim.
14
u/HexDecimal libtcod maintainer | mastodon.gamedev.place/@HexDecimal Jun 25 '19
Something I'm going try to do is avoid using libtcod's Map object. I'll also avoid making the tutorials
Tileclass. The tutorial doesn't do much with the aspect that tiles can have different visual and physical blocking properties so I can get away with representing the map as a single boolean NumPy array.So this:
Becomes:
I use 0 to mean a wall, and 1 to mean an open space. This way the same array can be passed directory to libtcod's algorithms without needing to convert them since 0=opaque and 1=transparent with field-of-view, and 0=blocking and 1=node-with-cost-of-1 with pathfinders.
I've been able to avoid nested for loops with NumPy, this is most important with the rendering code which seemed to be the slowest part of the tutorial when written in Python. Colors act as a 1d array rather than a scalar so you'll need to add a new axis to the tiles array in order to broadcast them together.
With dungeon generation, My rects can return the slice indexes used to address the tiles which they cover. For tunnels I use
tcod.line_wherewhich lets you index a NumPy array with a Bresenham line. With these tricks available I don't need to write thecreate_roomorcreate_tunnelhelper functions.GitHub repository - Python 3 / python-tcod+numpy
13
u/thebracket Jun 25 '19
Continuing to learn Rust by implementing the tutorial and the bits of
libtcodthat I need!Here is the git repo: Rusty Roguelike. If you have any interest in Rust, feel free to crib whatever you like from it. I'm a newbie to the language, so it's probably not great, idiomatic, or etc.
I've gone quite a bit further than part 2 (I'm in part 6 at time of writing), but if you browse to this commit, it's right at the end of week 2 with a bit of week 3 mixed in.
So the map with placement looks like this.
I've also made some significant progress on the library side of things. I figured out enough about traits to reduce the main file boilerplate to:
The key is that gamestate now implements a trait, defined in RLTK:
This is pretty cool. So now, any type that implements that can be passed to the main loop to provide a tick function. The clunky closure/lambda stuff is gone, making for a much cleaner setup. I used the same system to allow the map type to expose some information about the map, without RLTK having to know how the map works; in particular, a
get_available_exitsfunction.On the library side, I've achieved (and will talk about in subsequent weeks as they come up):
Implementing the map for this week was pretty much a 1:1 port of the tutorial. The algorithm was pretty easy to port, no major issues there. I did return a vector or rooms, rather than keep it around - and then iterate the rooms (picking a center point) for mob placement. Mobs are a basic vector. I didn't put the player in the mobs list - so it's not a really generic list at this point (I haven't quite figured out how to do that efficiently in Rust, yet).
12
u/iamgabrielma Ad Iterum on Steam Jun 25 '19
I'm doing this in C# and Unity, at the moment I'm around the part 6-7 of the python tutorial but I have deviated here and there in order to make it work properly. Some .gifs:
I'm also publishing a weekly post that fits our roguelikedev schedule about how I'm doing these changes, parts 1of13 and 2of13 already published.
I have used a drunken walk algorithm for my levels, as I wanted to get a cave-effect, that I've written from zero, I'll publish soon (within this week) how I went about this, some images of how they look like:
7
u/[deleted] Jun 25 '19
My project is coming along well. I finished Parts 0/1 quickly and then converted the code to use the newer python-tcod APIs. I spent quite a few hours this week on genre research, that is playing various roguelikes to familiarize myself with how they work and trying to formulate a better idea of what my final scope/deliverable will look like.
I had a little free time this weekend so I jumped ahead to Part 2 and afterwards spent a couple hours working on different terrain types, symbols and colors. Here is a screenshot of my ugly terrain testing map: https://i.imgur.com/UHDrIrZ.png
My next task is to implement interactive map objects like doors and teleporters.
Then I'm going to spend the rest of the week working on the map generator.
Github: https://github.com/hufflazon/roguelikedev2019
7
u/Viol53 Jun 25 '19
So I actually got these two finished early (I imagine a lot of people might have, the first two parts aren't very long). I didn't want to get too far ahead though, so I decided I'd take a look at other map generation algorithms.
I have a very rough idea of what I'd like to do on top of the tutorial, so I know that I want a more 'natural', cave-like look to the map, instead of the room-by-room approach.
To that end I tried both random walk and cellular automata. I'm definitely liking the automata method more right now, but I'd love to hear what other people think. Any other algorithms or techniques you've run into that end up with organic looking caves?
7
u/[deleted] Jun 25 '19
RoveR: Week 2
RoveR is a roguelike about a planetary rover created using R and the package Shiny.
Week 2 brings tile collision, a non-player entity and a temporary 'dungeon' for exploring. Level generation is simple but functional, and will need to be revisited. My repo for anyone who is interested in following along with RoveR as I work through the tutorials. You can play my most recent deployment. Performance of the hosted demo is just OK. Press any key to start; WASD to move.
7
u/Fagsquamntch Jun 25 '19
I forgot to post last week, but I've been following along and am somewhat ahead. I've been working with Ruby and BearLibTerminal, and basically had no problems until I reached FoV, which is in part 4.
Libtcod has its own FoV algorithm, but BearLibTerminal does not. While I found a Ruby based one online, I decided I would write my own so that I could learn some stuff rather than blindly converting Python code into Ruby code (which is what I've been doing). However, I didn't fully really realize what this entailed - turns out FoV is somewhat complicated. Where I am now is that I have successfully made circles instead of just rectangles for rooms, and my map generator detects the intersection of circles and rectangles correctly, so I now have two types of rooms during mag generation. This has led to a significantly better understanding of drawing shapes on a 2D tile matrix, which is what I needed to understand how to design a circular FoV.
So now I should probably go ahead and make some kind of Fov algorithm, and I now understand the code for the ones I looked at online, so that's a good sign. The problem is there is no perfect FoV algorithm. This Roguebasin post explains why quite well. However, I've decided to go with Shadowcasting for this tutorial.
Another thought is the tunnel creation is quite ugly in this tutorial, with often multiple parallel lines, intersecting tunnels, and tunnels cutting through rooms other than the ones they are attempting to create. A quick google search suggested using a pathfinding algorithm to generate tunnels, so I'm very tempted to learn how to do that as well, but I think I'll hold off until after FoV so I am at least keeping in pace with the tutorial.
7
u/EsotericRogue Jun 25 '19 edited Jun 26 '19
Today's livestream will be at 3pm EDT (19:00 UTC-4).
RLDevRLTut2019 is written in Python using the Kivy GUI and select roguelike routines from libtcod.
Week 1 in Review
Week 2 in Preview
See you there!
Week 2 in Progress
7
u/TorvaldtheMad Jun 25 '19
Not gonna lie, I kind of really like Rust. It's a bit weird to go back and forth between Rust (for fun) and Python (for work) but I actually quite enjoy "arguing" with the Rust compiler. Something about the verbosity of the language and the careful deliberation with which it applies its logic really speaks to me.
That said, I'm actually up to the end of Part 5 with the current commit on the Repo. I've got basic player/enemy turns and I've implemented the move_or_attack functionality that searches and finds a target at the destination, so next is slapping some numbers on it and making things die. xD
Because I'm in Rust, and I kind of got lost in the weeds when I tried to go off the tutorial too early (what with the borrowing and checking and whatnot), I've decided just to follow the tutorial very closely until the end, and then make my adjustments at the end. I do want to figure out how to add a seed to the mapgen RNG--it'd be nice to have reproducible maps for testing, especially because my hope is to make this a complete (albeit small) playable game when I'm done.
6
u/gLeviRodriguez Jun 25 '19
Progress went well for this week. Deviated from the tutorial a bit (aside from putting everything in modules). I’m doing a lot of C# code at work currently, and I think that’s affecting my code a bit (it’s not functional enough for Rust, I think).
In any case, here’s where I deviated from the Rust tutorial:
Aside from the above, I also took time this week to run fmt and clippy on my code to fix style issues and inefficient coding patterns. Overall, things are looking good.
GitHub: https://github.com/GLeviRodriguez/rusty_roguelike
6
u/VedVid Jun 25 '19 edited Jun 25 '19
Pony + BearLibTerminal gitlab github
It is my first bigger project in Pony. Or rather - it is my first experience with Pony, except Fibonacci, FizzBuzz and Hello World.
Due to the simplicity of the parts 0 & 1, I have more to tell about language than the game itself.
Impressions? Rather a small language, very consistent, with great FFI - writing BLT wrapped was a very pleasant experience. I liked it that much I started to write libtcod bindings, but... I was using this library for a long time and never realized how big under the hood libtcod is. Maaaaaybe I'll finish libtcod wrapper in the future, but it's definitely not a priority.
Pony has some pretty unique features - like capabilities. I definitely need to learn more about it as currently I'm using only ref to mute things :D On the other hand, some decisions are kinda strange IMO: garbage collector is triggered only upon switching actor (I guess it may make a sense in language focused on concurrency, but I have no experience in that field); almost every action is performed like method call (even array indexing is array.(index), not array[index]), but taking address of object is performed by keyword addressof (for example, addressof player).
The problem is documentation, and I think it is the reason why Pony won't get adaptation. You may think "Pony is in infancy, they need time, and priority is bug fixing" etc. but I won't agree. Pony is a surprisingly mature language for a project that started in 2012 developed entirely by the community. There is a tutorial, but not very helpful. A lot of words, much fewer facts. It's more like talk you'd give your friend plus (a) few examples. I'd expect at least kind of syntax overview, but to learn how to index arrays I had to wade through the standard library documentation. I won't lie, it's kind of adventure :) I like to tinker with obscure stuff, but even languages like Min, Gluon, Janet, Elvish has much better docs (disclaimer: it doesn't mean that their documentation is truly good. But still, better than Pony).
In the end, I'm not pleased with the code I wrote. But on the other hand, I don't care that much. For a long time, I wanted to be a professional programmer. Last week it turned out that I will follow a different career path, so now... I don't know, it's not burnout per se, but I want to get things done, and I don't have a strong motivation to polish solutions and focus on clean code.
edit: typos fixed
6
u/zwilf Jun 25 '19
Progress is going well. As I said last week, I'm new to Python, so I'm using the tutorial to learn. I'm working ahead with the intent of adding things and making tweaks at the end. I've just finished up Part 7, and I haven't encountered any major hurdles yet (the tutorial is pretty darn solid). If anyone else is using MacOS or PyCharm and has questions, feel free to ask. Here's my repo.
6
u/tpseven Jun 26 '19
Week 2 with Purescript | Repository & Demo
Second week was a bit tricky. Part 2 done via pattern matching, this is more common way in functional programming rather than adding attributes to tile structure. This was easy.
Part 3 on the contrary requires to change a level structure, and it's not just plain mapping because generator uses its own intermediate structures. Moreover, some random values required during generation. I decided to leave it pure, so I'm using pseudo random linear congruential generator algorithm. And to make code clean it's wrapped in State Monad. Dungeon generator takes a seed, and on each random invocation it also generates new seed which will be used in next random call.
5
u/PTrefall Jun 25 '19
I'm progressing alright with my implementation in Unity and Fluid HTN.
My focus so far has been to set up some basic dungeon generation using my planner, and a very basic AI using the planner as well.
So far the dungeon planner can place rooms with a size range, random selection of sub-branches, repeat a sequence until a condition is met, spawn the player and spawn npcs inside the last room added, with conditional rules. I also added a decoration option, allowing me to add hand-drawn tile data to the last room added. I can also set the theme for a sequence, and control which direction a sequence is built in (with a random option)
I separated the character and character controller. So the player and character AI just have a separate controller implementation while the character itself handles the input.
So far the character planner can move towards the enemy target and hit the target when in melee range. The npc can lose sight of the enemy. Sight sensor is used to detect when enemies are in range. The idea is to add more sensors, using different rules of detecting enemies.
I also added a stat system that allow me to add stats to each npc via data. So far I've got health and sight stats. Stats will support modifiers.
I also experimented a bit with the new 2d renderer in 2019.2 and the latest light weight render pipeline, but it's a little too early to adopt to it, as it broke the pixel perfect camera component.
Video Github
5
u/Beidah Jun 25 '19
Started working on my own written in Rust. I'm using tcod for the terminal rendering and specs for an ECS framework. Getting them to work together actually became a huge problem, because using tcod's
wait_for_keypressfunction in one of specs systems would cause the whole thing to freeze up. Luckily, putting the input system in with spec'swith_thread_localfunction seemed to getting it working. I guess having a blocking function in a system isn't something specs really liked.Currently, for map generation, I'm just using one of tcod's noise functions. I might play around with it to find something that makes something more natural looking. I'll have to read up a bit more on different map generations to find one I like. Guess we'll see.
Gitlab repo here. And a Github repo over here.
5
u/itsnotxhad Jun 28 '19
I ended up working ahead this week and finishing the tutorial. I'm trying to decide where to go with it next, but I had to share my favorite bug: I somehow managed to mess up the item pickup code to the point where grabbing an item put the player in the player's inventory. The player graphic would even disappear from the screen (though I could still walk around and attack!), although when I opened my inventory and tried to use myself, that was where the engine drew the line.
4
u/conswess Jun 25 '19
It may look like I'm starting late, but actually I started early. In fact I finished the tutorial and spent the last few days re-writing parts of it. Starting with the depreciation warnings. I didn't understand how I was supposed to use the event.dispatch class because it doesn't return any values, so I used event.getattr instead. Then I ended up re-writing most of the main game loop and moved on from there.
In a few weeks I'll probably have a game that's identical to the tutorial one with completely different code. Then maybe I'll start writing my own game.
4
u/dafu RetroBlit Jun 25 '19
I've completed this week ahead of time. I'll be away one of the weeks so I'm trying to get ahead a bit. This time I took the time to share a repo of my work:
https://gitlab.com/mcietwie/rbrl
I'm including a markdown file in the repo that talks a bit more about the project and keeps a diary of weekly progress screenshots, as well as individual code branches for each week so you can scroll back to previous weeks if you'd like to!
As before you can play the WebGL build here: https://pixeltrollgames.itch.io/rl-tut
I'm following the tutorial using Unity & RetroBlit framework (C#), so I have to adapt the tutorial as I go. In general the changes have not been significant so far, and I'm trying to stick to the spirit of the tutorial as much as possible.
I am doing my game with pixel art however, 16x16 tiles rendered at 2x zoom, so for this week I could not fit as much of the map on the screen as the tutorial can. To get around this I had to add a camera that follows the player around as he moves through the rudimentary dungeon!
It also irked me that at the end of this tutorial you are left with an NPC that could be embedded into a wall, so I randomly pick a non-wall position for him.
4
u/leafdj Jun 25 '19
Our game is... interesting so far, because we're focusing on making an Idle Rogue game, where you gear up your adventurers and then send them into the dungeon without controlling them directly. As such we're off the tutorials, but so far we have map generation hooked into the Unity Tilemap system, and have some backend services hooked up and ready to start handling offline gameplay. Will try and share some visuals and such when the pieces come together a bit more :)
Also: with u/aaron_ds' permission I created an itch.io jam page for this jam. Feel free to upload your WIP games there if you want another place to share them!
https://itch.io/jam/roguelike
4
u/nicksmaddog Jun 26 '19 edited Jun 26 '19
I've been working on getting a Common Lisp tutorial using BearLibTerminal together for this. I've got Part 0 and Part 1 posted so far. I'm currently working on parts 2 and 3. My goal is to get caught up and have 4 and 5 ready for next weeks post.
You can find the Git repository for my code here: https://github.com/nwforrer/cl-rltut
4
u/KarbonKitty Rogue Sheep dev Jun 26 '19 edited Aug 07 '19
Burglar of Babylon - TypeScript + ROT.js
Play here || Repo here || Template repo
I've finished parts 2 and 3 - well, I'm actually keep my map static for the time being, so the part 3 was more or less bypassed, but the simple generation methods aren't all that well suited for the burglary roguelike that mostly will take place inside buildings. Unfortunately, procedural generation of floor plans is relatively complex topic, and I want to leave it for later. This coincides well with the fact that I had rather limited amount of time to work on the game this week, and plenty of it was consumed by changes to input/movement model.
So, there is now an NPC and a player on a floor full of LiviCubes™, and they can move around a bit. Next part should be relatively straightforward, thanks to the fact that ROT.js has a FoV implementation baked in, so I might go back to my main loop and try to recreate it using async/await feature instead of (deprecated) ROT.js Engine module.
BTW: I'm tagging end of each part in the repository, for ease of reference. I'm also willing to try and help anybody with C# or TypeScript related questions. :)
4
u/[deleted] Jun 26 '19
I actually went through the tutorial with Rust and tcod a couple weeks ago, was delighted, and promptly spent the next couple of weeks Second-System'ing myself into oblivion over and over again, getting less far with each successive attempt. But learning a lot along the way.
With this iteration, I'm taking a bit of a different approach. I'm working my way through the tutorial, but rewriting everything as I go rather than waiting to refactor later. Obviously this is very slow going, and I haven't pushed all of my recent commits to GitHub yet (should you happen to look)...
As an example, the past couple days I've been working on splitting the input -> movement stuff into input, which gets translated into commands based on the input "domain", which get mapped to an action, which has a corresponding set of rules that can transform or cancel that action altogether (e.g. map bounds checking on movement). With all that in place, I have a black screen where I can move my
@around. Small victories.I'm using Specs to manage most of the stuff, but I'm struggling a bit with some of the approach it represents. I'm definitely a simple-minded programmer best suited to looping through arrays and doing the same damned thing to every damned thing at each damned index, and rendering a tile map that isn't really a tile map by showing only the differences is a new experience. I haven't integrated this with the input -> command -> action system yet, although I think that will be straightforward. [I'm not using Specs idiomatically right now, so don't be perturbed if you look at my code and think "wtf is this idiot doing?" I'll get to it.]
Next steps are the tile-map-that-isn't-a-tile-map, or more to the point trying to make that performant and expressive and so forth in all of the situations I need, and monsters, which should be trivial since I'm trying to follow the player-character-is-just-like-everything-else approach. The main thing there is I want the thing where everyone can take turns at different rates, etc, which of course complicates the game loop somewhat.
I think, once I get this stuff figured out, that I'll have a highly scalable, well-organized project that can be extended basically infinitely in all directions.
4
u/Harionago Jun 26 '19
I normally develop for Unity3D, I haven't ever really tried anything in Python before, so my knowledge in programming extends as far as C# and a bit of Javascript. So this is all very new to me.
I have followed the tutorial closely. The only thing I have done differently is that I have modified the tile class to distinguish between tunnel/corridor tiles and room tiles. So that means I can colour the corridor tiles differently! Which is easier for debugging later down the line.
I will eventually have a corridor class that inherits from the tile class to separate things a bit more (I don't even know if you can do that in python yet xD)
https://imgur.com/z2hVeqv
3
u/-gim- Jun 25 '19 edited Jun 28 '19
Seems I accidentally did some of part 2 already, good I'll have more time to focus on part 3. In my map will only contain information about underlying tiles and sight will be blocked by elements, so I guess it's time to add some elements.
So instead of playing with world, I played with beautifying map, results are somewhat lovely, but I should probably focus ^
github || gallery ||
3
u/pkzeroh Jun 25 '19
Hello! I'm a complete begginer on python and programming in general and I decided to follow this tutorial so I could learn a little bit here and there. My repo is here (I'm a total newbie on git/github too so I don't know if I'm doing things the right way). The only difference from the tutorial so far is that I've changed the solid color graphics to tiles using the tutorial from roguebasin.
I'm a little bit ahead of week 2 due to pure and total anxiety haha
I have some ideas as to what I want my game to become but right now I'll just focus on following the tutorial. I'm not even sure how I'm going to implement most of my ideias, but more on that later.
This tutorial has REALLY helped me understand more of OOP in python, so far I'm really surprised of how smoothly things work with classes and how much we can do with them.
3
u/qu4ternion Jun 25 '19
I'm continuing in C++ and trying to aggressively modularize everything so I can pull some pieces out for use in a a game engine for later games. I've deviated a bit from the tutorial in terms of map generation algorithms, as for my game I want the maps to look like city blocks rather than the traditional "dungeon with lots of rooms", and I'm rather proud of what I've come up with.
My map layout currently has each "floor" as its own block, with entrances/exits on opposite edges of the map rather than randomly in the middle (to give it the "walking through the city from one block to another" feel). The recursive algorithm I use to generate the maps is a homebrew similar to BSP but works in thirds. I start with the whole floor as the ROI, then use the current recursion depth to decide whether to terminate or not (higher depth = more likely to terminate). If it decides to terminate, it just populates that region with buildings. If it decides to recurse, it picks either a horizontal or vertical split based on the aspect ratio of the region, then draws a "road" through the middle third (although the road can be slightly wider or narrower than a third) and then recurses on the two regions on either side of the newly drawn road. This way you get sort of rectangular paths branching off a main one through the middle for a "square-y" feel without being too regular.
3
u/Chronos_v2 Jun 26 '19 edited Jun 26 '19
Hey there! I'm getting in a little late (just saw the Twitter post today) but I've begun following the tocd tutorial. Starting out following to the letter (as some roguelike functions, such as map generation, are completely foreign to me) but I plan on doing my usual thing and adding stuff where I think it'd be cool. So far I've finished parts 0 & 1, and am about to start on Part 2 to catch up.
Thanks for sharing these! Understanding these concepts will go a long way in improving my game development skills.
Edit: Just finished this week's parts. So far the only thing I've branched off of is diagonal movement, but I'm hoping I can really get creative in the gameplay portion.
3
u/azureglows Jun 26 '19
I forgot to post on the first week!
This is really my first game I'm really working through. I have experience with development, and have always said I wanted to make a game, so here we go! I'm calling my game (currently) Pixel Gear Rogue. The intention is to make it have some stealth aspects to it and and homage to one of my favorite game series :).
I am making some minor changes but trying to stay within the scope of what has been learned up to that point. For example, I changed the font that is used. I am trying to keep a log of things I have diverged from the main tutorial in the readme. I almost couldn't wait for week 2 to start, but trying to pace myself here.
Anyways, here is my repo link: https://gitlab.com/azureglows/pixel_gear_rogue
3
u/Vertixico Jun 26 '19
Progress is going fine for me. So far I finished up Part 2 with my Java project. (Repo)
I am sticking close to the tutorial for now, but already made some mental (and actual) notes about where stuff is maybe a bit inefficient and should be revisited later on. I am a bit unsure about the write method in AsciiPanel - so far I am not seeing a way of leaving the background "transparent" and keep whatever the tile had set. But that is a thought for later I guess =)
Who else is doing this project with Java?
3
u/Jalexander39 Jun 27 '19
Since my post for last week I've switched over to Love2D and Lua, using the rotLove library. I've already done the libtcod tutorial in the past, so my main goal in this event is to experiment and try something new instead of copying the tutorial verbatim. I also set up a repo on GitLab, which in addition to teaching myself Git, discourages further language hopping :P
So now I'm caught up through part 3, and I currently have no less than three dungeon generators:
3
u/Thunderducky Jun 28 '19
Sorry for the lateness!
This week. I've been working on my map generator
My current version uses the room placement algorithm that's standard to the TCOD tutorial, except I also throw ellipses on top of it in order to make it get things that feel like caves
How the game starts After exploring for a little bit
So I tried starting with a few different algorithms, ultimately getting the furthest with Binary Space Partitioning after following this tutorial.
My map ultimately ended up look like this
The algorithm works by starting with one big rectangle and then randomly subdividing it into smaller pieces Outline of the boxes being generated
Then each of the boxes had rooms placed inside of them and were connected by hallways
Not shown was me trying to read through /u/Kyzrati 's excellent blog posts on the topic. I'm really interested in trying tunneling algorithm, but didn't have as much time to work on in this week as I would like
Hope everyone is having a great week!
Album of all the pictures is here https://imgur.com/a/NGLtnDt
3
u/ashopov Jun 28 '19 edited Jun 30 '19
Phaser-ES6-Webpack, week 2
Repo
Demo
Almost finished with part 2. I've spent a lot of time just playing with Phaser toolbox, and there's a lot of potential for fun features to be added to this project. My primary goal, though, is to finish, so in the interest of avoiding feature creep, right now I'm more or less following the spirit of the tutorial verbatim.
One notable deviation was the creation of (very) simple spritesheet that can be extended later, rather than relying on pure ascii as the tutorial does.
This weekend I plan to finish part 2 and 3, then do any necessary refactoring and code cleanup. A stretch goal is to transcribe my notes into a more readable form for anyone else that would like to try their hand at Phaser development.
Edit - Sunday June 30, 2019: Week 2 is complete!
3
u/theoldestnoob Jun 28 '19 edited Jun 28 '19
I completed the tutorial portion on Tuesday, and thought I was going to spend the rest of the week working on implementing a bunch of different map generation algorithms. Instead, I worked on a BSP algorithm for a little bit, then went back and started messing with the "randomly place non-overlapping rooms and then run corridors to them". I added diagonal hallways and variables to control the ratio of vertical-then-horizontal, horizontal-then-vertical, and diagonal hallways generated. I then added a bit of input handling to repeatedly generate and display new maps and got completely side-tracked and sucked in to learning about graph theory.
I'm now to the point where I generate a map, then generate a graph of that map, which is a collection of: vertices (rooms) which store their space (e.g. a Rectangle object) and know their neighbors; and edges (corridors) which store their space (a list of coordinates of all connected corridor tiles) and know the vertices they are connected to. The "randomly place rooms and corridors" method produces mostly non-k-uniform hypergraphs (edges with >2 nodes, but not all edges have the same number of vertices) that are multi-edge (some vertices have > 1 edge connecting them). At first I just wanted to be able to get a list of vertices so I could set up patrol routes for monsters later on (planning on a sort-of stealth puzzle roguelike after the tutorial), but now I'm interested in coming up with ways to automatically profile and describe arbitrary maps to compare map generation algorithms. If I manage to maintain my interest in the subject long enough to turn out anything usable, I'll do a write-up that describes how I generate the various metrics and what they mean. I'm sure there are practical applications in there somewhere down the line. For now, you can check it out on my repo in the part-3-extra branch. The graph stuff is in map_objects/map_graph.py if anyone wants to check it out, and if you run engine.py you can press "m" to generate a new map, "g" to generate that map's graph, "n" to display all of the vertices, "b" to display all of the edges, and "," (comma) to run a flood-fill vertex neighbor finding algorithm that is inefficient and unneeded but cool to watch (I have debug set to True so it shows the algorithms running).
3
u/godescalc Jun 28 '19 edited Jun 28 '19
So, I've skipped ahead a bit and have got to part 8 (items). Progress:
(1) circular, diamond-shaped rooms, with random colours
(2) I stripped out the game-state stuff from later tutorial sections and replaced it with a time-counter, so as to have actions taking different amounts of time. Then I realised I had to put back all the game-state stuff somehow in order to get inventory management... It seems to work, just about.
(3) HP and energy recover, slowly, over time
(4) Shift+movement keys (arrows, WASD QEZC) runs faster/attacks with more force, at the cost of energy
Repo: https://sourceforge.net/projects/cave-of-rainbows/ - language: Python
3
u/amuletofyendor Jun 28 '19
screen recording and repo
Sticking close to the tutorial so far, with the minor diversion of setting up a PETSCII tile set.
I'm planning on doing some PETSCII art for monster portraits, weapons, title screen etc. Also intelligently rendering the intersection of map walls.
For a theme I'm thinking of a big-game hunter on the moons of Neptune. Like something non-copyright-infringing
fromloosely inspired by the world of Dr. Grordbort.Inspirational F# line of the day:
List.pairwise rooms |> List.iter (joinRooms gameMap rng)3
u/CowFu Jun 29 '19 edited Jul 01 '19
Part 2 is done, going to do part 3 tomorrow. Sticking with it so far!
https://github.com/CowFu/rld_tcod_2019
EDIT: part 3 done too!
2
u/[deleted] Jun 25 '19 edited Jul 30 '19
My Repo
Part 3 is finished as of yesterday, and the game is slowly coming together. I'm thinking of making a few changes to the game's visual style (the colour scheme, etc.) but right now I like using the smiley face to represent the player character instead of the usual "@". In addition, I'd like to look into different algorithms for map generation. The one I'm currently using is basically a reproduction of the tutorial's but it would be fun to perhaps add different room shapes or other features.
2
u/[deleted] Jun 25 '19
Github Repo: Escape The Deepwoods
Blog writeup: Roguelike-dev Adventures 1
I've chosen Edge Chronicles as the setting for my game (favorite books as a kid) I'm going to revolve my core mechanics around companions with some state based AI but for now I really need to dig deep and start learning more proc gen (specifically map generation for cave like structures) Other than that I've settled quite nicely into using tcod. It's been a privilege to have so many people on hand to help.
2
u/dbpc Jun 25 '19
My Repo - C# with SadConsole
So far this is pretty much a duplication of the Python tutorial with minor changes due to the fact that C# is a statically typed language, but this will have to change as I will likely be implementing libtcod's algorithms for FoV in C#. Sure I could use externs to reference libtcod directly, but this honestly sounds more fun and will give me a better understanding of what is going on. Then I will probably be able to make it a standard library for other roguelikes that I make (of which one at least is on the back burner.)
2
u/waz4life Jun 26 '19
i am interested in hearing how people are progressing through these tutorials. I started last Tuesday not knowing Python and finished every single tutorial by Wednesday I think. Would have really liked if the tutorial went into more detail concerning things like storing of the levels, more into different ai systems to push the player, among other things.
I really enjoyed the tutorial I just wish there was more there. Since I felt a little lost after finishing all of the tutorials I decided to try to start recreating one of my favorite roguelikes. It will need a lot of reworking to be done but I'm enjoying the process a lot and once I finish recreating my favorite roguelike I really want to add the things to it that I always wished were there, like an overworld system and even a little more randomization when it comes to item properties a bit like DCSS.
Here is a link to what I have so far.
2
u/Marthusz Jun 26 '19
Week 2 finished! This time I should have all warnings removed (cheated a bit and got the value for the foreground and background tiles channel from HexDecimal's repo because I didn't know what to put there).
I've also been looking for other map generation algorithms because I don't really like the way the corridors look so I'll try to implement this kind of map generator before next week.
2
u/kinglslbob Jun 26 '19
I've been having fun following the python tutorial, I've never touched python before but done c++ and c# before. just finished up part 10 of the tutorial. I've been doing daily post on my twitter of my progress here repo
2
u/billturner Jun 26 '19
I've also started the challenge, and am looking forward to this week's progress. I'm going pretty much straight from the tutorial and using Python and tcod. If there's time, I'd also like to re-write what I can to reduce the deprecation warnings, and maybe even add type hints. We'll see. :) I'm posting updates to github here: roguelike_tcod
2
u/Harionago Jun 26 '19
I wanted to ask a couple of questions. I apologise if this doesn't make sense.
On the second line, you place the @ at player_x and player_y , which is fine. But then you overwrite that by placing ' ' at the same point (at player_x and player_y ) on the final line.
I know that this is to stop the player from ghosting...but since we are in the same loop, shouldn't the last line use the player's previous position instead of the current one? In my head, this should result in a blank console, but it doesn't.
Can someone explain how this works?
Also, what does libtcod.console_blit(con,0,0,screen_width,screen_height,0,0,0) do exactly?
thanks!
2
u/Captain_Tralfaz Jun 26 '19
Hero Party repo
python3, libtcod
developed on a mac with Pycharm
I've made it through the end of tutorial 7 with minimal deviations from the plan:
I'm holding off this week on tutorial 8 to instead focus on some new combat mechanics. I'm going to try implementing with a no-hitpoint system, relying only on cooldowns. The standard "player" will actually be a "Party" (represented of course by an @), and the Party will consist of party members, each with their own type of attack and set of cooldowns.
When the Party gets hit, a random party member not on cooldown will go on cooldown. However, if all members are already on cooldown, a party member will die.
New Party members can be rescued and added to the party (or possibly recruited at town?), but at a cost... as time passes, party members will want to be paid from the group's coffers. A lack of money will cause members to leave the party and strike off on their own looking for more lucrative adventures.
In theory, coins will be points, and those adventuring parties with the most money after (finding the amulet of Yendor? Surviving x dugeon levels?) will go down in history.
2
u/[deleted] Jun 27 '19
Made my way through part 2 and got stopped last night by a bug, Rewrote the class as I'm not exactly sure what I did, and it seemed to fix it. I'll probably launch into part 3 tomorrow as my brain is a little fried and I'm still trying to understand everything. (My python is a bit rusty.) I'll have to go back and comment things a little more fully and also look into those depreciation issues as while it all works, I'd like to future proof it a bit. I'm looking forward to part 3 as I've always wanted to know how the magic is done in procedurally generated dungeons. I'll probably reply to this comment again when I get it running.
2
u/RichardWizdan Jun 27 '19 edited Jun 27 '19
I have finished Part 2, but I somewhat skipped to Part 4 instead of taking care of map generation. For now this project still has no name, as I cannot decide on what I want to achieve (this seems like a common theme judging by other comments). As I am a fan of Warhammer Quest (the original boardgame) I am leaning towards using prefabs as tiles from which the dungeon will be created. The pool of available tiles would have to be big enough to allow the replayability, but that's something I will have to concern myself much later into the project. In general the work is coming along quite well, much better than I initially anticipated.
As I am using GML I had to rework some parts of the tutorial. Although I initially based the map on an array, I switched to GM objects to leverage all the functions for object to obejct interactions (
point_distance,collision_lineetc.). On the surface, i.e. when you launch the project, everything looks quite similar, but I am more confident using the built-in functionalities than forcing python's code into GML.The other change was to swtich from 10x10px tiles to 16x16px. Right now I'm using glyphs to represent the player and the game world, but at some point I would like to use sprites, and for that I fell better to use tiles which have "standard" dimensions.
[Edit] In the end I have implemented the procedurally generated dungeon after all. I will think about prefabs in the future. You can find the code on my Github repo.
2
u/swish014 Jun 27 '19
My C# implementation is going well so far.
I'm using the built-in console API to do all the drawing. That worked fine when it was just moving the initial `@` around the screen. Once I implemented map generation, flicker became a significant issue. I implemented a render-buffer to track which cells changed during each frame, and only redrawing the changed cells made a huge difference. I'd like to implement scrolling at some point so maps can be larger than the screen, and I suspect I'll have to do some additional optimizations at that point.
I've worked ahead a little bit and implemented FOV by porting the rot.js implementation to C#.
I may go back and revisit dungeon generation a bit later this week. Rather than joining the new room to the last generated room, I may try joining it to the closest room, and then dive into some of the resources listed for this week.
There isn't much to see, yet, but I posted a video on youtube, anyway.
Last but not least, thanks to the community here (and especially Kyzrati) for making this such a fun and engaging event.
2
u/codyebberson Jun 27 '19
Typescript + WebGL + WGLT (my pet roguelike library).
Part 2 (diff) was 100% provided by the WGLT library.
Part 3 (diff) was a direct port of the tutorial Python code to TypeScript.
Demo (works in browser on desktop and mobile)
Repo
2
u/-gim- Jun 29 '19
so turned out my house generator idea does not generate nice houses :( https://imgur.com/eLEX8cv any suggestion How I could make nicer houses?
D is/are house door(s). I don't have room doors yet and some of the walls should probably be removed, but that itself won't make it much nicer.
because the results are so-so, right now I think I'll just use it as a bootstrap to make prefabs (that I'll tune manually)
2
u/tehw1n Jun 30 '19
C# and Unity continues on. It seems to be a mix of trying to work with Unity and fighting against it. I like the room and halls style from the tut but the halls script will need and update down the road. FOV is in the next week but has been a huge pain for me. Attempts at shadow casting have not been successful so it currently has ray casting with a quick post processing fix added for some artifacts. There are plenty more that remain but I will just circle back at some point. Through Part 4
2
u/[deleted] Jun 30 '19
Enjoying the tutorial so far. I think I need to step back and stop rushing through this to learn better. I went through parts 2-6 today over 5 hours or so.
Anyway before I spend the rest of the night looking at code. When I died I keep the @ symbol instead of the % that an enemy gets. Is that correct or did I make a mistake somewhere? I can see in the code the dead character should get the same thing as an enemy, but mine isn't.
Thanks!
2
u/Nzen_ Jun 30 '19 edited Jun 30 '19
Maudlin Honey Cetyre satisfies the second and third milestones of the tutorial. It would be nice if I actively avoided corridors that are in each other's wall.
repository of java using java-websocket.
2
u/mattpwest Jun 30 '19
I almost fell out of this project this week due to having to prioritise some work-related training but managed to catch up with parts 2 and 3 of the tutorial tonight. I'm probably setting myself up for future pain, but I am increasingly deviating from the Python TCOD tutorial...
Last week I decided to eliminate all the deprecation warnings from the library. Tonight I attempted a clean-code refactor of the map generation method because I didn't like that it had so many comments or the deeply nested if statements. I also haven't religiously followed along with the tutorial filenames. I hope this will result in a cleaner and more understandable code base, but it might make the upcoming tutorials a bit tougher to follow.
The code is here if anyone wants to take a look. I'd be curious to hear if it is really any clearer than the tutorial itself?
Now that I'm done with that work training course, I hope to get ahead a bit this week, so I can start working on making my roguelike a bit more unique.
2
u/Reflex27 Jul 02 '19
I'm still here. Had a surprise visit from the inlaws and some other family events to take care of this week. When I settled back into the project I came across some syntax issues with my javascript tutorial at Part 4.
This tutorial was created before the ES6 spec was released and uses constructor functions and the prototype object instead of the new Class keyword. My initial thought was to continue and work through the tutorial as written and then return at the end and refactor to the newer Class syntax as a learning exercise.
But I'm hitting a runtime exception where the author's code uses an extend() function to derive one class from another:
My initial google hits suggest that this extend function might be from jQuery and it might be deprecated? I'll do some more reading tomorrow and see if I can get his code to run in my browser. Or maybe I'll just go ahead and convert to the newer ES6 syntax.
2
u/endperform Jul 02 '19
So, I finally found a Go library and I'm going to just go ahead and try it in Go, and forget about Python. I'll probably be perpetually behind, but I'm going to see it through. For anyone else looking for something with Go, have a look at https://github.com/JoelOtter/termloop
2
u/AgentMania Jul 02 '19
A little late posting this, but I have completed week 2! You can find an updated link to my project here.
Construct 3 has (so far) allowed me to move fairly quickly, so I'm still a bit ahead. You can find a full breakdown of things I added on the game page linked above.
Additionally, I've begun charting my progress on Twitter! Not only has this been good for exposure, but the creator of the rot.js plugin that I've been using actually reached out with a fix I needed!
Looking forward to next week! See you all then!
2
u/GeekRampant Jul 03 '19
Missed the deadline by one night :( Oh well, at least everything is working like it should now.
The game itself can be found here on my website. I'm using a cellular automata algorithm since most of it takes place in a forest, but I also have a general "rooms and tunnels" algorithm to create the dungeons, made from following the tutorial. That one will get more use once map-to-map portals are set up. I was hoping to have a BSP generator as well, for the houses/buildings located in the forest, and to use that on specific areas of the map. Alas, it wasn't working in time, but there is this next week...
I don't have a github repo (I should probably do that), so all the source code can be seen via right-click --> view source. It's kinda piggy in some places (had to switch from using screen to all tile coordinates at the last minute), but it plays nicely.
Hopefully the color scheme suggests "haunted forest". Wasted far too much time this week tinkering with fonts and colors and fancy rendering rather than actually making the game -_-
Movement: WASD
Camera zoom: [L] to zoom in, [K] to zoom out
(cracks knuckles) All right, onward to week 3!
1
u/swish014 Jun 27 '19
My C# implementation is going well so far.
I'm using the built-in console API to do all the drawing. That worked fine when it was just moving the initial `@` around the screen. Once I implemented map generation, flicker became a significant issue. I implemented a render-buffer to track which cells changed during each frame, and only redrawing the changed cells made a huge difference. I'd like to implement scrolling at some point so maps can be larger than the screen, and I suspect I'll have to do some additional optimizations at that point.
I've worked ahead a little bit and implemented FOV by porting the rot.js implementation to C#.
I may go back and revisit dungeon generation a bit later this week. Rather than joining the new room to the last generated room, I may try joining it to the closest room, and then dive into some of the resources listed for this week.
There isn't much to see, yet, but I posted a video on youtube, anyway.
Last but not least, thanks to the community here (and especially Kyzrati) for making this such a fun and engaging event.
1
u/gawwo Jun 27 '19
The more I advance with this tutorial the more I think Unity is not made for 2d. At the moment my code is far from perfect, and I'll give it a large refactor during the weekend, but my concern is not the code in itself but the fact that I'm reiventing the wheel. I've now completed step 4 (the field of view) and I had to make everything from scratch (luckily I found a wonderful library from which I copied the fov algorithm).
At the moment I would choose Unity for a roguelike just for its wonderful cross-compatibility.
UPDATE: I was forgetting a bit of spam of my work xD Repo | Demo
1
u/chad-autry Jul 01 '19
Trying to catch up, but I'm afraid that won't happen by Tuesday.
I'm working on a web based survival mmo roguelike I've had tickling the back of my mind for 5 years.
So where I'd like to be in order to mirror the tutorial steps as much as possible, is to have a user be able to log on, generate a first basic room, and move around the room.
Since Wednesday when I started, I was working on resurrecting some client side drawing code.
Right now, where I currently am is trying to get auth hooked up to chad.autry.dev. I'm taking the opportunity to learn about and shove that into some cloud functions (AWS lamda equivalent). Unfortunately I can't shove the whole game into web functions, since I want the server to push events back to the client asynchronously (so I can't just poll a function every 'tick' from the client) So next step is add web-sockets.
1
u/[deleted] Jul 01 '19
Has anyone added sounds to theirs? I’ve tried google but it seems like anything with sound is using pygame
1
u/Vertixico Jul 01 '19
I did start using a Map, however I quickly grew wary of using a String to identify a central Value like the color. True this is a bit lazyness to be able to use the IDE's autocomplete :)
For now, I see no issue with the size. I think I wiöl tackle that later, maybe I switch to a different tileset. So far it honors the tileset's original size and I have not yet looked into how to scale it. That's a problem for later :)
0
u/[deleted] Jun 26 '19
[deleted] — view deleted comment