Procedural Map Generation [2]


For the past two weeks I played some of the rogue-like games I liked most and discovered something: Most of them have maps where the rooms are on a 3x3 grid like:

▢▧▢ 
▧▢▢ 
▢▧▧

after some more research I found out that this is the exact same pattern used in the very first game of this genre: Rogue! lol So I decided to make my maps similar to that.


▬ Implementation

I had some help with BSP from a good tutorial but couldn't find anything similar for Rogue's maps. So this time I had to code everything by myself with leads from: Decoded: Rogue


Some of the possible results


There were so many new concepts to learn. What gave me the most trouble was structuring everything inside the project. Like right now the rooms are implemented as dictionaries which is comfy but I really feel like I should make a room-class instead. Just that there is no usecase for that yet.


Something else I had trouble with was loading a new level when the player enters the stairs. The first implementation worked fine. The player entered the stairs and pressed space to load the next level. 

# does the job - inside stairs script
extends Area2D
func _input(event):     
    if event.is_action_pressed("ui_select"):         
        if get_overlapping_bodies().size() == 1:             
            emit_signal("stairs_entered")

But when I switched the behavior to automatic loading without player input, the player's initial position was off:


Poor player, stuck in the wall


It's strange because I'm emitting the same signal from the same file...

# Still inside stairs script
extends Area2D  
signal stairs_entered()
func _ready():     
    connect("body_entered", self, "_on_Stairs_entered")
func _on_Stairs_entered(body):  
    emit_signal("stairs_entered")

Google sensei gave me a hint to what might be the answer why this is happening: A known bug? Σ(・口・) Area2D fires off "body entered" signal when scene is added back to scene tree

The solution posted there (yield before emitting) helped but I'm not sure if it's really the same bug as I'm not understanding everything yet.

welp it works for now even if it makes me feel a bit uneasy 💦



✨ Version 0.1.1 complete! 


Next:

▬ Version 0.1.2

✨ Sand slime (Enemy): 

Moves around the map and towards the player when in range.

 ⚠️ Core feature: Enemy path finding

Leave a comment

Log in with itch.io to leave a comment.