Fix enemy return ball two times each time

This commit is contained in:
Mathilde Grapin 2023-07-01 17:12:02 +02:00
parent a9a9f05296
commit 2b11ec8638
10 changed files with 29 additions and 42 deletions

View file

@ -31,38 +31,36 @@ func draw_wall():
for x in range(map_width):
set_cell(1, Vector2i(x - 1, middle_height - 1), wall_tile_source_id, Vector2i(0, 0), 0) # why have we to add -1?
func get_top_spawn_cell():
func get_top_spawn_cell() -> Vector2i:
return Vector2i(floor(map_width / 2.0), 1)
func get_bottom_spawn_cell():
func get_bottom_spawn_cell() -> Vector2i:
return Vector2i(floor(map_width / 2.0), map_height - 2)
func get_random_top_cell():
func get_random_top_cell() -> Vector2i:
var w = get_area_width()
var h = get_top_area_height()
return Vector2i(randi_range(w.x, w.y), randi_range(h.x, h.y))
func get_random_bottom_cell():
func get_random_bottom_cell() -> Vector2i:
var w = get_area_width()
var h = get_bottom_area_height()
return Vector2i(randi_range(w.x, w.y), randi_range(h.x, h.y))
func is_in_bottom_area(local_position: Vector2):
var map_position = local_to_map(local_position)
func is_in_bottom_area(cell: Vector2i) -> bool:
var height = get_bottom_area_height()
return map_position.y >= height.x && map_position.y <= height.y
return cell.y >= height.x && cell.y <= height.y
func get_area_width():
func get_area_width() -> Vector2i:
return Vector2i(0, map_width - 1)
func get_top_area_height():
func get_top_area_height() -> Vector2i:
var middle_height = floor(map_height / 2.0)
return Vector2i(0, middle_height - 1)
func get_bottom_area_height():
func get_bottom_area_height() -> Vector2i:
var middle_height = floor(map_height / 2.0)
return Vector2i(middle_height + 1, map_height - 1)