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.
This commit is contained in:
Dan 2024-05-16 12:08:02 +01:00
parent b8f42a552e
commit 7f5d9dc6fc
2 changed files with 12 additions and 11 deletions

View file

@ -270,25 +270,22 @@ script = ExtResource("1_lkvd1")
libraries = { libraries = {
"": SubResource("AnimationLibrary_6ntaf") "": SubResource("AnimationLibrary_6ntaf")
} }
autoplay = "Move" autoplay = "Sleep"
[node name="Z" type="Sprite2D" parent="."] [node name="Z" type="Sprite2D" parent="."]
visible = false
position = Vector2(-17, -22) position = Vector2(-17, -22)
scale = Vector2(0.1, 0.1) scale = Vector2(0.1, 0.1)
texture = ExtResource("5_owmpd") texture = ExtResource("5_owmpd")
[node name="Z2" type="Sprite2D" parent="."] [node name="Z2" type="Sprite2D" parent="."]
visible = false modulate = Color(1, 1, 1, 0.936508)
modulate = Color(1, 1, 1, 0.958931)
position = Vector2(-12, -38) position = Vector2(-12, -38)
rotation = 0.464258 rotation = 0.464258
scale = Vector2(0.11, 0.11) scale = Vector2(0.11, 0.11)
texture = ExtResource("5_owmpd") texture = ExtResource("5_owmpd")
[node name="Z3" type="Sprite2D" parent="."] [node name="Z3" type="Sprite2D" parent="."]
visible = false modulate = Color(1, 1, 1, 0.99451)
modulate = Color(1, 1, 1, 0.993125)
position = Vector2(-30, -47) position = Vector2(-30, -47)
rotation = -0.205949 rotation = -0.205949
scale = Vector2(0.13, 0.13) scale = Vector2(0.13, 0.13)
@ -299,6 +296,7 @@ position = Vector2(-6, 0)
scale = Vector2(0.1, 0.1) scale = Vector2(0.1, 0.1)
[node name="SnailBody" type="Sprite2D" parent="Sprite"] [node name="SnailBody" type="Sprite2D" parent="Sprite"]
visible = false
position = Vector2(60, 30) position = Vector2(60, 30)
scale = Vector2(1e-05, 1e-05) scale = Vector2(1e-05, 1e-05)
texture = ExtResource("7_8spp3") texture = ExtResource("7_8spp3")
@ -312,7 +310,7 @@ texture = ExtResource("8_0v3d4")
[node name="SnailShell" type="Sprite2D" parent="Sprite"] [node name="SnailShell" type="Sprite2D" parent="Sprite"]
rotation = -6.28319 rotation = -6.28319
scale = Vector2(1.00249, 1.00249) scale = Vector2(1, 1)
texture = ExtResource("8_0v3d4") texture = ExtResource("8_0v3d4")
[node name="ShadowEating" type="Sprite2D" parent="Sprite"] [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")] [node name="StateMachine" type="Node" parent="." node_paths=PackedStringArray("initial_state")]
script = ExtResource("1_tejvt") script = ExtResource("1_tejvt")
initial_state = NodePath("Eating") initial_state = NodePath("Sleeping")
[node name="Sleeping" type="Node" parent="StateMachine"] [node name="Sleeping" type="Node" parent="StateMachine"]
script = ExtResource("3_wnrnl") script = ExtResource("3_wnrnl")

View file

@ -21,10 +21,13 @@ func exit() -> void:
pass pass
func update(delta : float) -> void: func update(delta : float) -> void:
sleep_timer += delta
if sleep_timer > wakes_up_in: if GameState.level_started:
state_transition.emit(self, "Eating") 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: func physics_update(_delta : float) -> void:
pass pass