From: Lukas Krickl Date: Sun, 24 Aug 2025 17:21:26 +0000 (+0200) Subject: mapgen: player spawn map is now selected randomly X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=112a8fa86629e8fedced5c63f00248e341d6b61e;p=gbrg%2F.git mapgen: player spawn map is now selected randomly --- diff --git a/src/mapgen.s b/src/mapgen.s index ec7bbc4..bc13838 100644 --- a/src/mapgen.s +++ b/src/mapgen.s @@ -8,6 +8,7 @@ mapgen_init: call act_save_init call mapgen_seed call mapgen_make_doors + call mapgen_select_player_spawn call mapgen ret @@ -576,4 +577,29 @@ mapgent_unit_randomize_or_reaload_position: pop_all ret + + ; selects player spawn room + ; selects a random room that has an exit and + ; sets the map cursor + ; then places the player on a tile without flags +mapgen_select_player_spawn: + call rand + and a, FLOOR_MAP_COUNT-1 + ld hl, map_doors_location + ld d, 0 + ld e, a + add hl, de + ; check if the selected room has doors (is not 0) + + ld a, [hl] + cp a, 0 + jr z, mapgen_select_player_spawn REL + + ; write selected room + ld a, e + ld [player_map_cursor], a + ; TODO: move player position + + + ret