Add bottom area limits

This commit is contained in:
Mathilde Grapin 2023-07-02 17:23:23 +02:00
parent 40525022d7
commit 200ae7f262
22 changed files with 300 additions and 40 deletions

View file

@ -4,6 +4,11 @@ extends TileMap
@export var wall_tile_source_id = 1
@export var destination_tile_source_id = 2
@export var target_tile_source_id = 3
@export var ground_left_tile_source_id = 4
@export var ground_right_tile_source_id = 5
@export var ground_bottom_tile_source_id = 6
@export var ground_left_bottom_tile_source_id = 7
@export var ground_right_bottom_tile_source_id = 8
@export var map_width = 13 # keep to a odd value
@export var map_height = 19 # keep to a odd value
# Debug variables
@ -22,9 +27,23 @@ func draw_map():
draw_wall()
func draw_ground():
var tile_source_id = ground_tile_source_id
var height = get_bottom_area_height()
for x in range(map_width):
for y in range(map_height):
set_cell(0, Vector2i(x, y), ground_tile_source_id, Vector2i(0, 0), 0)
if x == 0 && y == map_height - 1:
tile_source_id = ground_left_bottom_tile_source_id
elif x == map_width - 1 && y == map_height - 1:
tile_source_id = ground_right_bottom_tile_source_id
elif x == 0 && y >= height.x:
tile_source_id = ground_left_tile_source_id
elif x == map_width - 1 && y >= height.x:
tile_source_id = ground_right_tile_source_id
elif y == height.y:
tile_source_id = ground_bottom_tile_source_id
else:
tile_source_id = ground_tile_source_id
set_cell(0, Vector2i(x, y), tile_source_id, Vector2i(0, 0), 0)
func draw_wall():
var middle_height = floor(map_height / 2.0)