From 7f5d9dc6fcb1e069bed767bfa5b224d0d7897b78 Mon Sep 17 00:00:00 2001 From: Dan Date: Thu, 16 May 2024 12:08:02 +0100 Subject: [PATCH] Updated snail entity behavior The snail entity's default state has been changed from 'Move' to 'Sleep'. Visibility and color modulation of certain sprites have been adjusted. The initial state of the StateMachine node is now set to 'Sleeping' instead of 'Eating'. In the snail sleeping script, the sleep timer update and state transition are now conditional on whether the level has started. --- entities/Snail.tscn | 14 ++++++-------- entities/snail/states/snail_sleeping.gd | 9 ++++++--- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/entities/Snail.tscn b/entities/Snail.tscn index 7c064d0..ed7088b 100644 --- a/entities/Snail.tscn +++ b/entities/Snail.tscn @@ -270,25 +270,22 @@ script = ExtResource("1_lkvd1") libraries = { "": SubResource("AnimationLibrary_6ntaf") } -autoplay = "Move" +autoplay = "Sleep" [node name="Z" type="Sprite2D" parent="."] -visible = false position = Vector2(-17, -22) scale = Vector2(0.1, 0.1) texture = ExtResource("5_owmpd") [node name="Z2" type="Sprite2D" parent="."] -visible = false -modulate = Color(1, 1, 1, 0.958931) +modulate = Color(1, 1, 1, 0.936508) position = Vector2(-12, -38) rotation = 0.464258 scale = Vector2(0.11, 0.11) texture = ExtResource("5_owmpd") [node name="Z3" type="Sprite2D" parent="."] -visible = false -modulate = Color(1, 1, 1, 0.993125) +modulate = Color(1, 1, 1, 0.99451) position = Vector2(-30, -47) rotation = -0.205949 scale = Vector2(0.13, 0.13) @@ -299,6 +296,7 @@ position = Vector2(-6, 0) scale = Vector2(0.1, 0.1) [node name="SnailBody" type="Sprite2D" parent="Sprite"] +visible = false position = Vector2(60, 30) scale = Vector2(1e-05, 1e-05) texture = ExtResource("7_8spp3") @@ -312,7 +310,7 @@ texture = ExtResource("8_0v3d4") [node name="SnailShell" type="Sprite2D" parent="Sprite"] rotation = -6.28319 -scale = Vector2(1.00249, 1.00249) +scale = Vector2(1, 1) texture = ExtResource("8_0v3d4") [node name="ShadowEating" type="Sprite2D" parent="Sprite"] @@ -324,7 +322,7 @@ texture = ExtResource("2_yor00") [node name="StateMachine" type="Node" parent="." node_paths=PackedStringArray("initial_state")] script = ExtResource("1_tejvt") -initial_state = NodePath("Eating") +initial_state = NodePath("Sleeping") [node name="Sleeping" type="Node" parent="StateMachine"] script = ExtResource("3_wnrnl") diff --git a/entities/snail/states/snail_sleeping.gd b/entities/snail/states/snail_sleeping.gd index 13b0156..bb1e245 100644 --- a/entities/snail/states/snail_sleeping.gd +++ b/entities/snail/states/snail_sleeping.gd @@ -21,10 +21,13 @@ func exit() -> void: pass func update(delta : float) -> void: - sleep_timer += delta - if sleep_timer > wakes_up_in: - state_transition.emit(self, "Eating") + if GameState.level_started: + sleep_timer += delta + + # Snail will only wake up if the level has started + if sleep_timer > wakes_up_in: + state_transition.emit(self, "Eating") func physics_update(_delta : float) -> void: pass