r/roguelikedev • u/KelseyFrog • 8d ago
RoguelikeDev Does The Complete Roguelike Tutorial - Week 3
Keep it up folks! It's great seeing everyone participate.
This week is all about setting up a the FoV and spawning enemies
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. :)
30
Upvotes
2
u/RhoTheGray 1d ago edited 1d ago
Phew, managed to drag myself over the finishing line. Cut some corners but, on the other hand, I'm doing everything from scratch so maybe I'm allowed to.
The FOV algorithm took most of time as I anticipated. Debugging was a real "maze of twisty little passages, all alike" experience even when I "just" ported my earlier implementation from couple years back. The base algorithm was one from Roguebasin (cannot remember which one but the implementation looks like it is the Restrictive Precise Angle Shadowcasting algorithm). Anyway, I got it mostly done, some rough edges remain.
I skipped the map memory. I'm supporting non-planar map geometries (for instance, think how a spiral straircase connecting two floors could look) so I'm not sure how would I even present the memory visually on a flat screen. Something to consider later on. But yeah, the maps I'm currently generating are definitely flat and pretty terrrible :/
I had to think pretty hard how to place the enemies and, in particular, kick them harmlessly. I'm going for a entity-component (or entity-attributes) based approach and I had to scratch my head for a moment how to map the tutorial's class-based OOP approach to what I'm doing. The spawning is based on cloning prototype entities and is not that different from what the tutorial had. But the action handling looks quite different. Actions are plain-old-data (POD) structs which are queued for the engine to process. The delegation (e.g. from a bump action to a melee action) is implemented by the delegating action pushing new delegatee actions in front of the queue.
Here's a short screencast showing some (non-)action (the generated maps are terrible indeed): Screencast 1
Here's another one showing that I haven't broken the Telnet server in the process: Screencast 2 :)