From 6aa4d7ad1d9ed089ba8c01c85a28c2137e220415 Mon Sep 17 00:00:00 2001 From: Victor Andrade de Almeida Date: Sun, 17 Jul 2022 03:07:32 -0300 Subject: Fix skeletons --- Scenes/MonsterSquare.gd | 12 +++++------- Scenes/MonsterSquare.tscn | 1 - 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/Scenes/MonsterSquare.gd b/Scenes/MonsterSquare.gd index 89ae2e3..443d3ec 100644 --- a/Scenes/MonsterSquare.gd +++ b/Scenes/MonsterSquare.gd @@ -1,22 +1,20 @@ extends Monster -onready var cardinal = Vector2.UP - const directions = [Vector2(1,0), Vector2(0,1), Vector2(-1,0), Vector2(0,-1)] + var dir_i = 0 +var dir = 1 func _ready(): ._ready() - dir_i = 0 + dir_i = randi() % 4 if randf() < 0.5: - cardinal = Vector2.RIGHT + dir = -1 func try_moving(player_pos : Vector2, monster_pos : Vector2) -> MonsterAction: var action = MonsterAction.new() - var next_tile = monster_pos var next_movement = directions[dir_i] - var next_pos = monster_pos + next_movement if next_pos == player_pos: @@ -24,7 +22,7 @@ func try_moving(player_pos : Vector2, monster_pos : Vector2) -> MonsterAction: else: action.type = MonsterActionType.MOVE action.dir = next_movement - dir_i = (dir_i + 1) % 4 + dir_i = (dir_i + dir) % 4 return action diff --git a/Scenes/MonsterSquare.tscn b/Scenes/MonsterSquare.tscn index 3627cae..95a8b79 100644 --- a/Scenes/MonsterSquare.tscn +++ b/Scenes/MonsterSquare.tscn @@ -6,7 +6,6 @@ [node name="MonsterSquare" instance=ExtResource( 1 )] script = ExtResource( 2 ) -actionable = false [node name="Sprite3D" parent="." index="0"] texture = ExtResource( 3 ) -- cgit v1.2.3