Adds highlight to the caterpillar minigame
This commit is contained in:
@@ -14,7 +14,6 @@ anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_jdfsm")
|
||||
current_lesson_stimuli_ratio = null
|
||||
|
||||
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
|
||||
bus = &"Effects"
|
||||
|
||||
@@ -7,4 +7,3 @@
|
||||
script = ExtResource("2_nc3s1")
|
||||
lesson_nb = 4
|
||||
difficulty = 1
|
||||
current_lesson_stimuli_ratio = 0.7
|
||||
|
||||
@@ -22,6 +22,10 @@ var is_eaten: bool = false:
|
||||
collision_shape.set_deferred("disabled", true)
|
||||
|
||||
|
||||
func highlight() -> void:
|
||||
highlight_fx.play()
|
||||
|
||||
|
||||
func wrong() -> void:
|
||||
wrong_fx.play()
|
||||
await wrong_fx.finished
|
||||
|
||||
@@ -52,7 +52,7 @@ offset_left = -8.0
|
||||
offset_top = -116.0
|
||||
offset_right = 68.0
|
||||
offset_bottom = -40.0
|
||||
theme_override_font_sizes/font_size = 30
|
||||
theme_override_font_sizes/font_size = 32
|
||||
text = "A"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
@@ -12,12 +12,20 @@ const berry_scene: PackedScene = preload("res://sources/minigames/caterpillar/be
|
||||
@onready var berries: Node2D = $Berries
|
||||
@onready var leaf_timer: Timer = $LeafTimer
|
||||
|
||||
var velocity: float = 400.0
|
||||
var velocity: float = 0.0
|
||||
|
||||
|
||||
func _ready():
|
||||
# Adds some leaves from start
|
||||
var pos: = -leaves.position.x + velocity * randf_range(0,2)
|
||||
while pos < 0:
|
||||
var leaf: Leaf = leaf_scene.instantiate()
|
||||
leaves.add_child(leaf)
|
||||
leaf.position.x = pos
|
||||
pos = pos + velocity * randf_range(2, 5)
|
||||
|
||||
if not Engine.is_editor_hint():
|
||||
leaf_timer.wait_time = randf_range(0, 2)
|
||||
leaf_timer.wait_time = randf_range(2.0, 5.0)
|
||||
leaf_timer.start()
|
||||
|
||||
|
||||
@@ -32,7 +40,7 @@ func _process(delta):
|
||||
berry.position.x -= velocity * delta
|
||||
|
||||
|
||||
func spawn_berry(gp: Dictionary):
|
||||
func spawn_berry(gp: Dictionary) -> void:
|
||||
var berry : Berry = berry_scene.instantiate()
|
||||
berries.add_child(berry)
|
||||
berry.gp = gp
|
||||
@@ -44,6 +52,13 @@ func clear_berries() -> void:
|
||||
for berry: Berry in berries.get_children():
|
||||
berry.fall()
|
||||
|
||||
|
||||
func highlight_berries(gp: Dictionary) -> void:
|
||||
for berry: Berry in berries.get_children():
|
||||
if berry.gp == gp:
|
||||
berry.highlight()
|
||||
|
||||
|
||||
# ---------- CONNECTIONS ---------- #
|
||||
|
||||
func _on_button_pressed():
|
||||
@@ -51,7 +66,7 @@ func _on_button_pressed():
|
||||
|
||||
|
||||
func _on_leaf_timer_timeout():
|
||||
var leaf: Node2D = leaf_scene.instantiate()
|
||||
var leaf: Leaf = leaf_scene.instantiate()
|
||||
leaves.add_child(leaf)
|
||||
|
||||
leaf_timer.wait_time = randf_range(2.0, 5.0)
|
||||
|
||||
@@ -15,6 +15,10 @@ var gp: Dictionary:
|
||||
label.text = ""
|
||||
|
||||
|
||||
func _ready():
|
||||
walk()
|
||||
|
||||
|
||||
func idle():
|
||||
animated_sprite.play("idle")
|
||||
|
||||
|
||||
@@ -77,8 +77,7 @@ scale = Vector2(0.5, 0.5)
|
||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
||||
sprite_frames = SubResource("SpriteFrames_236fx")
|
||||
animation = &"walk"
|
||||
autoplay = "walk"
|
||||
frame_progress = 0.0810001
|
||||
frame_progress = 0.649697
|
||||
offset = Vector2(32, -64)
|
||||
|
||||
[node name="Label" type="Label" parent="."]
|
||||
@@ -86,6 +85,6 @@ offset_left = -8.0
|
||||
offset_top = -116.0
|
||||
offset_right = 68.0
|
||||
offset_bottom = -40.0
|
||||
theme_override_font_sizes/font_size = 30
|
||||
theme_override_font_sizes/font_size = 32
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
@@ -34,6 +34,7 @@ var difficulty_settings: Array[DifficultySettings] = [
|
||||
@onready var branches_zone: Control = $GameRoot/BranchesZone
|
||||
@onready var caterpillar: Caterpillar = $GameRoot/Caterpillar
|
||||
@onready var berry_timer: Timer = $GameRoot/BerryTimer
|
||||
@onready var highlight_timer: Timer = $GameRoot/HighlightTimer
|
||||
|
||||
|
||||
var branches: Array[Branch] = []
|
||||
@@ -79,6 +80,11 @@ func _start() -> void:
|
||||
berry_timer.start()
|
||||
|
||||
|
||||
func _highlight() -> void:
|
||||
for branch: Branch in branches:
|
||||
branch.highlight_berries(_get_GP())
|
||||
highlight_timer.start()
|
||||
|
||||
func _get_difficulty_settings() -> DifficultySettings:
|
||||
return difficulty_settings[difficulty]
|
||||
|
||||
@@ -125,6 +131,7 @@ func _on_berry_eaten(berry: Berry) -> void:
|
||||
|
||||
if _is_GP_right(berry.gp):
|
||||
_clear_berries()
|
||||
highlight_timer.stop()
|
||||
await caterpillar.eat_berry(berry)
|
||||
await audio_player.play_phoneme(_get_GP().Phoneme)
|
||||
current_word_progression += 1
|
||||
@@ -155,3 +162,6 @@ func _on_current_progression_changed() -> void:
|
||||
# Start the timer again
|
||||
berry_timer.start()
|
||||
|
||||
|
||||
func _on_highlight_timer_timeout():
|
||||
_highlight()
|
||||
|
||||
@@ -49,4 +49,8 @@ position = Vector2(384, 0)
|
||||
[node name="BerryTimer" type="Timer" parent="GameRoot" index="3"]
|
||||
wait_time = 2.5
|
||||
|
||||
[node name="HighlightTimer" type="Timer" parent="GameRoot" index="4"]
|
||||
wait_time = 3.0
|
||||
|
||||
[connection signal="timeout" from="GameRoot/BerryTimer" to="." method="_on_berry_timer_timeout"]
|
||||
[connection signal="timeout" from="GameRoot/HighlightTimer" to="." method="_on_highlight_timer_timeout"]
|
||||
|
||||
Reference in New Issue
Block a user