Makes tracks stay validated. Frogs jumps at the last validated track when a mistake is made. Handles the scaling of lilypads to ensure that the label is always the same size.
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
[gd_resource type="LabelSettings" format=3 uid="uid://bguqnhiblwick"]
|
||||
|
||||
[resource]
|
||||
font_size = 86
|
||||
outline_size = 10
|
||||
font_size = 90
|
||||
outline_size = 8
|
||||
outline_color = Color(0, 0, 0, 1)
|
||||
shadow_size = 4
|
||||
shadow_color = Color(0, 0, 0, 0.639216)
|
||||
|
||||
@@ -108,6 +108,8 @@ func _setup_word_progression() -> void:
|
||||
|
||||
func _set_current_word_progression(p_current_word_progression: int) -> void:
|
||||
current_word_progression = p_current_word_progression
|
||||
|
||||
consecutive_errors = 0
|
||||
is_highlighting = false
|
||||
|
||||
if current_word_progression == max_word_progression:
|
||||
|
||||
@@ -39,7 +39,6 @@ var difficulty_settings: Array[DifficultySettings] = [
|
||||
|
||||
|
||||
func _setup_word_progression() -> void:
|
||||
await _free_tracks()
|
||||
super()
|
||||
_create_tracks()
|
||||
_start_tracks()
|
||||
@@ -56,6 +55,12 @@ func _reset_frog() -> void:
|
||||
frog.global_position = frog_spawn_point.global_position
|
||||
frog.jump_to(start.global_position)
|
||||
await frog.jumped
|
||||
|
||||
# Returns to the last completed track by jumping on each pad
|
||||
for track: LilypadTrack in lilypad_tracks_container.get_children():
|
||||
if track.is_cleared:
|
||||
frog.jump_to(track.lilypads[0].global_position)
|
||||
await frog.jumped
|
||||
|
||||
#region Tracks management
|
||||
|
||||
@@ -87,12 +92,15 @@ func _create_tracks() -> void:
|
||||
|
||||
func _start_tracks() -> void:
|
||||
var is_first_track_enabled: bool = false
|
||||
var i: = 0
|
||||
for track: LilypadTrack in lilypad_tracks_container.get_children():
|
||||
await track.reset()
|
||||
if not is_first_track_enabled:
|
||||
track.is_enabled = true
|
||||
is_first_track_enabled = true
|
||||
track.start()
|
||||
if i >= current_word_progression:
|
||||
await track.reset()
|
||||
if not is_first_track_enabled:
|
||||
track.is_enabled = true
|
||||
is_first_track_enabled = true
|
||||
track.start()
|
||||
i +=1
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -102,6 +110,9 @@ func _on_track_lilypad_in_center(lilypad: Lilypad, track: LilypadTrack) -> void:
|
||||
# Log the answer
|
||||
_log_new_response_and_score(lilypad.stimulus)
|
||||
|
||||
# Disable the tracks
|
||||
track.stop()
|
||||
|
||||
# Makes the frog jumps on the lilypad
|
||||
frog.jump_to(lilypad.global_position)
|
||||
await frog.jumped
|
||||
@@ -116,14 +127,13 @@ func _on_track_lilypad_in_center(lilypad: Lilypad, track: LilypadTrack) -> void:
|
||||
await audio_player.play_gp(lilypad.stimulus)
|
||||
|
||||
current_lives -= 1
|
||||
current_word_progression = 0
|
||||
|
||||
_start_tracks()
|
||||
await _reset_frog()
|
||||
else:
|
||||
track.stop()
|
||||
track.is_highlighting = false
|
||||
track.is_cleared = true
|
||||
track.is_enabled = false
|
||||
await audio_player.play_gp(lilypad.stimulus)
|
||||
current_word_progression += 1
|
||||
|
||||
@@ -152,6 +162,9 @@ func _on_current_progression_changed() -> void:
|
||||
frog.jump_to(frog_despawn_point.global_position)
|
||||
await frog.jumped
|
||||
|
||||
# Free the tracks
|
||||
await _free_tracks()
|
||||
|
||||
# Resets the frog position
|
||||
await _reset_frog()
|
||||
|
||||
|
||||
@@ -6,10 +6,10 @@ signal disappeared()
|
||||
@onready var animation_player: AnimationPlayer = $AnimationPlayer
|
||||
@onready var button: TextureButton = $TextureButton
|
||||
@onready var label: Label = %Label
|
||||
@onready var water_ring_fx: WaterRingFX = $WaterRingFX
|
||||
@onready var highlight_fx: HighlightFX = $HighlightFX
|
||||
@onready var right_fx: RightFX = $RightFX
|
||||
@onready var wrong_fx: WrongFX = $WrongFX
|
||||
@onready var water_ring_fx: WaterRingFX = %WaterRingFX
|
||||
@onready var highlight_fx: HighlightFX = %HighlightFX
|
||||
@onready var right_fx: RightFX = %RightFX
|
||||
@onready var wrong_fx: WrongFX = %WrongFX
|
||||
|
||||
var stimulus: Dictionary:
|
||||
set = _set_stimulus
|
||||
@@ -46,10 +46,6 @@ func stop_highlight() -> void:
|
||||
highlight_fx.stop()
|
||||
|
||||
|
||||
func get_real_size() -> Vector2:
|
||||
return button.size
|
||||
|
||||
|
||||
func _set_stimulus(value: Dictionary) -> void:
|
||||
stimulus = value
|
||||
label.text = stimulus["Grapheme"]
|
||||
|
||||
@@ -27,7 +27,7 @@ tracks/0/keys = {
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("TextureButton/Label:modulate")
|
||||
tracks/1/path = NodePath("Label:modulate")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
@@ -55,7 +55,7 @@ tracks/0/keys = {
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("TextureButton/Label:modulate")
|
||||
tracks/1/path = NodePath("Label:modulate")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
@@ -77,17 +77,11 @@ layout_mode = 3
|
||||
anchors_preset = 0
|
||||
script = ExtResource("2_pdqed")
|
||||
|
||||
[node name="WaterRingFX" parent="." instance=ExtResource("3_cojnu")]
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
libraries = {
|
||||
"": SubResource("AnimationLibrary_3tohd")
|
||||
}
|
||||
|
||||
[node name="HighlightFX" parent="." instance=ExtResource("5_1llgv")]
|
||||
|
||||
[node name="RightFX" parent="." instance=ExtResource("6_wslmk")]
|
||||
|
||||
[node name="TextureButton" type="TextureButton" parent="."]
|
||||
material = ExtResource("1_pbo2v")
|
||||
layout_mode = 1
|
||||
@@ -105,23 +99,70 @@ texture_normal = ExtResource("3_1ueu4")
|
||||
texture_disabled = ExtResource("4_0e8ya")
|
||||
stretch_mode = 0
|
||||
|
||||
[node name="Label" type="Label" parent="TextureButton"]
|
||||
[node name="WaterRingFX" parent="TextureButton" instance=ExtResource("3_cojnu")]
|
||||
unique_name_in_owner = true
|
||||
show_behind_parent = true
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="HighlightFX" parent="TextureButton" instance=ExtResource("5_1llgv")]
|
||||
unique_name_in_owner = true
|
||||
show_behind_parent = true
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="RightFX" parent="TextureButton" instance=ExtResource("6_wslmk")]
|
||||
unique_name_in_owner = true
|
||||
show_behind_parent = true
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="WrongFX" parent="TextureButton" instance=ExtResource("7_241b6")]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="Label" type="Label" parent="."]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_right = -39.0
|
||||
offset_bottom = -57.0
|
||||
offset_left = -150.0
|
||||
offset_top = -150.0
|
||||
offset_right = 150.0
|
||||
offset_bottom = 111.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
text = "A"
|
||||
text = "ent"
|
||||
label_settings = ExtResource("8_4pqhl")
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="WrongFX" parent="." instance=ExtResource("7_241b6")]
|
||||
|
||||
[node name="VisibleOnScreenNotifier2D" type="VisibleOnScreenNotifier2D" parent="."]
|
||||
|
||||
[connection signal="animation_finished" from="AnimationPlayer" to="." method="_on_animation_player_animation_finished"]
|
||||
|
||||
@@ -12,14 +12,14 @@ const lilypad_crossing_time: = 5.0
|
||||
@onready var audio_player: = $AudioStreamPlayer2D
|
||||
@onready var spawn_timer: = $SpawnTimer
|
||||
|
||||
var top_to_bottom: = false
|
||||
var ready_to_spawn: = false
|
||||
var is_cleared: = false
|
||||
var is_enabled: = false:
|
||||
set = _set_enabled
|
||||
var is_highlighting: = false:
|
||||
set = _set_highlighting
|
||||
var top_to_bottom: bool = false
|
||||
var is_stopped: bool = false
|
||||
var is_cleared: bool = false
|
||||
var is_enabled: bool = false:
|
||||
set = _set_enabled
|
||||
var is_highlighting: bool = false:
|
||||
set = _set_highlighting
|
||||
|
||||
|
||||
var difficulty_settings: FrogMinigame.DifficultySettings
|
||||
var gp: Dictionary = {}:
|
||||
@@ -52,8 +52,6 @@ func _get_velocity() -> float:
|
||||
|
||||
|
||||
func reset() -> void:
|
||||
is_cleared = false
|
||||
ready_to_spawn = false
|
||||
is_enabled = false
|
||||
is_stopped = true
|
||||
|
||||
@@ -64,12 +62,10 @@ func reset() -> void:
|
||||
|
||||
|
||||
func start() -> void:
|
||||
ready_to_spawn = true
|
||||
is_stopped = false
|
||||
|
||||
|
||||
func stop() -> void:
|
||||
ready_to_spawn = false
|
||||
is_stopped = true
|
||||
|
||||
|
||||
@@ -101,10 +97,10 @@ func _spawn_lilypad() -> void:
|
||||
else:
|
||||
lilypad.global_position = global_position + Vector2(size.x / 2.0, size.y)
|
||||
|
||||
lilypad_size = lilypad.get_real_size()
|
||||
lilypad_size = lilypad.button.size
|
||||
if size.x < lilypad_size.x:
|
||||
var s: float = size.x / lilypad_size.x
|
||||
lilypad.scale = Vector2(s, s)
|
||||
lilypad.button.scale = Vector2(s, s)
|
||||
lilypad_size *= s
|
||||
|
||||
var is_stimulus: = randf() < difficulty_settings.stimuli_ratio
|
||||
@@ -133,8 +129,9 @@ func _despawn_lilypad(lilypad: Lilypad) -> void:
|
||||
|
||||
func _set_enabled(value: bool) -> void:
|
||||
is_enabled = value
|
||||
for lilypad in lilypads:
|
||||
lilypad.disabled = not is_enabled
|
||||
if not is_cleared:
|
||||
for lilypad in lilypads:
|
||||
lilypad.disabled = not is_enabled
|
||||
|
||||
|
||||
func _set_highlighting(value: bool) -> void:
|
||||
@@ -150,7 +147,7 @@ func _set_highlighting(value: bool) -> void:
|
||||
#region Connections
|
||||
|
||||
func _on_lilypad_pressed(lilypad: Lilypad) -> void:
|
||||
if is_cleared:
|
||||
if is_cleared or is_stopped:
|
||||
return
|
||||
audio_player.play()
|
||||
stop()
|
||||
@@ -174,7 +171,7 @@ func _on_center_tween_finished(lilypad: Lilypad, center_tween: Tween) -> void:
|
||||
|
||||
|
||||
func _on_spawn_timer_timeout() -> void:
|
||||
if ready_to_spawn:
|
||||
if not is_stopped:
|
||||
_spawn_lilypad()
|
||||
|
||||
# Makes sure the lilypads don't overlap
|
||||
|
||||
Reference in New Issue
Block a user