a game about throwing hammers made for the github game off
Diffstat (limited to 'levels/Level.gd')
| -rw-r--r-- | levels/Level.gd | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/levels/Level.gd b/levels/Level.gd index 33dcda8..7510149 100644 --- a/levels/Level.gd +++ b/levels/Level.gd @@ -8,8 +8,6 @@ const BlockDoor_scn := preload("res://world/door/block_door.tscn") const Door_scn := preload("res://world/door/door.tscn") const OneWayPlatform_scn := preload("res://world/one_way_platform.tscn") -const ALL_DOORS := [Vector2i.UP, Vector2i.DOWN, Vector2i.LEFT, Vector2i.RIGHT] - ## The enabled walls. [url=https://kidscancode.org/blog/img/cells_4bit.png]4bit[/url] @export_range(0, 15) var enabled_walls := 15 @@ -36,22 +34,16 @@ func create_node(p_name: StringName) -> Node2D: n.position = Vector2.ZERO n.name = p_name add_child(n) + move_child(n, 0) return n func _ready(): - var wall_array := Maze.tile_4b_to_wall_array(enabled_walls) + var door_array := Maze.tile_4b_to_path_array(enabled_walls) if completed: ($Enemys as Node2D).queue_free() - if len(wall_array) != 4: - var door_array := Util.sub(ALL_DOORS, wall_array) - if Vector2i.DOWN in door_array: - var n := create_node(&"one_way_platform") - n.position = Vector2(128, 243) - var p: OneWayPlatform = OneWayPlatform_scn.instantiate() - n.call_deferred(&"add_child", p) - + if !door_array.is_empty(): if has_enemys: blockdoors = create_node(&"block_doors") @@ -60,6 +52,12 @@ func _ready(): if has_enemys: add_block_door(door) + if Vector2i.DOWN in door_array: + var n := create_node(&"one_way_platform") + n.position = Vector2(128, 243) + var p: OneWayPlatform = OneWayPlatform_scn.instantiate() + n.call_deferred(&"add_child", p) + for enemy in enemys: enemy.died.connect(_on_enemy_died) |