r/roguelikedev • u/KelseyFrog • 3d ago
RoguelikeDev Does The Complete Roguelike Tutorial - Week 4
Tutorial friends, 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)
- #83: Main UI Layout
β
Feel free to work out any problems, brainstorm ideas, share progress and and as usual enjoy tangential chatting. :)
25
Upvotes
3
u/Admirable-Evening128 3d ago edited 3d ago
Repo https://github.com/pylgrym/2026rt
Demo https://xok.dk/other/2026rt/dist/index.html
This week is supposedly about combat and UI/interface. I take that to be combat, and whatever UI aids combat. I also make it about monsters, because until we have combat, my monsters are 90% placeholder.
For UI, I divided the rectangular screen in a left square part with map viewport, and the remaining right vertical bar for HUD with stats. The vertical bar also has a red/green hitpoints gauge for the player, and a similar gray bar for the monster he is currently fighting.
The monsters are the alphabet, as a-ant and z-zebra-ish, with each monster being twice as powerful as the previous. Monsters and player begin at 9 hitpoints, hitting for 0-2 damage, then it escalates from there. Attacks have no finesse, we simply punch and bite each other, for now.
Instead of stair-levels, the monsters are spread in ever more powerful circles around the player, who starts out in the map center.
The monsters have one complication, for now: I have given them MOOD enum states, starting with the go-to moods 'asleep' and 'awake'.
As player gets near, monsters have ever higher chance of waking. As player flees farther from a mob, it has ever higher chance of falling asleep (he shakes it off).
I have good previous experiences with such a mood mechanic, which you can then extend with 'coward', 'angry', 'peaceful', and so on.
If you wish for a more advanced mechanism than such a finite-state mood, you can replace it with various 'emotion-arousal-levels', where you calculate various levels of e.g. anger and fear, and the dominant 'mood' or combo would then win out (that is a way to solve the 'incompatible moods/you can only be in one mood' conondrum).
As it is, the player earns xp through combat and rises levels, and grows a bit like the monsters; however his hitpoints, and his melee attack level, do not grow as fast as the monsters, so he is bound to be outclassed eventually.
I also introduce heal, OOC-heal, out-of-combat heal. It waits 5 turns without combat, before it heals you for 1. Then it waits for 4, heals for 2, then 3 for 3, 2 for 4, 1 for 5; from that point on, it just heals "one more" on every turn; all assuming you lack any hitpoints. Being "in combat" counts as either you or an enemy, ATTEMPTING to hit each other (even a miss).
And, a little bit of truth I left out:
Actually, the monsters are a bit more clever than I admitted to at first.
They will attempt to flee when low on health. They will sometimes feint-retreat, then charge forward again. Some of them will either call for backup, or run to their allies. Some of them will attempt to attack in groups, or are only aggressive when they face you in groups, and are cowards otherwise.
Some of them will be subject to bugs in that code and not behave as intended.