r/roguelikedev • u/aaron_ds Robinson • Jul 09 '19
RoguelikeDev Does The Complete Roguelike Tutorial - Week 4
This week we wrap up combat and start working on the user interface.
Part 6 - Doing (and taking) some damage
The last part of this tutorial set us up for combat, so now it’s time to actually implement it.
Part 7 - Creating the Interface
Our game is looking more and more playable by the chapter, but before we move forward with the gameplay, we ought to take a moment to focus on how the project looks.
Of course, we also have FAQ Friday posts that relate to this week's material.
- #16: UI Design(revisited)
- #17: UI Implementation(revisited)
- #18: Input Handling(revisited)
- #19: Permadeath(revisited)
- #30: Message Logs(revisited)
- #32: Combat Algorithms(revisited)
Feel free to work out any problems, brainstorm ideas, share progress and and as usual enjoy tangential chatting. :)
6
u/jeansquantch Jul 09 '19
Here's a GIF of some basic gameplay since last week. And github. My roguelike is coded in Ruby on BearLibTerminal. :>
In addition to very basic combat, I have:
Implemented my own A* pathfinding algorithm. That took a while. I haven't bothered to create a binary heap to sort explored tiles for it yet because it hasn't slowed anything down, even searching the whole map (only ~1000 walkable tiles usually).
Finally spent time finding better looking colors and fonts. This game is heading towards something sci-fi-y, so I went for 'metal' colored walls.
Made a looking system that rotates through entities in the FoV and returns their symbol, name, and status (which is currently attacking or dead). This is done by pressing TAB.
Made an HP bar and log. Ran out of time to implement a key that temporarily shows a full screen-height of log, but that shouldn't be too hard.
6
u/thebracket Jul 09 '19
My continuing adventure to boldly go where quite a few Rust programmers have been before - and learn a lot doing it. :-)
The repo for my Rust implementation of the tutorial is here: https://github.com/thebracket/rustyroguelike. As I've mentioned before, I've actually completed the tutorial now - so I'll write a bit about my implementation of tutorials 6 and 7.
Field of View Extension
I started out by extending my Field of View code to also give mobs a visibility list. It only updates when they move (lists tiles they can see, rather than contents), and is fast enough that calculating them isn't a big resource drain. I did tweak the implementation a bit to pre-allocate space rather than dynamically resizing vectors, which reduced the amount of work to be done. Then I gave mobs an FoV, and for their AI tick it simply checks the FoV list to see if the player is in it - and if they are, the mob activates.
Path Finding
The mob simply paths straight towards the player. I first implemented this with Dijkstra flow maps; I like to implement these whenever I'm learning a new language: they are really useful, really easy to get working on the basic level (with lots of room for improvement), and conceptually a lot easier than A-Star. I highly recommend this article for reasons why you should implement them, too!
Anyway, the basic implementation went well: pass in an array of "starting points" (distance 0 spots), it iterates the list running a search on each (only applying depth if the new depth is shorter than the old one) using the time-tested open/closed list. I did learn that Rust's
HashMapimplementation could use some work - it was faster to search a small vector than to use set membership for the closed list.It worked well, and mobs chase the player.
I then went ahead and implemented A-Star anyway. I basically ported the version from One Knight in the Dungeon over, and it also works well. Speed wise, it's about the same as the C++ version.
Fighters
The tutorial makes a point of putting combat stuff in the Fighter component, so I did the same. I was surprised to discover that traits (Rust's polymorphism) don't do data members, so you end up implementing getters and setters. That felt like a step backwards, but ok. I also setup a
Combattrait, and put the ability to bash things in there. This was pretty straight forward, and worked decently enough.User Interface
I extended RLTK to include box drawing, horizontal/vertical progress bars (that work great for health bars) and a console. Since I was already passing text results around, it was a pretty straightforward task to put them into UI elements instead of sending them to the text console. The results are quite nice.
I really wasn't enjoying my tooltips, so I hacked together a quick Cogmind-like setup (only less sophisticated and not as pretty). Not bad for 10 minutes. It's very primitive: it goes to the left or right of the cursor based on absolute screen position (so if you are in the right half of the screen, it goes left - and vice versa).
I also went slightly out of order and put a main menu in place. I didn't get to save/load until later (the screenshot is from a slightly later build), but it felt like a good time to worry about look/feel. The Matrix effect isn't overly useful, nor does it really fit - but I had fun making it!
RLTK_RS - Rust Library
I've been hard at working taking the library code from RR, and turning it into a library: https://github.com/thebracket/rltk_rs. I don't recommend using it until it hits version 0.2 - I'm still tweaking the API, so I'll potentially break anything you write at this point.
Algorithm2Dtrait, and teach it to translate x/y positions to whatever indexing scheme you are using behind the scenes. This then automatically provides distance and other geometry functions. ImplementBaseMap(which requires that you provide anis_opaquefunction and aget_available_exitsfunction - the latter listing directions you can travel from a tile) adapts path-finding (A-Star and Dijkstra) to your map format.RGBtriple. I imported the X11rgb.txtcolorset (this is also used by the W3C for named colors in HTML/CSS), and setup helpers for them all. So if you want to use named colors, they are as simple asRGB::named(rltk::YELLOW). It also knowsRGB::from_u8(255,255,0),RGB::from_f32(1.0, 1.0, 0.0), andRGB::from_hex("#FFFF00"). There's various helpers such asgreyscale(uses a fixed weighting to provide a quick to-grey function),to_hsv(turns it into a hue/saturation/value triplet),lerp(for stepping between colors), and basic math (add to/subtract from, multiply by, etc. between colors and colors and a float).If you build it right now, it'll want you to have
cmakeand a full C++ toolchain available. That's because it goes out, downloadsglfw(a C library) and builds it! I don't really like that at all - so I'm in the process of porting it over toglutin- a Rust-native OpenGL library. This is hard work, and I'm struggling to not change the API. It's in a branch (not sure if I've pushed that branch to github - been working on it locally), but it gets rid of the C toolchain requirement and is a little faster. In theory, it also supports web assembly (WASM) - untested, so far.6
u/nicksmaddog Jul 09 '19
I'm still chugging along on my Common Lisp tutorials, although I did fall a bit behind this past week. I've got the tutorials up through the dungeon generation posted, and I'm working of the FOV tutorial now. Hopefully I can get caught back up.
You can find the tutorials here: http://nwforrer.github.io/
5
u/TorvaldtheMad Jul 10 '19
Connection Lost | Repo | Gameplay GIF
I have a mostly functional GUI now, and items in the inventory (right now there's only a "healing potion") can be used via the virtual console (the ~ tilde key, like the old days of gaming). My dungeon generator works fine and the game is 'playable' to some extent.
Coming up: some additional items and mobs (I'm going to try to make a 'corruption' attack script that functions basically like a fireball, but also randomly alters terrain; and once I introduce the randomly-wandering drone type, I'm going to attempt a 'hijack' spell that will essentially turn it into a 'pet', but that's going to require some AI enhancements before I can get it fully online--hoping the fireball/mind control part of the tutorial will get me some of the way there). I'd also like to give the 'virus' enemy the ability to randomly replicate itself, probably similar to how slimes work in Rogue.
In order for me to make the game fully functional I'm going to have to do some major refactoring, but I'd like to get through the tutorial before I start on THAT endeavor.
I really like working in Rust. It's just a pleasant language to work in. I don't object to curly braces, and the borrow-checker and I have come to sort of a mutual understanding: it does its thing, which I respect, and I listen and tweak my approach until it's happy. =)
4
u/itsnotxhad Jul 09 '19
After last week I got to work on creating some new monsters. The first new monster idea I had really tested my ability to add features to this code. It's called a wraith. It:
The Damage/Healing over time system required a new component, the different movement rules required me to write a new AI and tweak some of the existing movement code, the lack of a corpse meant adding invisible objects to the render (since a monster can't easily delete itself) And getting the timing of the damage right meant mucking about with the turn order and may eventually mean creating a separate game state for it as my current solution is kind of ugly.
I also found out
shelvecan't handle arbitrary functions which led to some fun rewriting the save game code.I've also implemented a potion that heals over time (slightly less powerful than the current Healing Potion) and a snake that tries to poison the player and then run away, and a Balrog a.k.a. a BasicMonster with unreasonably high stats just to add some danger.
The next major feature on my wishlist is to be able to write separate floors and have the game move between them, but this turned out to be more difficult than I thought it would be. Right now some parameters that would be interesting to vary by floor are in the startup constants, while others are scattered throughout method definitions in GameMap. I'm still thinking this over.
Github | Blog
4
u/HexDecimal libtcod maintainer | mastodon.gamedev.place/@HexDecimal Jul 09 '19
GitHub Repo - Python 3.7 / tcod+numpy
An alternative way to compute A* is with the
tcod.pathmodule:Where
costis your Map object or an array with the cost of movement (with 0 being blocking.)pathwould then be a list of all the coordinates on the path, or an empty list if a path isn't found. Typicallyif path:,len(path), andx, y = path.pop(0)are used with this list. While this is better since you can provide a NumPy array ascostthis isn't going to be the final API for handling path-finding in python-tcod. There's plans for these to be single functions and for Dijkstra to be more useful.I've been trying to figure out how to do elegant composition and polymorphism for a while now. A pattern I've been using more is to have a dictionary where the key is a class and the value is an instance of that class or subclass. This can be verified with type hints:
You don't need to add anything else to this type, and this could also be something stored in Entity, instead of being Entity itself. It's used like this:
So all you need to do to make a new component is to make a new class for it. Since this is just a dictionary you can use
Cls in entityandentity.get(Cls)syntax. I've made a far more complex version of this before, but I might switch to this simplified version for the tutorial.4
u/iamgabrielma Ad Iterum on Steam Jul 10 '19
Unity and C#
FOV
FOV was a bit tricky to implement with TileMaps, and while works I'm not sure if is the best approach:
As I cannot set the state of each tile to discovered or not (or I haven't discovered how to do so) but I can change its color if I know the vector where is located, what I do is default everything to black, so is invisible with the background, and then as soon as the player approaches I convert that zone to white, so is "visible" from that point.
Once the player leave that area that is discovered but should be outside of view, the tile becomes grey. It needs some more work but for the moment I prefer to go through all the tutorial and have a functional horizontal slice where everything works before digging in fixing the details or improving the bits.
Last week:
I've been working in the inventory & equipment & gear system, as well as displaying this dynamically in the UI, which has been a challenge, some GIFS:
This week:
I started to work in the Save/Load system which is something I haven't done so far, while I used PlayerPrefs in the past for other projects to save little data between sessions, this wouldn't work for this complexity so seems I will have to serialize the data, I'm checking a few tutorials before coming up with a solution for the game.
4
u/Jalexander39 Jul 10 '19
Untitled Love2D Roguelike -- Repo
This week followed the tutorial a bit more closely than I perhaps would've liked, although I had to adjust somewhat to account for separating actors and items into their own classes. Dead actors are replaced with corpse items (since I'm not working with a proper ECS, having a single entity class didn't make as much sense). This week was particularly troublesome, so I got lazy and skipped some minor steps like formatting the message log.
Here's a screenshot. I switched back to the tutorial's dungeon algorithm for now, albeit with a few tweaks such as allowing overlapping rooms. I opted to change the color of the HP text based on amount, from white (100%) to yellow to red (0%). I'll eventually add a visual meter like in the tutorial. I also added a list of visible actors/items to the sidebar, in lieu of mouse-driven farlook, plus a rough HP indicator for monsters.
Incidentally, the player and monsters share most of the same movement code, which substitutes an attack for trying to walk into another actor. Later on I'll add factions, and prevent actors from attacking their allies, but until then the monsters have no qualms about fighting each other offscreen.
4
u/-gim- Jul 10 '19 edited Jul 15 '19
love2d 11.x - lua || github || screenshots gallery ||
Hello week 4,
Last week went pretty good. There are small issues with entities display, that I need to check.
I have pretty lengthy plan for this week, not sure if I'll be able to do everything in here:
add in-game debug console - srsly, I need to see what's happening, logging things on a console is less than optimaladd a-star - plan the path towards goaladd mouse support (want to let the player entity to use a-star)use a-star (go towards player or nearby location)wild idea action queue items replacement - i.e. in the middle of move, but if hit by player, could replace action with strike-back (and proper action points progress) - not sure if good idea- moved intotodo.mdnotesadd "screens" / screen-manager - to handle initial menu -> game transition + keyboard, display etc.- turned out hump has what I want under namegamestatemain menu + game menudisplay visible enemies listinventory- delayedmodal/non-modal dialogs - not sure if needed- delayed"voice" messages4
u/Zireael07 Veins of the Earth Jul 10 '19
Repo (Javascript + Canvas API)
So I said I won't be taking part? Turns out I lied... or rather, I got a surprise bit of free time and a need to redo Veins yet again due to performance problems.
Sticking with the browser target, the obvious pick is Javascript. I use it at work, mostly for "when this button clicked, fire this function" kinda things, but sometimes it's a bit more involved. Because it's mostly a learning project for my job (at least the web frontend part of it), I use jQuery and some html buttons that basically are an alternate input to the old and tried keyboard. No mouse support, because I target mobiles too, and learning both mouse and touch API is a pain. No roguelike libraries, because jQuery is big enough by itself, no need to bloat it up further by dragging rot.js in. No rendering libraries, because I want the freedom of making my own game loop, and most of those impose some sort of a loop already, somewhat like Love2D does. That leaves Canvas API for rendering - and it does perform well enough!
I started last Friday, and I have already caught up to the end of week 4. Bits and pieces of JS code did accompany the Nim version, after all. I basically adapted the Nim version, commit by commit.
The A* implementation I snagged from somewhere, and for RNG, I used Alea and extended it to work with dice rolls. And I should credit maetl's tutorial, as I snagged the FOV implementation from there instead of writing my own (for performance reasons, his implementation uses Set() and mine was a mess of temporary objects representing vectors...) Also for the same reason, I forwent the vector class completely and I'm using straightforward x,y integers. Less readable, but hopefully lets me avoid the GC trap I fell in last time with Nim!
The most painful part so far was implementing player death - I spent two hours debugging only to discover the game was reacting to keypresses even in PLAYER_DEAD state, and therefore setting back state to ENEMY_TURN, when a move was attempted. Turns out I'd mixed up scope (again - I had some trouble with that at work, too) and had to split up the if .... Other than that, I installed JS snippets for VS Code, as I have trouble remembering the syntax of the for loop... too used to Python's, I guess! and no loops anywhere to be seen in JS code at work ;)
The things I already learned: ES 6 classes, ES 6 modules, destructuring assignments, switch/case statements. I guess the project's living up to the plan of making me better at JS!
I will probably fall behind a bit, though, as I'm leaving for holidays this week with no computer access. Starting in two weeks, the only thing I will have access to will be a spare copy of the JS project + Vim portable on a USB stick and a shitty computer, but I will try to catch up as much as possible then, or when I return to my own rig. That's nearly a month of a break!
3
u/KarbonKitty Rogue Sheep dev Jul 09 '19 edited Aug 07 '19
Burglar of Babylon - TypeScript + ROT.js
Play here || Repo here || Template repo
So this week I've actually managed to do a little more than the two parts that were planned for this week! But we will come to this later. ;)
Part 6 - Since this is a stealth game, doing and taking damage part is noticeably different than in the tutorial. In particular, the player character doesn't do any damage (albeit I will probably allow stunning later on), and the damage is dealt to the player in a specific way - instead of HPs, there is an alert level, which goes from 0 to 5, and on 5, the game is 'lost' (actually, a browser alert is displayed for now; I will try adding something like restarting the game on losing, but it's unfortunately a little bit more complex in the browser than normally). The alert level rises every time the player ends the turn within enemy FoV - and to make this a little bit easier, guards have a significantly shorter sight radius than the player (5 tiles instead of 10) and their FoV is actually marked as a background color (red) on all the tiles they can see.
There is still no AI to speak of for the guards, and they just wander randomly 80% of the time and stand still other 20%. Better AI is in the works! ;)
Part 7 - Creating the interface. There is now a space for interface and a space for messages in the text area on the side of the game area. It shows player's name (Johnny. The name is Johnny. It will be editable later on... But not now.) and current alert level. I should probably add max alert level to the display too, now that I think about it.
Bonus! - doors can be now opened, and they aren't passable any longer. Just bump into them and they will open. Unless they are security doors, those don't open so easily (or at all, for now). There is no way to close them (to be exact, there is in code, but it's inaccessible for now), but it will come next week, with the input handling refactor, which will be needed for the inventory. I've also cleaned up some of the code and I have a couple of reasonably good ideas about handling furniture, so I have a reasonably good feeling about this. I will probably take a break after finishing the event to get back to my other projects, but Burglar is getting more and more chance to be put into this rotation even after the event. :)
3
u/dafu RetroBlit Jul 09 '19 edited Jul 09 '19
[C#, Unity + RetroBlit]
Follow my progress at: https://gitlab.com/mcietwie/rbrl
Current screenshot: https://i.imgur.com/mw36Npw.png
This week I continued to run into extra challenges due to missing builtin functionality that's provided by tcod lib.
First I needed to implement pathfinding. The tutorial uses A* pathfinding. I decided to use flood-fill based pathfinding that I've used in other games before. With flood-fill algorithm the total movement cost from the player from any tile (within max range) is precalculated, and all monsters can share these results to figure out how to get to the player from their current position by following neighbouring tiles with least total cost. There is no need to do pathfinding for each monster separately. The flood-fill map is recalculated every time any entity moves. Here is a visualization of the algorithm calculating movement costs: https://i.imgur.com/7jma8EM.gifv
Next I implemented the results[] collection used in the tutorial. I'm a little sensitive to Garbage Collection and so I implemented this without causing any runtime garbage, there is pre-allocated storage for results that is reused every frame.
For UI I've already implemented the message log in the previous weeks so there was not much work to be done here. For the mouse "tooltip" I've sorted the entities under the cursor by their render order so that corpses are listed last.
3
u/conswess- Jul 09 '19
I don't feel like I got very far this week. I'm struggling to add more complex things to it because I don't really understand the design, so I don't have any idea where to put anything.
I also don't know how to make visual effects. I tried spawning an entity with the right symbol with an "AI" that removes itself, but that's either too fast to see or persists until you take a turn, neither of which I like. I could have it just stall for a tenth of a second or something, but that doesn't sound great either. Maybe the libtcodpy docs have the answers, but I don't know enough to make sense of them.
3
u/[deleted] Jul 09 '19
Azymus is... IDK, doing whatever it's going to do. I'm just along for the ride, y'all.
Big thing this weekend was switching from libtcod to BearLibTerminal for I/O. I still use tcod for FoV and... something else? I don't even know anymore.
I added a spatial map and quad-tree (someone else's code; I got most of the way through a simple implementation but the iterator was giving me a headache, so I bailed) for map entities, which helped when I upgraded my lighting to support multiple light sources.
I don't know why I cared about lighting.
Tutorial-wise, I added some monsters and they'll kill your ass. Unless you have 32767 HP, like I do. But they fight bravely and die and turn into corpses.
My focus this week is adding some GOAP and factions to make things more interesting (the actual focus of the game is that I want interesting mob AI). I wanna add a few more species:
I want to make trolls like D&D trolls -- very hard to kill and organized around small matriarchal clans. Obviously gonna moderate the hard-to-kill thing for the time being. Trolls will fight anything, including other trolls, and are loyal only to their own clan. They tend to live in an area until they exhaust the food supply or until a few of them are killed. They're fully aware of their power and thus quick to recognize a legitimate threat. They produce few children; normally only one or two children will be in a clan at any given time. Children are raised communally.
I want to make orcs like D&D orcs (notice a theme here? I really like the D&D treatment of monsters in general). Orcs are tribal and can have more complicated faction structures than trolls. Orcs tend to form all-male warbands that orbit larger tribes and are based mostly around marauding with some agricultural activity going on in the tribe's territory. Orcs tend to have a child every 1-2 years or so and have close-knit family groups. They are not terribly dissimilar to humans in many regards.
Goblins are small and comparatively weak. They have a different breeding strategy than Orcs; they have twins or triplets on a yearly basis, gestating for about six months. They're generally neglectful parents; once a goblin bears a new set of children, the previous generation are cared for casually by the community, being given left-over food from hunts and raids. In lean times, they're the first to die, and in the worst of times they're the first to be cannibalized. They're often dominated or enslaved by orcs or farmed by trolls, often living as small "suburbs" to a more powerful group.
Kobolds are smarter and crueler than goblins, but similarly weak. While the Goblin strategy is to overwhelm the hapless by surprise and with superior force, kobolds lay traps and wait in ambush. They live in small clans, like trolls, but are migratory. They are keenly aware of their vulnerabilities and that they are viewed as pests by essentially all intelligent races. They almost never ally with any other race. Kobolds are boisterous with other kobolds from outside their clan, and members are frequently exchanged at multi-clan meetings. They're egalitarian and do all things collectively. Kobolds respect one another's cleverness and ability to create interesting traps or carry out difficult burglaries.
Chickens are small livestock that reproduce and reach maturity quickly, so I thought they'd be good as a basis for agriculture among goblins and orcs (trolls are too ravenous to delay eating, and kobolds are unwilling to bother or tolerate the noise). Ideally, eggs would hatch, be chicks for a few turns, then mature for a few turns, then some passing mob would slaughter it, cook it (optionally), and eat it.
Mushrooms would be another agricultural item. They'd spawn quite quickly and be eaten almost as quickly, but obviously provide less nourishment than a chicken. They also act as a food source for chickens.
Moss grows comparatively slowly and has little nutritional value, but will be eaten in starvation conditions. It provides some dim green light as it phosphoresces. It tends to be stripped from the walls in populated areas, though, since most of these creatures have infravision and the moss will only hinder them. Being deeply rooted, though, it tends to grow back. It's a food source for chickens, mostly when mushrooms are unavailable.
So, obviously, that's all quite a bit complicated and way beyond the scope of what most would consider a roguelike, but it's where I'd like to explore. I'm thinking this behavior can be explained pretty well with GOAP, factions, and some clever programming (in other words, me reading a lot of tutorials and doing a lot of research).
I'm not terribly concerned about the complexity. A likely explanation for that is that I'm an idiot and haven't fully comprehended how complicated this would be. Another likely explanation is that it isn't actually going to be all that complicated to implement but will be endlessly tweakable and still be underwhelming or completely broken in practice.
Meh, #YOLO.
3
u/[deleted] Jul 09 '19
RoveR: week 4 'Prop-M' screenshot
RoveR is a roguelike about a planetary rover created using R and the package Shiny.
This week's progress brings a simple user interface and combat. I've avoided any polish on the UI. I don't know what I will need from the UI, so a basic text display seems reasonable for now.
Melee combat is implemented and players will find themselves within a small station (i.e. dungeon), rather than the open planets from last week. There are two enemy classes with slightly different behaviour to seek out and destroy. Placing the mouse cursor over enemies now displays their names, but will eventually reveal statistics about each entity.
Performance worsened considerably this week - especially after adding pathfinding behaviour and multiple enemies. I didn't have time to profile and optimize, but I think it will be necessary before next week's tutorial. If you have the patience, you can try the demo.
3
u/theoldestnoob Jul 14 '19
My repo.
I have just completed part 7, and my earlier prediction about making things harder for myself has finally caught up to me.
Last week:
I completed part 5, and spent some extra time adding the core mechanic I'm going to be using for the game that I hope to have at the end of this: possession. The "player" entity is incapable of interacting with or perceiving the regular map, it can only see the "soul" of any entity inside its FOV range, and no other information. For now this is just a colored * or + based on a random number, but in the future I plan to provide the player with some information about the entity's qualities (just not what it actually is). The player can possess any entity that has a "soul" value and isn't dead, can walk through walls, etc. I plan on having multiple "missions" but for now I create a "VIP" entity on each map that puts the game into a failure state if it dies. The idea is, for this type of "mission", to have the VIP be incredibly weak and dumb so you have to possess them and enemies to get them through the level without dying. In order for this to be fun, I think I'm going to have to put a lot of work in to the AI and map generation.
This week:
Part 6 required some refactoring and doing things differently than the tutorial, because of previous changes (e.g. completely different user input handling system, per-entity fov, and per-entity map memory) and because I have to take into account that the player can control any of the monsters on the map. The bits that let you display various graph features on the map make everything more painful and much less elegant, I'm going to have to come up with a way to move them someplace where they're out of the way of the actual game.
I did a lot of extra work between part 6 and part 7. The two major things were adding a different time system and making it so that user input and ai functions just return an action that they want to take, which I handle separately. This does mean that now any abilities I add can immediately be used by both the player and any other entities. It also makes my main game loop much cleaner looking, now that I have shuffled the big nasty blocks of if statements to another module. I also spent a while working on switching to the newest tcod styles (using the objects) for rendering and fov and improving the efficiency of my fov and rendering functions. I started running in to lag due to the rendering and fov calculations occurring between every single entity action even when nothing was changing, so I added in dirty flags for rendering and each entity's fov calculation and now only render when something changes and calculate fov when an entity moves. I still render the entire map every time, which is inefficient, but I don't have any input lag so I'm not worried about optimizing it further.
I'm quite proud of my time system, although it's pretty similar to various other priority queue systems I've seen described here. I give every entity a speed and time_to_act attribute, and set up a deque of all the entities sorted by speed. Then each turn:
I currently just have every action that takes time take 100 "ticks", and vary entity speed to have them act at different rates. It is predictable and regular, and allows me a lot of control over how many turns an entity takes proportional to any other entity (A has double the speed of B: A takes 2 turns between each turn B takes; A has 2.5 times the speed of B: A alternates between taking 2 and 3 turns between each turn B takes; etc). It should also allow me to do things like effects-over-time fairly easily. The whole thing is about 20 lines of code.
Screenshots of my game so far:
Possessing the VIP (&), locked in mortal combat with a Troll and Orc
Not possessing anyone
Possessing an Orc
Album with the three images
You can see that when not possessing anyone, I can only see colored * and +, and can't see the corpse. Walls also don't block movement (I'm standing in one) or vision (I can see two other orange dots to the top right that are out of the VIP's FoV). When I go up and possess one of the orange dots, I discover that they are orcs. You can also see that the orc I have possessed has its own FoV and exploration history.
Until week 5 starts, I'm going to be working on: making large scrollable maps, rewriting the message log to have a scrollable history (and probably make it into a bounded deque instead of a list), and adding a "clock" entity to track and display the in-game time (to test my time system's flexibility and also to better understand the UI rendering)
2
u/Skaruts Jul 09 '19
Nim - libtcod_nim | my repo
Unfortunately I made no progress this past week. I was kinda busy with other stuff, and I'm also trying to figure out a direction for this project, lest I lose motivation to keep working on it...
So I'll have a bit of catching up to do, and perhaps some design decisions to make, but for the moment the project is as it was last week.
2
u/godescalc Jul 10 '19
Progress report: not as much done as previous weeks, life has been busy. Developments/todo-list:
Repo: https://sourceforge.net/projects/cave-of-rainbows/
2
u/[deleted] Jul 12 '19
Running behind by a week. Just complete Part 3 : Generating a dungeon.
Will get started with Part 4 soon. I am a little concerned about FOV in Clojure. From first look at the tutorial it looks like libtcod supports it out-of-the box. Will have to look for something similar in Clojure or roll out my own implementation.
Progress so far.
Repo.
2
u/Soul-Drake Jul 13 '19
I have a question for TStand90, the maintainer of the Roguelike Tutorial: It feels like many of the functions in the tutorial have a rather extreme number of parameters. For example,
game_map.make_maptakes 8 parameters, which seems like a lot. This is a problem I've encountered myself when programming: you're kind of stuck between either using globals (yuck) or passing inane amounts of parameters. You can reduce the number of arguments by packaging them in structs or classes, but that just seems to outsource the problem.Here's the actual question part: Why did you choose to go with the many-parameters-method, and do you know any viable alternatives?
2
u/dbpc Jul 14 '19 edited Jul 14 '19
My Repo - C# with SadConsole
Late update this week, but things are still moving along. As with the previous weeks I am sticking to the existing tutorial before transforming it later, but this will have to come soon if I'm to have anything that sets itself apart at the end of the series.
EDIT: I seem to be listed in the directory twice u/aaron_ds
2
u/[deleted] Jul 14 '19
Has anyone looked into implementing a scrolling camera with the tutorial code? Alot of the implementations I've seen would require me to make some pretty big refactors to my code.
2
u/AgentMania Jul 15 '19
Here's an updated link to week 4 of my Construct 3 roguelike. You can play it online, so feel free to click through if you want to try it out!
This was a big week in terms of adding in features! Some notable additions include:
I'm looking forward to finally being able to add in magic scrolls next week! See you all then!
2
u/Viol53 Jul 16 '19
I'm late, but I still finished! At first I had a lot of ideas for things I could add to the base tutorial stuff, but this code seems kind of hard to scale so I think I'll just follow along with it for now . After we're done I'll think about building something from scratch with the knowledge I've gained.
2
u/CowFu Jul 16 '19
I'm a week behind at this point, but I'm a good way through part 6, going to try and do 6,7 and 8 next week.
2
u/u1timo Jul 16 '19
Me: I wonder if someone can help me set up vi-keys
OH SNAP!
Happy that this was included :)
I'm curious about something. If I wanted to add color to text/strings, what is the easiest way to do it? For example in MUDs or Caves of Qud, there are items that have different colored letters in one word. Maybe for a Troll, I want the T to be a light green, the o to be a dark green and the rest of the letters to be brown.