Godot Engine - Procedural Generation

Built a dimension-swap mechanic that retargets enemy, item, and collision geometry visibility, screen color grading, and an audio reverb bus across two synchronized worlds with different environment sprites. Kept procedurally mirrored rooms pathable by reversing navmesh polygon winding order to work around an engine bug, assembling levels from 9 room prefabs onto type-matched connection points and shuffling them at runtime. Implemented an enemy state machine with navmesh pathfinding, raycast line-of-sight and facing-cone detection, lure redirection within 300px, and 4s stuck recovery, scaling spawns to 10 concurrent enemies

Notable Features

  • Random room shuffling, mirroring, item spawning

  • Enemy and dog pathing in levels with randomness and tilesets

  • Enemy states and behavior (patrolling, detection, etc.)

func get_rand_rooms() -> Array[RoomResource]:
	if roomCount >= rooms.size():
		var dupe := rooms.duplicate()
		dupe.shuffle()
		return dupe
	
	randomize()
	var i := 0
	var res : Array[RoomResource] = []
	while i < min(roomCount, rooms.size()):
		var rand := randi_range(0, len(rooms) - 1)
		var randRoom := rooms[rand]
		if randRoom not in res:
			res.push_back(randRoom)
			i += 1
	return res

func set_spot(room: RoomResource, playerBlob := false, item := false):
	roomSpots = currentLevel.get_room_spots()
	
	# different traversal for item rooms to seperate from player/blob rooms
	var span := range(len(roomSpots) - 1, -1, -1) if item else range(0, len(roomSpots))
	
	# select an open room spot and add room
	for i in span:
		var spot := roomSpots[i]
		if spot.active:
			continue 
		match spot.type:
			"Left", "Right":
				if room.type == "Left" || room.type == "Right":
					spot.active = true
					spawn_room(room, spot, playerBlob, item)
					return
			"Top", "Bottom":
				if room.type == spot.type:
					spot.active = true
					spawn_room(room, spot, playerBlob, item)
					return
	push_error("ERROR: DID NOT FIND SPOT FOR ROOM - isPlayer:", playerBlob, " isItem", item)
	
func set_room_for_spot(spot: RoomSpot):
	for r in rooms:
		match spot.type:
			"Left", "Right":
				if r.type == "Left" || r.type == "Right":
					spawn_room(r, spot, false, false)
					return
			"Top", "Bottom":
				if r.type == spot.type:
					spawn_room(r, spot, false, false)
					return

func spawn_room(room: RoomResource, spot: RoomSpot, playerBlob := false, item := false):
	# align room to spot
	var r := room.room.instantiate() as Room
	if room.type != spot.type:
		# must be a LR or RL Room to Spot matchup
		r.flip()
		r.type = spot.type # UPDATE ROOM TYPE TO BE ACCURATE
	r.global_position = spot.global_position
	
	# add special objects
	if playerBlob:
		# add player and blob
		spawn_player(r)
		spawn_cur_blob(r)
		spot.player_spawning = true

		# mark as light switch room
		lightSwitchRooms.append(r)
	elif item:
		# add correct item to scene
		if itemMap.has(game.currItem):
			currentItemPickup = itemMap[game.currItem].instantiate() as ItemPickup
			spawn_item(r, currentItemPickup)

	spot.room = r
	
	# add to scene
	roomContainer.add_child(r)

	# update hallway to have no tile at door vector location
	if spot.active:
		r.set_door()

Awesome credits to my partners for the music and art!