r/roguelikedev • u/aaron_ds Robinson • Jul 02 '19
RoguelikeDev Does The Complete Roguelike Tutorial - Week 3
This week is all about setting up a the FoV and spawning enemies
Part 4 - Field of View
Display the player's field-of-view (FoV) and explore the dungeon gradually (also known as fog-of-war).
Part 5 - Placing Enemies and kicking them (harmlessly)
This chapter will focus on placing the enemies throughout the dungeon, and setting them up to be attacked.
Of course, we also have FAQ Friday posts that relate to this week's material.
- #12: Field of Vision(revisited)
- #41: Time Systems(revisited)
- #56: Mob Distribution
- #70: Map Memory
Feel free to work out any problems, brainstorm ideas, share progress and and as usual enjoy tangential chatting. :)
56
Upvotes
3
u/nomadthoughts Jul 02 '19
Could we get links to the previous weeks' posts please? I can't easily find them and I want to start. I'm a bit late to the party tho.
8
u/KarbonKitty Rogue Sheep dev Jul 02 '19 edited Aug 07 '19
Burglar of Babylon - TypeScript + ROT.js
Play here || Repo here || Template repo
Screenshot!
Part 4 was all nice and simple, because of built-in FoV algorithms in ROT.js (right now, the Recursive Shadowcasting with 360 degree view is used, but it might change in the future), so now both fog of war and player memory are implemented. It might be somewhat difficult to notice, but tiles outside of FoV are drawn grey. It would be easier if not for the fact that there is plenty of grey anyway... But I had limited time this week to work on aesthetics. :)
Part 5 was - again - somewhat derailed by the fact that the current map is hand-made... Well, both maps, really. :) There is a new map - this one more practical and less, well, test-ish - of an floor at an office building. Player will be tasked with getting from the start point, to the mainframe (where the data he wants to steal resides) and then to lifts or stairs, to get out. I will be placing guards, giving them FoV and making them stop player in part 6, because I'm yet to decide on how to actually do the placement and wandering routines. :)
7
u/HexDecimal libtcod maintainer | mastodon.gamedev.place/@HexDecimal Jul 02 '19
GitHub Repo - Python 3.7 / tcod+numpy
If you're using NumPy arrays to hold tile data then you can skip making a Map object and call the tcod.map.compute_fov function instead.
Last time I did the tutorial I used dataclasses for things like the Fighter class (in part 6,) but those turned out to be tedious to subclass (they're better at just holding data rather than doing class stuff.) This time I've been assigning immutable objects as typed class variables manually.
The tutorial has been returning messages from its functions as dictionaries and I've been trying to replace those. It was easy enough to refactor the event system but my solution currently feels half-finished. I'm worried that I might end up making the action code overly complex rather than finding something elegant.
6
u/Skaruts Jul 02 '19 edited Jul 02 '19
Nim - libtcod_nim | my repo
So following last week's assignment on map generation, I tried a few things and thought of some others, but wasn't happy with any. I tried a binary tree for generating the houses, but didn't seem like I can get what I want with it. I thought of using a grid with large cells for generating parts of the village in each one. Not sure how, but I'm still keeping this idea on the table.
Another idea I had was by using prefabs of certain points of interest with preset house spawning points (to be selected at random), I could potentially create parts of the village around those points of interest, which would be scattered around the map (this is specifically for the forest village -- if I ever do a regular one, I think I'll try using tunneler algorithms for making roads and houses. In this case I want something less sophisticated). The screenshot is a mockup of a prefab for a Well, and the red and yellow markers are the spawning points for houses (they mark the center of a house). Each house would be placed randomly in one, if not overlapping an existing house. They are in pairs to create some variation, although this might not be needed -- that variation in placement could be specified in a prefab file.
Since I couldn't improve on that before today, and since I don't have prefabs figured out yet, I kept what I already had and resorted to what I think is a naive way to add doors, windows and a bit of furniture (screenshot). Doors aren't yet working, and I'm trying to decide whether to make them entities or tiles.
I was thinking of going in a more ECS direction than the tutorial does (or at least find some way to not have growing numbers of component arguments in the entity's constructor), and perhaps make a door component, if a door component makes sense. (What if you give that to an Orc?)
(Personally I think the tutorial should have a better way of adding components. It was my biggest peeve with the original one, and still is with this one.)
Meanwhile I went on to part 4 and added fov, as well as an option (a flag) for using either a faded color or single color for tiles outside fov.
So, anyway, my map generation is essentially this:
This takes a whole lot of conditional braches -- too many for my taste... It's bloated and unwieldy and very hard to add more content, and the content that there is is just a facade. So I'll have to try to wrap my head around how to actually get it done.
I had a bit of trouble with deciding how to represent the map in between all these steps, and I'm not sure the way I'm doing it is ideal:
I have a temporary tilemap (a 2D array of ints -- a Nim sequence) that stores references to terrain types (which are separate from the TileType enum), that gets passed around to and changed by each of the generators and decoration functions, and at the end the actual tiles are created based on it.
So now I'm onto part 5, regardless -- adding the bad guys. And the good ones.
My TODO list:
5
u/iamgabrielma Ad Iterum on Steam Jul 02 '19
This week I started to work on the inventory system and player/enemy stats, I'm still deciding the final theme of the game but at the moment seems will be placed underwater and involve submarines. Some screenshots from the progress:
5
u/Jalexander39 Jul 02 '19
Untitled Love2D Roguelike: Gitlab Repo
So I did some more work cleaning up my maze generator, and right now I think it's complete except for supporting 'blob' mazes and Wang tile prefabs. Until then, I have the generator randomly add rooms and 2-wide corridors.
FOV is more difficult than I anticipated; unlike in libtcod, the FOV algorithm in rot.js/rotLove only stores the tiles in FOV instead of the entire map. This means I have to manually clear the FOV status of each tile before rerunning the FOV algorithm. Fortunately, the rendering code for camera panning and NPCs still works flawlessly without adjustment.
Meanwhile, setting up rot's turn scheduler was straightforward, but turn processing is very slow, to the point that input is ignored for a quarter-second or more despite there being less than 20 actors on the map. I know it's the scheduler because it lags even if I have the NPCs do nothing; I'll have to check out rot's source code and/or consider writing my own.
Pic for this week
5
u/dafu RetroBlit Jul 02 '19 edited Jul 02 '19
Follow my progress at: https://gitlab.com/mcietwie/rbrl
Current screenshot: https://i.imgur.com/GhguyiW.png
[C#, Unity + RetroBlit]
Follow my progress at: https://gitlab.com/mcietwie/rbrl
In this week I ran into the first snag in not doing this project in tcod library, I had to implement FOV from scratch! Well not really from scatch, I just borrowed it from one of my other C# projects, which in turn based the code on this article http://roguebasin.roguelikedevelopment.org/index.php?title=FOV_using_recursive_shadowcasting_-_improved
The other lesser snag was printing text. I needed to implement a rudementary console to print text into. The console contains a rotating LinkedList of strings, when I'm logging a new string I grab the last string in the list, clear it, fill it, and move it to the front. I then render as many strings as I can fit from bottom up until I reach the maximum height of the console (1/3 of the display). RetroBlit has a FastString class that I'm using throughout this project, which does not incur the normal Garbage Collector costs of the built-in C# immutable string.
4
u/diomedet Jul 02 '19
My Repo (Python 3.7 libtcod)
Hi! Here's my repo, a little messed up, I'm cleaning up the code a little every week. For now, I'm following the tutorial try to understand and implement the code as explained and then I watch the /u/HexDecimal code (thanks for your work) and re-do the work and try to get used to NumPy.
I hope I can stick with you all till the end of the tutorial :D
4
u/-gim- Jul 02 '19 edited Jul 05 '19
love2d 11.x - lua || github || screenshots gallery ||
Hello week 3,
I'm a little bit behind. I don't like my generated houses, and the ones I hand-crafted (based on real-world designs), are IMO bit too big. I don't want to get stuck with this, so I'll temporarily skip that part and will get back to it later
Plan for next week:
elements properties - currently all placed elements aren't passable by the player, need to temporarily make the doors passable, cause it will make testing easierfov - I do have code in lua somewhere already, I want recalc fov for all entities, that might turn up super slowcalculate LOS after fovbumping onto enemies - that shouldn't be very hard, cause I already have basic entities.stretch goal - add fog of war - should be simple, have all the blocksI already have some sort of timestep, which hopefully should make things easier.
good news, managed to add FOV today, calculating fov for 100 random entities, radius 10 cells, takes < 20ms on my machine.
have bumping onto enemies - some dummy damage + let them die
I'm away from Fri-Tue, so not really much time this week 😱 glad I made things I wanted, see you on Wed!
4
u/jeansquantch Jul 02 '19 edited Jul 03 '19
I have spent an extremely long time on the portion of the tutorial scheduled for this past week, easily the majority of the time I've spent coding so far in this tutorial. And really I'm just talking about FoV. My project is is in Ruby using BearLibTerminal.
You can see my FoV code here. What I have primarily done is taken the already-written Ruby code for recursive shadowcasting and modify it with Adam Milazzo's "my algorithm", as he refers to it. Note that there are some other changes in my code, such as the octant transformation matrix being reorganized to go in order, and significantly more explanatory commenting, amongst others.
Milazzocasting introduces beveled blocking (wall) tiles and half-width-piercing requirements on unblocked (floor) tiles.
Tiles can be beveled during the algorithm, such as in his code, or at map generation, such as in my code (under the bevel_tiles) method. Note that this didn't take a second for even a 400x400 map (many tiles), so it is probably a good performance idea to do it this way. A tile corner is beveled if the two orthogonally adjacent-most tiles to it are not blocking. This results in tiles have 0, 2, or 4 (a pillar) beveled corners. Here is the map I will be referring to below completely revealed with all beveled tiles in red. Yes, I know, it's pretty ugly. I only have circle rooms, square rooms, and tunnels for now. I added those pillars in manually. Not the point! So what does it mean for a tile corner to be beveled? It means that corner of the tile is "cut off" for the purposes of slope calculation when light beams are trying to pass through it - if all 4 corners are beveled, the wall tile (pillar) is in effect a diamond.
Wall tiles are lit if any portion of the wall shape (including bevels) is hit by the light beam, while floor tiles are lit if their center square (half the width of the tile) is hit by the beam. The performance impacts are minor, with Milazzocasting still outperforming most other algorithms, even without tile pre-beveling at map generation. His website has more details on that.
The main purposes of his changes are to remove the following 'cons' (some may not think them cons) of shadowcasting:
I also added my own change - which as far as I can tell should be implemented in just about every circular FoV, but isn't. Here is what a wall-passing circular FoV 13 tiles out looks like. Doesn't it seem a little...not circular? (I'm not talking about the oval shape because the tiles are rectangular - I'm talking about dem nsew sides) The reason is that the x2 + y2 < r2 calculation does not account for the width of the player's tile. Thus adding or subtracting 0.5 from the radius fixes this. It's a minor change, and some may prefer the first version - but I think the second is nicer looking.
I learned a -lot- adapting his changes to the ruby shadowcasting algorithm. Understanding left-handed coordinate systems (slope is x/y, not y/x, for example). And of course understanding recursive shadowcasting - the idea is one thing, the code is a different beast. It was awesome.
Edit: Note that when a rectangular room's corners are just out of view, they still do not appear lit sometimes depending on your FoV radius. This is no longer the expansive wall problem from typical shadowcasting, but not merely from the x2 + y2 < r2 check. This should probably be fixed with some kind of check for corner blocked tiles in the algorithm, but I'm not sure if it's worth it.
4
u/thebracket Jul 02 '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 now finished the tutorial in Rust, and am working on turning RLTK_RS into a Rust library - complete with examples and tutorials. It'll be a bit before that's ready.
Here is the @ walking around a new, randomly made map
Week 3's tutorial went reasonably smoothly. I actually did parts of week 3 and 4 together, so it's a little harder to separate them than I'd like. You can browse the repo at the time when a random map is generated here. The mob stuff got mixed into a few later commits, but I did field-of-view first (trying to get my head around some Rust concepts).
The actual map generation wasn't too bad at all:
mapstruct to implementrandom_rooms_tut3, which uses the same algorithm as the tutorial. This required that I learn therandsystem from Rust (it works pretty well - word of warning, a new version is just coming out that changes the syntax quite a lot), and also made aRectstructure that implementscenterandintersectsto assist. My implementation returns a vector ofRectstructures for each room.Rooms), and places one mob in the center of each room.For mobs, I went with a super simple definition at this point:
And I simply added a
Vec<Mob>to the game state. Since the goal is reusable code, I created a "trait" namedRenderable. (Traits are like extension classes in other languages; you can implement a trait for most types, and then call the functions for that trait on the type. You setup a prototype/interface, and implement it on every type you want; you can also use polymorphism to store a mixed bag of structs that implement a trait - I did that a bit late in the game, more on that in coming weeks!). I also implementedRenderableforPlayer. So the render code simply callsdrawon all mobs and the player. For now, the implementations are identical: put an ASCII glyph on the map in the right place, in the right color.My collision detection is relatively primitive. When I detect a player movement request, I calculate the tile on which they will land - and ask the map if that tile is walkable. If it is, then I iterate through the
mobslist and see if their position matches my position. If it does, the move is cancelled and a message (on the console, since we don't have a GUI yet) says "you kick the monster".One fun discovery: structs don't have an equality operator by default, but you don't have to implement operator overloading to make it happen. You can tack
#[derive(Eq, PartialEq)]onto a struct to have it do a member-wise comparison for equality purposes. Likewise, if you put#[derive(Copy, Clone)]into a stuct it no longer moves every time you assign it - it simply splats a copy out. This was especially useful forColor- rather than have references everywhere, it simply copies the values. Given that aColoris just three 32-bit floats, that's near instant since the compiler is smart enough to use registers for the purpose (and a pointer is 64-bits, so it's only slightly larger than a reference anyway).After week 3, I used this discovery to move all my
x,ytype structures into aPointstruct. It looks cleaner that way!4
u/godescalc Jul 02 '19 edited Jul 04 '19
I'm up to the bit of the tutorial where you add scrolls, and am slowly overhauling things to include skills, random damage, etc.
I've also reworked dungeon generation a bit - instead of directly tunneling between rooms, mapgen now uses a biased random walk to get from one room to another. I like the results a bit better. [EDIT: Rooms aren't always connected... need to fix that.]
I'm starting to add noise, with the idea that getting in a fight should attract monsters (a la DCSS). Because I don't know how to use python classes properly yet, the game crashes when you press "n" (for "noise")... although I prefer to think of this as a remapped "quit" command. [EDIT: beginner's mistake - I called the new method under the generic class name (GameMap.noise(...)) when I should have called it under the instance of the class (game_map.noise(...)).]
Repo: https://sourceforge.net/projects/cave-of-rainbows/ (the code is a mess tho)
4
u/CipherpunkChris Jul 02 '19
I'm at the beginning of week 7 right now. I'm writing my project in C with SDL2 (but I'm considering removing SDL2 right now). I spent the weekend compressing the code, pulling out useful helper functions and eliminating redundant calculations. The code has also been split into files and is much better organized.
I wanted a more expressive way to handle probabilities and I love tabletop RPGs so I added a dice rolling function that I use in various places. It's a lot easier for me to conceptualize probability curves in terms of dice and now I can roll 2d6 by typing Roll(2, 6).
Before starting on the UI, I wanted to add some piles of gold that can be picked up and added to the player's inventory . So I added gold pieces to the generator (they're gold colored "$"s) and all the logic to pick them up. There's also console output for how many pieces were picked up in each pile.
4
u/[deleted] Jul 03 '19 edited Jul 03 '19
RoveR: week 3 'Lunokhod 2' screenshot
RoveR is a roguelike about a planetary rover created using R and the package Shiny.
This week's mission objectives included planet generation and turn handling. I've decided to forego the field of view tutorial - I will implement later - any suggested roguelikes with interesting or unusual field of view mechanics?
I approached planet generation with methods from landscape ecology, specifically a random cluster method modified from Saura and Martínez-Millán, 2000. Briefly, this creates a simple random map of a 200 by 200 pixel grid (i.e. percolation map of presence or absence). Connected component labelling is used to identify and then assign a value (zero or one) to connected clusters in the percolation map. The absent pixels from the initial percolation map are then filled by taking the mean of their nine nearest neighbours. The process is repeated by creating a percolation map from the previous simulation. A smoothed random walk adds rivers. The arguments are all fixed for now, so variety is limited, but I will expand this if there is time for polish towards the end of the tutorial. I also want to use this approach to generate environmental variables (e.g. thermal gradients across elevation and latitude) that will be relevant for my little rover's journeys.
Performance remains an issue when hosted online but is fine locally. Because this only seems to be an issue with the hosted demo, I will save optimization until the end of the tutorial. You may need to refresh the demo until the rover spawns outside obstacles - Sorry folks, I will address this next week.
4
u/ryosen Untitled RL Jul 03 '19 edited Jul 05 '19
I've been helping my kid through the Python tutorial. She has the full game working and has made several enhancements. Currently she is working on adding NPCs.
One place where we are stuck is in using a replacement tile set. We've followed the "extra" part of the tutorial but haven't succeeded in getting anything more than a blank square when trying to use a custom character. Named characters (e.g. "b") work as expected with the tilemap but using an integer index results in a blank space.
Some things we've checked/tried:
set_custom_font(), thenload_customfont(), thenconsole_init_root()load_customfont()are correct but have tried other variables to account for different offsets. Nothing works and all integer index values passed toconsole_put_char_ex()result in a blank character.I'm new to Python and libtcod. In the past, I've successfully used Java with a version of AsciiPanel.
Any suggestions of things to try would be appreciated. I'll try to get a github repo up shortly.
Update: Big thanks to /u/HexDecimal who pointed out that
load_customfont()has to be called afterconsole_init_root(). Everything that I saw online said it had to come before but placing it after fixed the issue.3
u/week77 Jul 02 '19
My Java project is currently a little behind because I wanna learn how to connect caves instead of just creating a random cave with randomized connectivity....
So I am now trying to learn some data structure that can be helpful for my game.
3
u/Harionago Jul 02 '19
Python 3.7 libtcod | GitHub
I want to complete this tutorial and have a functional roguelike, but I'm fighting the urge to deviate and implement my own features. I am going to try to stick to this and only start hacking away once the tutorial is complete!
My only notable change -
I have created a subclass that inherits from the entity class called Player. That way I can use ' isinstance' to distinguish between monsters and players. Although I have a feeling that the tutorial might start doing things like this later down the line.
I am thinking of creating a room generator so that I can a lot more variety in the dungeon. Maybe I'll come up with a theme and base it off that.
3
u/endperform Jul 02 '19
Noname Roguelike - Go - termloop | Github
I'm running pretty far behind since I could not find a libtcod (well, an updated libtcod) for Go, so I found something else to try to work with. Right now the character can move on a pre-defined field and I'm still working on learning about termloop so I can implement the map.
3
u/[deleted] Jul 02 '19 edited Jul 02 '19
I implemented FoV, FoW, and my turn-based energy-dripping scheduler thing in Azymus. It worked! Details on the scheduler here.
I'm still struggling with the ECS architecture. I found CPU usage would spike up to 300% (!!!) when running headlong down a hallway. I'm not sure why that is... I mean, I know I'm an idiot and I'm overcomplicating things, but can what I'm doing be that inefficient? The performance of Specs as a whole seems to be excellent, so I'd expect that any negative performance effect would be a result of me doing boneheaded things. Running around in a dungeon with a similar level of detail in NetHack 3 yielded about .4% CPU.
Also, it was a bit irritating to immediately have to "shadow" my component-based map tiles with more traditional 2-D arrays for performance with pathfinding/FoV/collision detection. My original thinking was that, sure, I could use bitwise operators and stuff to have pretty substantial tile variety with an
i64per tile... but I really wanted the infinite possibilities of tiles that were actually objects. And some tiles are collidable, some objects are collidable, so let's make them all the same thing, right? Well, performance sucked. Which, again, is a little surprising to me, because I feel like dumb loops, even with 16000 things, should be faster than what I actually experienced. (I'm sure there are optimizations there -- maybe I could do some spatial hashing or quad-tree algorithm to do this faster... but a custom storage engine for Specs seems a bit heavy for me right now -- even assuming that's the right approach, which I honestly don't know -- given the amount of time I spend scratching my head over really basic Rust stuff.)And performance being any kind of issue this early in the game is very concerning to me.
So I'm currently split between two approaches:
I've been working on #2 in a feature branch. It's more fun than the ECS approach, and more comfortable, and still exposes weaknesses in design (specifically, that I still don't know WTF I want to do with my maps) and knowledge (took me forever to figure out I was inadvertently copying my player object and that was the reason my input was no longer moving him around the screen). But if I have, say, 100 complex AIs on the screen, and 1-2000 objects floating around in inventories and treasure chests and hovels and such, and graphical effects like animated water, and things where an orc's sense of smell has a sort of FoV and vampires are drawn by the smell of blood and splashing through a stream alerts monsters and stuff like that... I can definitely imagine the ECS approach being very, very handy there.
So I'm torn. As I so frequently am.
EDIT: I should mention I've also considered the strong possibility that it's nothing to do with ECS but my dumb ass misuse of
tcodthat's causing this dramatic performance consumption. That's no doubt part of the problem, but I turned off rendering and still had high sustained CPU usage, so there's other stuff going on.3
u/TorvaldtheMad Jul 02 '19
Repo
I spent a bunch of last week working on implementing a new dungeon generator (as I mentioned in a previous topic) and getting it to work procedurally via seeded RNG. This was tricky, as I couldn't find good documentation on the existing PCG stuff in Rust, so I ended up taking one of their procedural number generators and implementing my own methods to randomly select indexes from a Vector and one that essentially recreates gen_range(), also using a seed. That was probably unnecessary, but it forced me to think pretty hard about how to achieve those ends, and so I call it a win.
As of now I have the message box working, and I'm basically at the end of Part 7 of the tutorial. I'm skipping mouse for now, because I actually want a keyboard-only feel for this. My next big trick is going to be getting typed player input; one of the things I really want to get the feeling of in this game is "command line" interaction, so "scrolls" and "potions" are going to be "apps" and "scripts" that the player will have to execute with specific commands. I know libtcod can do this, but I'm pretty sure it's outside the scope of the tutorial. I'm looking forward to figuring it out =)
3
u/Arctic_Pheenix Jul 02 '19
I've been silently following along here for the past two weeks as time permits. Decided to do this in Rust, by following the tutorial at https://tomassedovic.github.io/roguelike-tutorial/index.html
While I'm quite accomplished at Python, Java, C, C++, and Go, I had only dabbled in Rust about two to three years ago, and had never written a game without the aid of an established engine. I just completed part four, and am continuing on to part 5 here shortly.
My plans are to complete the tutorial in its entirety, and then start playing around with various design decisions to make this my own little thing.
If anyone is interested, they can find my repo at: https://github.com/ArcticPheenix/rusty-roguelike
3
u/[deleted] Jul 02 '19
I didn't have much time to work on my game this week but I did accomplish my goal of implementing doors which then led me to other map objects. I added teleportation portals and shrines and at the same time inadvertently skipped ahead to the "harmlessly kicking enemies" portion of the tutorial since I gave my NPC a collision reaction.
I also implemented a look function although it currently only works for the terrain and objects in the tile you're standing on which isn't super useful. I'm now printing a lot of text to the console so I've been thinking about skipping ahead to the UI portion but it's only one more week so I can probably wait.
https://pbs.twimg.com/media/D-ZhwMhUIAAqmSq.png
https://pbs.twimg.com/media/D-ZhwMqUcAACd1H.png
I did quickly hack in the map generation algorithm from the tutorial (https://pbs.twimg.com/media/D-ZlHNbVUAAArxO.png) but I didn't try any other techniques.
My immediate goals are refactoring and cleaning up the code (particularly, the map class is getting unwieldy and has a lot of stuff in it that shouldn't be there), finishing the tests that I've been working on locally, and adding FOV and NPC turns from this week's tutorial. Once that's done I'm going to experiment with different map generation algorithms and interesting distribution of terrain and objects.
https://github.com/hufflazon/roguelikedev2019
3
u/Captain_Tralfaz Jul 02 '19 edited Jul 03 '19
Hero Party repopython3, libtcoddeveloped on a mac with Pycharm
This week I implemented the basics to my cooldown-based no-HP combat system that I explained in last week's update. I was ready to start adding items, but didn't want to get too far ahead, so... I worked on further tweaking the dungeon generation.
I started off with basic Cellular Automata. This can typically make some very small maps on occasion, so I decided to keep any cave systems larger than a certain threshold, and connect them with a random walk algorithm: from random cave 1 point to random cave 2 point, similar to how the rooms are connected in the tutorial. I then generated seeds in the fully connected cave system, and flood-filled from those seeds to create "zones" for monster / treasure spawning (similar to the rooms in the tutorial. This left me with cave systems with long corridors where monsters could spawn: Example1, Example2, Example3
Not wanting the zones to extend into the corridors, I decided to connect the cave AFTER they had had been flood-filled. This required a different seeding system, but came out a bit nicer (Example4), but still didn't fix the problem of long, unnatural looking hallways.
After hammering on this for a bit, I finally came up with a better, more natural looking solution: connecting the smallest cave to its nearest neighbor by the shortest route. This involved flood-filling around the walls of the cave instead of the open areas, until I found an open area not already in the cave... then connecting that point back to the cavern along the shortest route, re-discovering all the caves, and starting again with the new smallest cave. This proved to be a much better (if a bit slower approach) Example5
All this cave generation was done in a test script (using pygame for display) separate from my main repo, It will take me a bit to get it the algorithms transferred over to my main repo since the map formats are a bit different, but I wanted to share it out for use if anyone was interested.
*update: Well, that was a lot easier to add to the game than I expected!
3
u/dbpc Jul 02 '19 edited Jul 02 '19
My Repo - C# with SadConsole
I discovered while working on this week's stuff that there is actually a .NET Standard library called GoRogue (as well as RogueSharp as mentioned in the sidebar) that apparently handles FoV, pathfinding, etc. Basically it seems like SadConsole + GoRogue gives all the functionality that libtcod does (but probably with more features). That said I won't be opting to use GoRogue for this project because I've already learned quite a bit implementing the circular raycasting algorithm from libtcod into my own GameMap class.
I also made my first real deviation from the tutorial: I've made it so kicking the monsters kills them and replaces their entity with a corpse entity of the same color and name (with the '%' symbol of course). This is because I wanted to still be able to run around and explore the random dungeon. I will likely wait until the end of the tutorial to make any real changes to the engine as I want to have a better view of the project as a whole before trying to shape the architecture in a way that makes more sense to me.
3
u/theoldestnoob Jul 03 '19
My repo.
Last week:
I did not manage to get as far as I had hoped with my graph analysis stuff, but I did clean it up significantly, and separated it out so that it isn't really tied to the rest of the tutorial code - it takes a list of lists of bools for walkability and a list of rooms (which must be a generic Space object with a method to test adjacency of an (x, y) coordinate pair tuple). The map generation code passes it its input, and the main game loop can display some of the stuff it finds, but there's no real coupling other than the fact that the roguelike code sets it up and displays the objects it generates. I got it cleaned up and fleshed out to the point at which I was ready to begin working on building a list of all paths from each vertex to each vertex and a list of all cycles in the graph (getting a list of cycles to use for enemy patrol routes was my original goal for all of this), and then I realized that it was Monday night and the week was over. I promised myself that I wouldn't get sucked into some rathole and burn myself out on it to never complete the project (as I tend to do), so I'm putting that part aside and moving on to work on things related to part 4 and 5 of the tutorial this week. I will go back to the graph stuff later, after I have explored a little bit of all of the other areas that I can customize things.
Last week I also sorted out my BSP map generation, and added a bunch of different variables that I can use to tweak the generation: max and min size of rooms, max and min number of rooms, ratios of hallway orientation, whether hallways are generated in order of room creation or randomly, ratio of circular to rectangular rooms, variation in BSP partition, depth of BSP tree. I like the looks of some of the maps I make with lots of circles and diagonal hallways like this one, although I still want to tweak it a bunch. But like I said, that will have to wait.
This week:
I completed part 4 today, and decided to do some extra stuff before moving on to part 5. Since I still want to be able to work on map generation stuff later without having to rewrite a bunch of stuff, I added an "omnivision" mode that, when enabled, displays the entire map at all times, and a keyboard command to toggle it. I want to make a game that involves controlling multiple entities, so I decided I'd add the ability to switch which entity you control, and that made the FoV go all weird, so I changed it to store an fov map for each entity, and set the tiles to store which entities have explored them. Now when I change between entities, I can only see what they see and have explored. I'm not sure yet what I'll add after I finish part 5, but I'm sure as I'm working on it I'll think of a hundred different things and then struggle with deciding which ones I can feasibly do before I have to cut myself off again next Tuesday. Worst case I'll go back to cleaning things up to make them more readable and adding documentation and tests. And given how many extra commands I've added at this point, it might make sense to separate handling that out from the main game loop. I am certainly not in danger of running out of things to do.
3
u/tpseven Jul 05 '19
Parts 4 & 5 with purescript repo & demo
FOV is done via shadowcasting algorithm, in my optioning this gives the best results and pretty straightforward.
Since purescript has powerful type system there is no need to have entity class, so monsters and items won't have anythings shared (and to my logic, they don't share anything in real life).
And there is no need in game state like player or monster turn - monsters turn doesn't require anything from player, it's just a pure function (don't take randomness in mind) which transforms the level so monsters act as a final stage of player's action.
3
u/nilamo Jul 05 '19
For those of you not using libtcod (I'm using Pygame), how do you handle fov? The tutorial has like a single line that basically just pokes libtcod and asks it nicely to recompute the fov, which isn't super helpful lol.
I've put together a brute-force method, but it's noticeably slow (1-2 second delay before the screen updates). I can probably improve that by more intelligently culling tiles that are too far from the player, but it still seems like I'm over complicating it.
2
u/RichardWizdan Jul 02 '19 edited Jul 02 '19
Github | Twitter
Hi guys! Another week is behind us, and it's been a fruitful one! I have adjusted scripts for procedural generation and went ahead a little to implement basic turn order and attacks that damage enemies. Going along with the tutorial has been a great help as in my previous projects I didn't have any concrete plan. Now I have a solid idea of what functionalities I want to have and a vague idea on how to get them to work.
I am trying to leverage GML as much as I can. Instead of keeping the whole level in an array I switched to Game Maker's objects for tiles, although at some point in the future I will probably store each tile's position and type in a ds_map.
Sample screenshots:
2
u/[deleted] Jul 02 '19 edited Jul 30 '19
My Repo
Part 4 is done, and Part 5 will be on the way soon. Since I'm not using libtcod, I had to use my own algorithm for FOV, which was based on the algorithm here. The results aren't as good as, say, shadow-casting (I noticed that there are a few spots where you can't see the walls in hallways) but it is good enough for now.
2
u/itsnotxhad Jul 02 '19
Last week I finished the tutorial (in Python 3.7), so now I'm fully into seeing how far I can take this throughout the rest of the event. So far the only real feature I've added is numpad controls. I think my next feature is going to be a "high score system" (just the floor the player died on) followed by adding monsters and ratcheting up the difficulty level.
Github | Blog
2
u/Marthusz Jul 02 '19
Yesterday I finished implementing the FOV map and today I been trying other fonts and ended up using one for Dwarf Fortress (Aesomatica 16x16) that I had to modify so it was grey scale (probably not the best but it looks acceptable). I'll try to finish part 5 tonight and get ahead as much as possible.
GitHub
2
u/conswess Jul 02 '19
I spent most of the week rewriting the tutorial code instead of making any progress beyond it. Though I have implemented a time system, so there's that.
As my game is going to be mostly ranged combat I need to put some work into making that, uh, work. I think I'm going to have to implement a few FoV algorithms and see what I actually like for a start. Feels like I'm still a long way from even generating proper levels, never mind starting the actual content.
2
u/chad-autry Jul 02 '19
I'm still trying to catch up from a late start and the additional workload I'm adding by not following the tutorial exactly (or even inexactly)
However, I have previously spent some time thinking about FOV. I expect to fall further behind when I actually get to implementing it though, instead of catching up https://github.com/chad-autry/angular-obstruction-fov
The basic idea is to compute visibility of the arc through each cell edge. So if the the relative cell just to the north was blocked, but the west cell wasn't; you'd only see half the cell to the nw. If a cell edge was a portal, you'd see through the portal for the arc of vision which passes through that edge/portal.
2
u/zachuk Jul 02 '19
github
Had a bit of a busy week last week and didn't really manage to get much done except get a game loop that doesn't kill my laptop. Just managed to catch up with the week 2 tutorial tonight. I wasn't planning on using an ECS, but took inspiration from the discussion of generic entities in the tutorial and decided to do it anyway. So far so good, and I'm reasonably happy with the base I now have to work off. Still some refactoring to go, but will do that as I work through the weeks. Will begin work in the new tutorial tomorrow.
2
u/CowFu Jul 03 '19 edited Jul 06 '19
Still going strong!
Part 4 is done, pretty much stuck to the tutorial this time without much deviation. Planning on part 5 tomorrow or Thursday!
github (python/tcod)
EDIT: Part 5 done too!
2
u/Minkelz Jul 04 '19
Just a little thing - but the way PyLint auto breaks up a long line annoys me a bit (Visual Studio Code).
I like how the code looks in the examples but my PyLint is always breaking up the long functions putting breaks in. Should a newbie even be using PyLint? I've been following Automate The BS as well where it is a part of the tutorial to use it. Is there a way to disable or set a new max line length? Why is having a max line length important in a world where everyone uses widescreen and multiple monitors?
Also does anyone know what color theme the examples are taken in? It's quite nice but it's different to all the ones VSC downloaded with.
2
u/gawwo Jul 05 '19
Here's my weekly update :)
I've completed step 5. There are just a couple of differences compared to the tutorial right now:
- entities can move diagonally
- turns are mixed. In each game the player may not be the first to act
- enemies have a sort of dumb AI: they move completely randomly and can try to attack
To handle a "console output" I've used TextMeshPro, because I thought it will come in handy in the future for styling the text inside. This slowed down the game load inside WebGL.
It's pretty exciting seeing this thing coming to life :)
Repo | Demo
1
u/Viol53 Jul 08 '19
I left this one pretty late! Splitting the caves into separate zones took a bit longer than expected, and the solution I have isn't perfect, but I think it's good enough for the tutorial. Nothing really exciting to screenshot this time, but I at least got my repo online here, if anybody dares venture into my code.
1
u/AgentMania Jul 08 '19
Back again with my Construct 3 roguelike! You can find the most recent version of the project here.
I decided to add some things at the last moment (which broke certain parts of the game) so you may notice some small changes to the project page over the next day or so. (Feel free to let me know if you run into any bugs!)
The big news this week is that the project is now open source! You can find a link to the Construct 3 file (and instructions on how to open it) on the page linked above. You can also view a full list of changes I made there as well.
See you all next week!
1
u/GeekRampant Jul 09 '19 edited Jul 09 '19
Game: Ghost Bound
Here is a screenshot, and here is the current playable game.
Re: Field of View
This week was the most challenging so far. While I've implemented most of the typical roguelike mechanics repeatedly in other projects (NPC's, AI, inventory, etc.), this was my first time working with FOV; and it does add a whole new layer to the game.
The algorithm itself is simple raycasting using Bresenham's, but I decided to go with a full radial area for now. The reason is that the "game world" is supposed to be woods covered in fog, and this felt like having the limited ability to see through bushes and branches. I might set something up which varies the vision range depending on how see-through the foliage is, but this suffices for now.
The other reason is that I'm currently forgoing fog-of-war (and no it's not entirely because I'm lazy :) ). I want this to feel like navigating the misty woods, therefore the player should feel a little uncertain about where they are in the big scheme of things. One idea was to implement flairs/torches to leave a breadcrumb trail; and also one of the later items will be a transponder beacon the player can drop off or give to someone. They'll know the direction to move in, but it'll still be trial and memory.
I want the player to be thinking things like: "the trail turns back to the left up ahead, right? So the 'Haunted Hut' tavern was around there someplace".
Of course it still needs plenty of finesse.
Re: Bumping into the other things
This was far more straightforward. Each NPC has a position (xy) and a tile_x/tile_y member set. Since the current actor count is small, the game loops through each actor and checks if their tile x/y matches the player's destination x/y. I used this as chance to set up a VERY rudimentary message system. A box pops up (or should) and disappears after two turns. The message log is part of a new HUD, and holds the last ten messages.
If the HUD is in the way (which it kind of is unless you're zoomed out), it may be toggled on/off via the [H] key.
Got bogged down with some other work this week but the next is wide open, so I'll use that as an opportunity to "clean house" a bit.
Good luck on week 4! :)
0
u/[deleted] Jul 02 '19
[deleted] — view deleted comment
0
u/[deleted] Jul 04 '19
[deleted] — view deleted comment