Frog minigame
This commit is contained in:
@@ -12,3 +12,7 @@ func _on_crabs_button_pressed() -> void:
|
||||
|
||||
func _on_parakeets_button_pressed() -> void:
|
||||
get_tree().change_scene_to_file("res://sources/minigames/parakeets/parakeets_minigame.tscn")
|
||||
|
||||
|
||||
func _on_frog_button_pressed() -> void:
|
||||
get_tree().change_scene_to_file("res://sources/minigames/frog/frog_minigame.tscn")
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
[gd_scene load_steps=6 format=3 uid="uid://dla6fxetre5pl"]
|
||||
[gd_scene load_steps=7 format=3 uid="uid://dla6fxetre5pl"]
|
||||
|
||||
[ext_resource type="Script" path="res://sources/menus/minigame_selection.gd" id="1_8yhlq"]
|
||||
[ext_resource type="FontFile" uid="uid://b2l4jfylc1v41" path="res://assets/fonts/DidactGothic-Regular.ttf" id="1_s5eb1"]
|
||||
[ext_resource type="Texture2D" uid="uid://c3okdxpi317x5" path="res://assets/minigames/monkeys/graphic/gauge_icon_monkey_full.png" id="2_prxem"]
|
||||
[ext_resource type="Texture2D" uid="uid://cq5wwf7y1msh7" path="res://assets/minigames/crabs/graphic/gauge_icon_crab_full.png" id="3_wq58l"]
|
||||
[ext_resource type="Texture2D" uid="uid://di2qcv6jw8wh0" path="res://assets/minigames/parakeets/graphic/gauge_icon_parakeet_full.png" id="4_b8s0s"]
|
||||
[ext_resource type="Texture2D" uid="uid://re7qgivb3n5w" path="res://assets/minigames/frog/graphics/gauge_icon_frog_full.png" id="6_bke25"]
|
||||
|
||||
[node name="MinigameSelection" type="Control"]
|
||||
layout_mode = 3
|
||||
@@ -59,6 +60,17 @@ icon = ExtResource("4_b8s0s")
|
||||
icon_alignment = 2
|
||||
expand_icon = true
|
||||
|
||||
[node name="FrogButton" type="Button" parent="VBoxContainer"]
|
||||
custom_minimum_size = Vector2(500, 2.08165e-12)
|
||||
layout_mode = 2
|
||||
theme_override_fonts/font = ExtResource("1_s5eb1")
|
||||
theme_override_font_sizes/font_size = 100
|
||||
text = "Frog"
|
||||
icon = ExtResource("6_bke25")
|
||||
icon_alignment = 2
|
||||
expand_icon = true
|
||||
|
||||
[connection signal="pressed" from="VBoxContainer/MonkeysButton" to="." method="_on_monkeys_button_pressed"]
|
||||
[connection signal="pressed" from="VBoxContainer/CrabsButton" to="." method="_on_crabs_button_pressed"]
|
||||
[connection signal="pressed" from="VBoxContainer/ParakeetsButton" to="." method="_on_parakeets_button_pressed"]
|
||||
[connection signal="pressed" from="VBoxContainer/FrogButton" to="." method="_on_frog_button_pressed"]
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
[ext_resource type="Texture2D" uid="uid://dqtmyedk1ylbw" path="res://assets/minigames/minigame_ui/graphic/button_replay_up.png" id="17_ipxst"]
|
||||
[ext_resource type="Texture2D" uid="uid://bvu8ud6hkwusb" path="res://assets/minigames/minigame_ui/graphic/button_replay_down.png" id="18_5pefo"]
|
||||
[ext_resource type="Texture2D" uid="uid://d4ffd4us2hrbs" path="res://assets/minigames/minigame_ui/graphic/button_replay_disabled.png" id="19_mm65c"]
|
||||
[ext_resource type="PackedScene" uid="uid://c4t2cq5vyj4ai" path="res://sources/minigames/base/kalulu.tscn" id="19_wn4nd"]
|
||||
[ext_resource type="PackedScene" uid="uid://blos4rn53qkwg" path="res://sources/minigames/base/kalulu.tscn" id="19_wn4nd"]
|
||||
[ext_resource type="Texture2D" uid="uid://db64tlixplfru" path="res://assets/minigames/minigame_ui/graphic/life_empty.png" id="20_jyeyb"]
|
||||
[ext_resource type="Texture2D" uid="uid://dkvf2b6b1keqf" path="res://assets/minigames/minigame_ui/graphic/volume_up.png" id="20_qsa3m"]
|
||||
[ext_resource type="Texture2D" uid="uid://blgoagm5j5jh2" path="res://assets/minigames/minigame_ui/graphic/volume_down.png" id="21_g5me6"]
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
extends Node2D
|
||||
|
||||
signal flooded
|
||||
|
||||
@export var jump_distance: = 240.0:
|
||||
set(value):
|
||||
jump_distance = value
|
||||
if jump_area_collision:
|
||||
jump_area_collision.position = Vector2(jump_distance / 2.0, 0.0)
|
||||
jump_area_collision.shape.height = jump_distance * 1.5
|
||||
|
||||
@onready var sprite: = $AnimatedSprite2D
|
||||
@onready var jump_area: = $JumpArea
|
||||
@onready var jump_area_collision: = $JumpArea/CollisionShape2D
|
||||
@onready var frog_area: = $FrogArea
|
||||
|
||||
var follow_mouse: = false
|
||||
var is_jumping: = false
|
||||
var land_area: Area2D
|
||||
|
||||
|
||||
func _ready():
|
||||
jump_distance = jump_distance
|
||||
|
||||
|
||||
func _physics_process(_delta: float) -> void:
|
||||
if follow_mouse:
|
||||
var direction: = _get_mouse_direction()
|
||||
jump_area.rotation = direction.angle()
|
||||
|
||||
if not is_jumping:
|
||||
if land_area != null:
|
||||
global_position = land_area.global_position
|
||||
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if not is_jumping:
|
||||
if event is InputEventMouseButton:
|
||||
if event.button_index == MOUSE_BUTTON_LEFT:
|
||||
follow_mouse = event.pressed
|
||||
|
||||
if not event.pressed:
|
||||
var direction: = _get_mouse_direction()
|
||||
_jump(direction)
|
||||
|
||||
|
||||
func _jump(direction: Vector2) -> void:
|
||||
_search_for_land_area()
|
||||
|
||||
# Checking if there is somewhere to land
|
||||
var area: Area2D
|
||||
var dist: = jump_distance * 2.0
|
||||
for other_area in jump_area.get_overlapping_areas():
|
||||
if other_area != frog_area and other_area != land_area:
|
||||
var other_dist: float = (other_area.global_position - global_position).length()
|
||||
if area == null or other_dist < dist:
|
||||
area = other_area
|
||||
dist = other_dist
|
||||
|
||||
land_area = null
|
||||
var destination: = global_position + jump_distance * direction
|
||||
if area != null:
|
||||
destination = area.global_position
|
||||
|
||||
# actual jump
|
||||
is_jumping = true
|
||||
sprite.play("jump_side")
|
||||
var tween: = create_tween()
|
||||
tween.tween_property(self, "global_position", destination, 0.1)
|
||||
await tween.finished
|
||||
|
||||
# Landing
|
||||
land_area = area
|
||||
sprite.play("idle_side")
|
||||
|
||||
if area:
|
||||
if area.owner is Lilypad:
|
||||
var lilypad: = area.owner
|
||||
if not lilypad.frog_landed():
|
||||
flooded.emit()
|
||||
else:
|
||||
flooded.emit()
|
||||
|
||||
is_jumping = false
|
||||
|
||||
|
||||
func _search_for_land_area() -> void:
|
||||
var overlapping_areas: Array = frog_area.get_overlapping_areas()
|
||||
if overlapping_areas.size() != 0:
|
||||
land_area = overlapping_areas[0]
|
||||
else:
|
||||
land_area = null
|
||||
|
||||
|
||||
func _reset() -> void:
|
||||
land_area = null
|
||||
|
||||
|
||||
func _on_animated_sprite_2d_animation_finished() -> void:
|
||||
sprite.play("idle_side")
|
||||
|
||||
|
||||
func _get_mouse_direction() -> Vector2:
|
||||
return (get_global_mouse_position() - global_position).normalized()
|
||||
@@ -0,0 +1,198 @@
|
||||
[gd_scene load_steps=41 format=3 uid="uid://ca0ul885cbe41"]
|
||||
|
||||
[ext_resource type="Script" path="res://sources/minigames/frog/frog/frog.gd" id="1_3i23t"]
|
||||
[ext_resource type="Texture2D" uid="uid://3i2kdog0hcd7" path="res://assets/minigames/frog/graphics/frog_animations/frog_front_idle_01_00.png" id="1_syiy8"]
|
||||
[ext_resource type="Texture2D" uid="uid://cnxaaavna1iut" path="res://assets/minigames/frog/graphics/frog_animations/frog_front_idle_01_01.png" id="2_4q8yu"]
|
||||
[ext_resource type="Texture2D" uid="uid://dl4ny8xqds5wd" path="res://assets/minigames/frog/graphics/frog_animations/frog_front_idle_01_02.png" id="3_bkha4"]
|
||||
[ext_resource type="Texture2D" uid="uid://cgxxr6yt214se" path="res://assets/minigames/frog/graphics/frog_animations/frog_front_idle_01_03.png" id="4_d22w8"]
|
||||
[ext_resource type="Texture2D" uid="uid://bdf0wkxihsdr5" path="res://assets/minigames/frog/graphics/frog_animations/frog_front_idle_01_04.png" id="5_kn1ir"]
|
||||
[ext_resource type="Texture2D" uid="uid://cxto67h464020" path="res://assets/minigames/frog/graphics/frog_animations/frog_front_idle_01_05.png" id="6_mgjb2"]
|
||||
[ext_resource type="Texture2D" uid="uid://b347142s3nerw" path="res://assets/minigames/frog/graphics/frog_animations/frog_front_idle_02_00.png" id="7_q3xnb"]
|
||||
[ext_resource type="Texture2D" uid="uid://crjy7fv8tmbl2" path="res://assets/minigames/frog/graphics/frog_animations/frog_front_idle_02_01.png" id="8_7euu5"]
|
||||
[ext_resource type="Texture2D" uid="uid://d0t2lbtlkvlq2" path="res://assets/minigames/frog/graphics/frog_animations/frog_front_idle_02_02.png" id="9_maitf"]
|
||||
[ext_resource type="Texture2D" uid="uid://c24h7imi6h3eg" path="res://assets/minigames/frog/graphics/frog_animations/frog_front_idle_02_03.png" id="10_nw786"]
|
||||
[ext_resource type="Texture2D" uid="uid://b45e74pq5os4b" path="res://assets/minigames/frog/graphics/frog_animations/frog_front_idle_02_04.png" id="11_4iyty"]
|
||||
[ext_resource type="Texture2D" uid="uid://c8lacn7niv7um" path="res://assets/minigames/frog/graphics/frog_animations/frog_front_idle_02_05.png" id="12_twnvy"]
|
||||
[ext_resource type="Texture2D" uid="uid://dw5sb4dk4nojh" path="res://assets/minigames/frog/graphics/frog_animations/frog_side_idle02_01.png" id="13_jwiru"]
|
||||
[ext_resource type="Texture2D" uid="uid://cam2utbgn117b" path="res://assets/minigames/frog/graphics/frog_animations/frog_side_idle02_02.png" id="14_huq2e"]
|
||||
[ext_resource type="Texture2D" uid="uid://bvquobk7ejruu" path="res://assets/minigames/frog/graphics/frog_animations/frog_side_idle02_03.png" id="15_3glbm"]
|
||||
[ext_resource type="Texture2D" uid="uid://1mkfs4q3mcx4" path="res://assets/minigames/frog/graphics/frog_animations/frog_side_idle02_04.png" id="16_vm1ly"]
|
||||
[ext_resource type="Texture2D" uid="uid://cwumb5swp18sl" path="res://assets/minigames/frog/graphics/frog_animations/frog_side_idle02_05.png" id="17_rl57n"]
|
||||
[ext_resource type="Texture2D" uid="uid://djkxvpwwkw4yy" path="res://assets/minigames/frog/graphics/frog_animations/frog_side_idle_01_00.png" id="18_wqok6"]
|
||||
[ext_resource type="Texture2D" uid="uid://dv8ymga36atdh" path="res://assets/minigames/frog/graphics/frog_animations/frog_side_idle_01_01.png" id="19_43wjj"]
|
||||
[ext_resource type="Texture2D" uid="uid://brgjq3ta4dvg0" path="res://assets/minigames/frog/graphics/frog_animations/frog_side_idle_01_02.png" id="20_iympc"]
|
||||
[ext_resource type="Texture2D" uid="uid://bftjipg8mutqi" path="res://assets/minigames/frog/graphics/frog_animations/frog_side_idle_01_03.png" id="21_g2wtr"]
|
||||
[ext_resource type="Texture2D" uid="uid://dgctla7ilh5ar" path="res://assets/minigames/frog/graphics/frog_animations/frog_side_idle_01_04.png" id="22_wluk2"]
|
||||
[ext_resource type="Texture2D" uid="uid://b4bbjeqpy1f5p" path="res://assets/minigames/frog/graphics/frog_animations/frog_side_idle_01_05.png" id="23_tkkm6"]
|
||||
[ext_resource type="Texture2D" uid="uid://shsb7y1qaolu" path="res://assets/minigames/frog/graphics/frog_animations/frog_side_idle_02_00.png" id="24_h50iq"]
|
||||
[ext_resource type="Texture2D" uid="uid://5y8s5jtfough" path="res://assets/minigames/frog/graphics/frog_animations/frog_side_jump_00.png" id="25_kiv4k"]
|
||||
[ext_resource type="Texture2D" uid="uid://02cx2u6mj0wc" path="res://assets/minigames/frog/graphics/frog_animations/frog_side_jump_01.png" id="26_pdad0"]
|
||||
[ext_resource type="Texture2D" uid="uid://oclmkmjyc03q" path="res://assets/minigames/frog/graphics/frog_animations/frog_side_jump_02.png" id="27_hmo0d"]
|
||||
[ext_resource type="Texture2D" uid="uid://dycytl4eumnfq" path="res://assets/minigames/frog/graphics/frog_animations/frog_side_jump_03.png" id="28_u3a50"]
|
||||
[ext_resource type="Texture2D" uid="uid://0egt6wqodpnx" path="res://assets/minigames/frog/graphics/frog_animations/frog_side_jump_04.png" id="29_11nc4"]
|
||||
[ext_resource type="Texture2D" uid="uid://bg622tvggx87w" path="res://assets/minigames/frog/graphics/frog_animations/frog_side_jump_05.png" id="30_sjuhf"]
|
||||
[ext_resource type="Texture2D" uid="uid://b36e360ka1xum" path="res://assets/minigames/frog/graphics/frog_animations/frog_side_jump_06.png" id="31_rmnnf"]
|
||||
[ext_resource type="Texture2D" uid="uid://bn4i0hr8eygu2" path="res://assets/minigames/frog/graphics/frog_animations/frog_side_jump_07.png" id="32_cgpdx"]
|
||||
[ext_resource type="Texture2D" uid="uid://c38s3q7j4ofns" path="res://assets/minigames/frog/graphics/frog_animations/frog_side_jump_08.png" id="33_xyt2u"]
|
||||
[ext_resource type="Texture2D" uid="uid://cvosw5qtv262k" path="res://assets/minigames/frog/graphics/frog_animations/frog_side_jump_09.png" id="34_lnnwi"]
|
||||
[ext_resource type="Texture2D" uid="uid://4j6sxetbqkhh" path="res://assets/minigames/frog/graphics/frog_animations/frog_side_jump_10.png" id="35_jfqpd"]
|
||||
[ext_resource type="Texture2D" uid="uid://fb6mfwl8pu33" path="res://assets/minigames/frog/graphics/frog_animations/frog_side_jump_11.png" id="36_q67ce"]
|
||||
|
||||
[sub_resource type="SpriteFrames" id="SpriteFrames_7bxkc"]
|
||||
animations = [{
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("1_syiy8")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("2_4q8yu")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("3_bkha4")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("4_d22w8")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("5_kn1ir")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("6_mgjb2")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("7_q3xnb")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("8_7euu5")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("9_maitf")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("10_nw786")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("11_4iyty")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("12_twnvy")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"idle_front",
|
||||
"speed": 10.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("13_jwiru")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("14_huq2e")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("15_3glbm")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("16_vm1ly")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("17_rl57n")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("18_wqok6")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("19_43wjj")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("20_iympc")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("21_g2wtr")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("22_wluk2")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("23_tkkm6")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("24_h50iq")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"idle_side",
|
||||
"speed": 10.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("25_kiv4k")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("26_pdad0")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("27_hmo0d")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("28_u3a50")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("29_11nc4")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("30_sjuhf")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("31_rmnnf")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("32_cgpdx")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("33_xyt2u")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("34_lnnwi")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("35_jfqpd")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("36_q67ce")
|
||||
}],
|
||||
"loop": false,
|
||||
"name": &"jump_side",
|
||||
"speed": 110.0
|
||||
}]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_lnxyi"]
|
||||
radius = 30.0
|
||||
height = 360.0
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_h7qyi"]
|
||||
radius = 25.1794
|
||||
|
||||
[node name="Frog" type="Node2D"]
|
||||
script = ExtResource("1_3i23t")
|
||||
jump_distance = 420.0
|
||||
|
||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
||||
position = Vector2(-16, -47)
|
||||
sprite_frames = SubResource("SpriteFrames_7bxkc")
|
||||
animation = &"jump_side"
|
||||
autoplay = "idle_front"
|
||||
|
||||
[node name="JumpArea" type="Area2D" parent="."]
|
||||
position = Vector2(0, -25)
|
||||
collision_layer = 0
|
||||
monitorable = false
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="JumpArea"]
|
||||
position = Vector2(120, 0)
|
||||
rotation = -1.5708
|
||||
shape = SubResource("CapsuleShape2D_lnxyi")
|
||||
|
||||
[node name="FrogArea" type="Area2D" parent="."]
|
||||
position = Vector2(0, -25)
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="FrogArea"]
|
||||
shape = SubResource("CircleShape2D_h7qyi")
|
||||
@@ -0,0 +1,129 @@
|
||||
extends Minigame
|
||||
|
||||
const lilypad_track_class: = preload("res://sources/minigames/frog/lilypad_track/lilypad_track.tscn")
|
||||
|
||||
@export var difficulty: = 1
|
||||
@export var lesson_nb: = 4
|
||||
|
||||
@onready var frog: = $GameRoot/Frog
|
||||
@onready var start_area: = $GameRoot/Start/Area2D
|
||||
@onready var end_area: = $GameRoot/End/Area2D
|
||||
@onready var river_container: = $GameRoot/RiverContainer
|
||||
|
||||
var lilypad_tracks: Array
|
||||
var current_word: Dictionary
|
||||
var current_distractors: Array
|
||||
var end_areas: = []
|
||||
|
||||
|
||||
func _find_stimuli_and_distractions() -> void:
|
||||
var words_list: = Database.get_words_for_lesson(lesson_nb)
|
||||
words_list.shuffle()
|
||||
stimuli = []
|
||||
distractions = []
|
||||
for i in max_progression:
|
||||
var word = words_list[i].Word
|
||||
var GPs: = Database.get_GP_from_word(word)
|
||||
stimuli.append({
|
||||
Word = word,
|
||||
GPs = GPs,
|
||||
})
|
||||
var grapheme_distractions: = []
|
||||
for GP in GPs:
|
||||
grapheme_distractions.append(Database.get_distractors_for_grapheme(GP.Grapheme, lesson_nb))
|
||||
distractions.append(grapheme_distractions)
|
||||
|
||||
|
||||
func _start() -> void:
|
||||
_get_new_word()
|
||||
|
||||
|
||||
func _on_current_progression_changed() -> void:
|
||||
if stimuli.size() != 0:
|
||||
await _get_new_word()
|
||||
_reset_frog()
|
||||
end_areas = []
|
||||
else:
|
||||
_win()
|
||||
|
||||
|
||||
func _get_new_word() -> void:
|
||||
if audio_player.playing:
|
||||
await audio_player.finished
|
||||
|
||||
await _free_tracks()
|
||||
_update_current_word()
|
||||
_create_tracks()
|
||||
await _play_current_word()
|
||||
# Await a frame so the tracks can occupy all the river container
|
||||
await get_tree().process_frame
|
||||
_start_tracks()
|
||||
|
||||
|
||||
func _free_tracks() -> void:
|
||||
if lilypad_tracks.size() != 0:
|
||||
for track in lilypad_tracks:
|
||||
track.disappear()
|
||||
await lilypad_tracks[lilypad_tracks.size() - 1].disappeared
|
||||
for track in lilypad_tracks:
|
||||
track.queue_free()
|
||||
lilypad_tracks = []
|
||||
|
||||
|
||||
func _update_current_word() -> void:
|
||||
current_word = stimuli.pop_front()
|
||||
current_distractors = distractions.pop_front()
|
||||
|
||||
|
||||
func _create_tracks() -> void:
|
||||
lilypad_tracks = []
|
||||
for i in range(current_word.GPs.size()):
|
||||
var track: = lilypad_track_class.instantiate()
|
||||
river_container.add_child(track)
|
||||
lilypad_tracks.append(track)
|
||||
|
||||
var track_stimuli: = [current_word.GPs[i]]
|
||||
track_stimuli.append_array(current_distractors[i])
|
||||
var are_distractors: = [false]
|
||||
for _j in range(track_stimuli.size() - 1):
|
||||
are_distractors.append(true)
|
||||
track.stimuli = track_stimuli
|
||||
track.are_they_distractors = are_distractors
|
||||
track.top_to_bottom = i % 2
|
||||
|
||||
|
||||
func _play_current_word() -> void:
|
||||
audio_player.stream = Database.get_audio_stream_for_word(current_word.Word)
|
||||
audio_player.play()
|
||||
if audio_player.playing:
|
||||
await audio_player.finished
|
||||
|
||||
|
||||
func _start_tracks() -> void:
|
||||
for track in lilypad_tracks:
|
||||
track.ready_to_spawn = true
|
||||
|
||||
|
||||
func _reset_frog() -> void:
|
||||
frog._reset()
|
||||
frog.global_position = start_area.global_position
|
||||
|
||||
|
||||
func _on_frog_flooded() -> void:
|
||||
_reset_frog()
|
||||
|
||||
current_lives -= 1
|
||||
|
||||
for track in lilypad_tracks:
|
||||
track.restart()
|
||||
|
||||
|
||||
func _on_end_area_area_entered(area: Area2D) -> void:
|
||||
if not area in end_areas:
|
||||
end_areas.append(area)
|
||||
var all_cleared: = true
|
||||
for track in lilypad_tracks:
|
||||
all_cleared = all_cleared and track.is_cleared
|
||||
|
||||
if all_cleared:
|
||||
current_progression += 1
|
||||
@@ -0,0 +1,263 @@
|
||||
[gd_scene load_steps=18 format=3 uid="uid://dlwnfq1mt2tla"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://8awe4usnucyv" path="res://sources/minigames/base/base_minigame.tscn" id="1_avl88"]
|
||||
[ext_resource type="Script" path="res://sources/minigames/frog/frog_minigame.gd" id="2_5vus4"]
|
||||
[ext_resource type="Texture2D" uid="uid://g1pr0xqbmwcb" path="res://assets/minigames/frog/graphics/background_river.png" id="2_xejtx"]
|
||||
[ext_resource type="AudioStream" uid="uid://brvigkassgx1b" path="res://assets/minigames/frog/audio/kalulu_end_frog_all.mp3" id="3_8qoit"]
|
||||
[ext_resource type="AudioStream" uid="uid://ve3na0ebxwsr" path="res://assets/minigames/frog/audio/kalulu_help_frog_language.mp3" id="3_cqjmm"]
|
||||
[ext_resource type="Texture2D" uid="uid://cusulkkvcyxak" path="res://assets/minigames/frog/graphics/sand_left.png" id="3_si4ka"]
|
||||
[ext_resource type="Texture2D" uid="uid://c7im0b3uxb6ha" path="res://assets/minigames/frog/graphics/grass_left.png" id="4_wsj75"]
|
||||
[ext_resource type="Texture2D" uid="uid://tl6bs08l37ar" path="res://assets/minigames/frog/graphics/sand_right.png" id="5_2g3rn"]
|
||||
[ext_resource type="Texture2D" uid="uid://jvpu77isfi5b" path="res://assets/minigames/frog/graphics/gauge_icon_frog_empty.png" id="5_o5eq5"]
|
||||
[ext_resource type="Texture2D" uid="uid://dg4n6nv84tl3u" path="res://assets/minigames/frog/graphics/grass_right.png" id="6_2y56j"]
|
||||
[ext_resource type="Texture2D" uid="uid://re7qgivb3n5w" path="res://assets/minigames/frog/graphics/gauge_icon_frog_full.png" id="6_bm4cp"]
|
||||
[ext_resource type="Texture2D" uid="uid://ct24yoo1efipg" path="res://assets/minigames/frog/graphics/reed_01.png" id="7_acpkk"]
|
||||
[ext_resource type="Texture2D" uid="uid://b51kxs3qm3wiw" path="res://assets/minigames/frog/graphics/rock.png" id="7_e20fa"]
|
||||
[ext_resource type="Texture2D" uid="uid://djg2gkxxjgqwx" path="res://assets/minigames/frog/graphics/reed_02.png" id="8_2571k"]
|
||||
[ext_resource type="PackedScene" uid="uid://ca0ul885cbe41" path="res://sources/minigames/frog/frog/frog.tscn" id="13_phlg8"]
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_a0wpy"]
|
||||
radius = 100.0
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_by6y7"]
|
||||
size = Vector2(437, 1800)
|
||||
|
||||
[node name="FrogMinigame" instance=ExtResource("1_avl88")]
|
||||
mouse_filter = 2
|
||||
script = ExtResource("2_5vus4")
|
||||
difficulty = 1
|
||||
lesson_nb = 4
|
||||
max_number_of_lives = 5
|
||||
max_progression = 3
|
||||
help_kalulu_speech = ExtResource("3_cqjmm")
|
||||
win_kalulu_speech = ExtResource("3_8qoit")
|
||||
|
||||
[node name="MinigameUI" parent="." index="1"]
|
||||
empty_progression_icon = ExtResource("5_o5eq5")
|
||||
full_progression_icon = ExtResource("6_bm4cp")
|
||||
|
||||
[node name="GameRoot" parent="." index="3"]
|
||||
mouse_filter = 2
|
||||
|
||||
[node name="Background" type="Control" parent="GameRoot" index="0"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
mouse_filter = 2
|
||||
|
||||
[node name="River" type="TextureRect" parent="GameRoot/Background" index="0"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
mouse_filter = 2
|
||||
texture = ExtResource("2_xejtx")
|
||||
|
||||
[node name="LeftSand" type="TextureRect" parent="GameRoot/Background" index="1"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 9
|
||||
anchor_bottom = 1.0
|
||||
offset_right = 676.0
|
||||
grow_vertical = 2
|
||||
mouse_filter = 2
|
||||
texture = ExtResource("3_si4ka")
|
||||
|
||||
[node name="LeftGrass" type="TextureRect" parent="GameRoot/Background" index="2"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 9
|
||||
anchor_bottom = 1.0
|
||||
offset_right = 478.0
|
||||
grow_vertical = 2
|
||||
mouse_filter = 2
|
||||
texture = ExtResource("4_wsj75")
|
||||
|
||||
[node name="RightSand" type="TextureRect" parent="GameRoot/Background" index="3"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 11
|
||||
anchor_left = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = -492.0
|
||||
grow_horizontal = 0
|
||||
grow_vertical = 2
|
||||
mouse_filter = 2
|
||||
texture = ExtResource("5_2g3rn")
|
||||
|
||||
[node name="RightGrass" type="TextureRect" parent="GameRoot/Background" index="4"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 11
|
||||
anchor_left = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = -365.0
|
||||
grow_horizontal = 0
|
||||
grow_vertical = 2
|
||||
mouse_filter = 2
|
||||
texture = ExtResource("6_2y56j")
|
||||
|
||||
[node name="Scenery" type="Control" parent="GameRoot" index="1"]
|
||||
anchors_preset = 0
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
mouse_filter = 2
|
||||
|
||||
[node name="Rock" type="TextureRect" parent="GameRoot/Scenery" index="0"]
|
||||
layout_mode = 0
|
||||
offset_left = 461.0
|
||||
offset_top = 127.0
|
||||
offset_right = 556.0
|
||||
offset_bottom = 345.0
|
||||
mouse_filter = 2
|
||||
texture = ExtResource("7_acpkk")
|
||||
|
||||
[node name="Rock2" type="TextureRect" parent="GameRoot/Scenery" index="1"]
|
||||
layout_mode = 0
|
||||
offset_left = 260.0
|
||||
offset_top = 1134.0
|
||||
offset_right = 355.0
|
||||
offset_bottom = 1352.0
|
||||
mouse_filter = 2
|
||||
texture = ExtResource("7_acpkk")
|
||||
|
||||
[node name="Rock3" type="TextureRect" parent="GameRoot/Scenery" index="2"]
|
||||
layout_mode = 0
|
||||
offset_left = 2172.0
|
||||
offset_top = 184.0
|
||||
offset_right = 2337.0
|
||||
offset_bottom = 432.0
|
||||
mouse_filter = 2
|
||||
texture = ExtResource("8_2571k")
|
||||
|
||||
[node name="Rock4" type="TextureRect" parent="GameRoot/Scenery" index="3"]
|
||||
layout_mode = 0
|
||||
offset_left = 2268.0
|
||||
offset_top = 1098.0
|
||||
offset_right = 2467.0
|
||||
offset_bottom = 1388.0
|
||||
mouse_filter = 2
|
||||
texture = ExtResource("8_2571k")
|
||||
|
||||
[node name="Rock5" type="TextureRect" parent="GameRoot/Scenery" index="4"]
|
||||
layout_mode = 0
|
||||
offset_left = 263.0
|
||||
offset_top = 1383.0
|
||||
offset_right = 470.0
|
||||
offset_bottom = 1679.0
|
||||
mouse_filter = 2
|
||||
texture = ExtResource("8_2571k")
|
||||
|
||||
[node name="Rock6" type="TextureRect" parent="GameRoot/Scenery" index="5"]
|
||||
layout_mode = 0
|
||||
offset_left = 221.0
|
||||
offset_top = 467.0
|
||||
offset_right = 428.0
|
||||
offset_bottom = 763.0
|
||||
mouse_filter = 2
|
||||
texture = ExtResource("8_2571k")
|
||||
|
||||
[node name="Rock7" type="TextureRect" parent="GameRoot/Scenery" index="6"]
|
||||
layout_mode = 0
|
||||
offset_left = 2342.0
|
||||
offset_top = 467.0
|
||||
offset_right = 2457.0
|
||||
offset_bottom = 736.0
|
||||
mouse_filter = 2
|
||||
texture = ExtResource("7_acpkk")
|
||||
|
||||
[node name="Rock8" type="TextureRect" parent="GameRoot/Scenery" index="7"]
|
||||
layout_mode = 0
|
||||
offset_left = 2362.0
|
||||
offset_top = 810.0
|
||||
offset_right = 2477.0
|
||||
offset_bottom = 1079.0
|
||||
mouse_filter = 2
|
||||
texture = ExtResource("7_acpkk")
|
||||
|
||||
[node name="Rock9" type="TextureRect" parent="GameRoot/Scenery" index="8"]
|
||||
layout_mode = 0
|
||||
offset_left = 2347.0
|
||||
offset_top = 1413.0
|
||||
offset_right = 2462.0
|
||||
offset_bottom = 1682.0
|
||||
mouse_filter = 2
|
||||
texture = ExtResource("7_acpkk")
|
||||
|
||||
[node name="Start" type="Control" parent="GameRoot" index="2"]
|
||||
anchors_preset = 0
|
||||
offset_left = 478.0
|
||||
offset_top = 900.0
|
||||
offset_right = 518.0
|
||||
offset_bottom = 940.0
|
||||
mouse_filter = 2
|
||||
|
||||
[node name="Rock" type="TextureRect" parent="GameRoot/Start" index="0"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -143.0
|
||||
offset_top = -170.0
|
||||
offset_right = 68.0
|
||||
offset_bottom = 79.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
mouse_filter = 2
|
||||
texture = ExtResource("7_e20fa")
|
||||
|
||||
[node name="Area2D" type="Area2D" parent="GameRoot/Start" index="1"]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="GameRoot/Start/Area2D" index="0"]
|
||||
shape = SubResource("CircleShape2D_a0wpy")
|
||||
|
||||
[node name="End" type="Control" parent="GameRoot" index="3"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
offset_left = 2341.5
|
||||
offset_top = 900.0
|
||||
offset_right = 2381.5
|
||||
offset_bottom = 940.0
|
||||
mouse_filter = 2
|
||||
|
||||
[node name="Rock" type="TextureRect" parent="GameRoot/End" index="0"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -140.5
|
||||
offset_top = -175.0
|
||||
offset_right = 70.5
|
||||
offset_bottom = 74.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
mouse_filter = 2
|
||||
texture = ExtResource("7_e20fa")
|
||||
|
||||
[node name="Area2D" type="Area2D" parent="GameRoot/End" index="1"]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="GameRoot/End/Area2D" index="0"]
|
||||
shape = SubResource("RectangleShape2D_by6y7")
|
||||
|
||||
[node name="RiverContainer" type="HBoxContainer" parent="GameRoot" index="4"]
|
||||
layout_mode = 0
|
||||
offset_left = 710.0
|
||||
offset_top = -500.0
|
||||
offset_right = 2030.0
|
||||
offset_bottom = 2300.0
|
||||
mouse_filter = 2
|
||||
theme_override_constants/separation = 50
|
||||
alignment = 1
|
||||
|
||||
[node name="Frog" parent="GameRoot" index="5" instance=ExtResource("13_phlg8")]
|
||||
position = Vector2(478, 900)
|
||||
|
||||
[connection signal="area_entered" from="GameRoot/End/Area2D" to="." method="_on_end_area_area_entered"]
|
||||
[connection signal="flooded" from="GameRoot/Frog" to="." method="_on_frog_flooded"]
|
||||
@@ -0,0 +1,44 @@
|
||||
extends Node2D
|
||||
class_name Lilypad
|
||||
|
||||
signal frog_land()
|
||||
signal frog_fall()
|
||||
|
||||
@onready var animation_player: = $AnimationPlayer
|
||||
@onready var sprite: = $Sprite2D
|
||||
@onready var label: = $Label
|
||||
|
||||
var stimulus: Dictionary:
|
||||
set(value):
|
||||
stimulus = value
|
||||
label.text = stimulus["Grapheme"]
|
||||
var is_distractor: = true:
|
||||
set(value):
|
||||
is_distractor = value
|
||||
if is_distractor:
|
||||
label.set("theme_override_colors/font_color", Color.BLACK)
|
||||
else:
|
||||
label.set("theme_override_colors/font_color", Color.WHITE)
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
sprite.material.set_shader_parameter("dissolve_amount", 1.0)
|
||||
|
||||
|
||||
func frog_landed() -> bool:
|
||||
if is_distractor:
|
||||
frog_fall.emit()
|
||||
return false
|
||||
else:
|
||||
frog_land.emit()
|
||||
return true
|
||||
|
||||
|
||||
func appear() -> void:
|
||||
sprite.material.set_shader_parameter("dissolve_amount", 0.0)
|
||||
label.visible = true
|
||||
|
||||
|
||||
func disappear() -> void:
|
||||
animation_player.play("flood")
|
||||
await animation_player.animation_finished
|
||||
@@ -0,0 +1,21 @@
|
||||
shader_type canvas_item;
|
||||
|
||||
uniform sampler2D dissolve_texture;
|
||||
uniform vec4 burn_color : source_color = vec4(0.0, 1.0, 1.0, 1.0);
|
||||
uniform float burn_size = 0.1;
|
||||
uniform float dissolve_amount : hint_range(0, 1) = 0.0;
|
||||
uniform float emission_amount = 1.0;
|
||||
|
||||
|
||||
void fragment() {
|
||||
vec4 out_color = texture(TEXTURE, UV);
|
||||
|
||||
float dissolve = dissolve_amount * (1.0 + 2.0 * burn_size) - burn_size;
|
||||
|
||||
float sample = texture(dissolve_texture, UV).r;
|
||||
float emission_value = 1.0 - smoothstep(dissolve, dissolve + burn_size, sample);
|
||||
vec3 emission = burn_color.rgb * emission_value * emission_amount;
|
||||
|
||||
COLOR = vec4(max(out_color.rgb, emission), smoothstep(dissolve - burn_size, dissolve, sample) * out_color.a);
|
||||
COLOR.rgb = clamp(COLOR.rgb / COLOR.a, vec3(0.0), vec3(1.0));
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
[gd_scene load_steps=12 format=3 uid="uid://dvf5bgmolayed"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://bl4csvpvhsgqh" path="res://assets/minigames/frog/graphics/lilypad_enabled.png" id="1_8x2di"]
|
||||
[ext_resource type="Script" path="res://sources/minigames/frog/lilypad/lilypad.gd" id="1_opnqg"]
|
||||
[ext_resource type="Shader" path="res://sources/minigames/frog/lilypad/lilypad.gdshader" id="2_2dv6s"]
|
||||
|
||||
[sub_resource type="Animation" id="Animation_erfnk"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Sprite2D:material:shader_parameter/dissolve_amount")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [0.0]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("Label:visible")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [true]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_mxa6m"]
|
||||
resource_name = "flood"
|
||||
length = 0.5
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Sprite2D:material:shader_parameter/dissolve_amount")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.5),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [0.0, 1.0]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("Label:visible")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0, 0.5),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 1,
|
||||
"values": [true, false]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_m3l6k"]
|
||||
_data = {
|
||||
"RESET": SubResource("Animation_erfnk"),
|
||||
"flood": SubResource("Animation_mxa6m")
|
||||
}
|
||||
|
||||
[sub_resource type="Gradient" id="Gradient_vlqm1"]
|
||||
colors = PackedColorArray(1, 1, 1, 1, 0, 0, 0, 1)
|
||||
|
||||
[sub_resource type="FastNoiseLite" id="FastNoiseLite_ni3sy"]
|
||||
frequency = 0.015
|
||||
fractal_type = 3
|
||||
fractal_gain = 0.1
|
||||
fractal_weighted_strength = 1.0
|
||||
fractal_ping_pong_strength = 4.0
|
||||
domain_warp_enabled = true
|
||||
domain_warp_amplitude = 20.0
|
||||
domain_warp_fractal_type = 2
|
||||
domain_warp_fractal_lacunarity = 2.0
|
||||
domain_warp_fractal_gain = 0.1
|
||||
|
||||
[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_q1q7t"]
|
||||
width = 256
|
||||
height = 256
|
||||
seamless_blend_skirt = 0.0
|
||||
color_ramp = SubResource("Gradient_vlqm1")
|
||||
noise = SubResource("FastNoiseLite_ni3sy")
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_gigvy"]
|
||||
resource_local_to_scene = true
|
||||
shader = ExtResource("2_2dv6s")
|
||||
shader_parameter/burn_color = Color(0.156863, 0.192157, 1, 1)
|
||||
shader_parameter/burn_size = 0.3
|
||||
shader_parameter/dissolve_amount = 0.0
|
||||
shader_parameter/emission_amount = 1.0
|
||||
shader_parameter/dissolve_texture = SubResource("NoiseTexture2D_q1q7t")
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_m3jds"]
|
||||
radius = 51.0098
|
||||
|
||||
[node name="Lilypad" type="Node2D"]
|
||||
script = ExtResource("1_opnqg")
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
libraries = {
|
||||
"": SubResource("AnimationLibrary_m3l6k")
|
||||
}
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
material = SubResource("ShaderMaterial_gigvy")
|
||||
texture = ExtResource("1_8x2di")
|
||||
|
||||
[node name="Area2D" type="Area2D" parent="."]
|
||||
collision_mask = 0
|
||||
monitoring = false
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
|
||||
shape = SubResource("CircleShape2D_m3jds")
|
||||
|
||||
[node name="Label" type="Label" parent="."]
|
||||
offset_left = -48.0
|
||||
offset_top = -48.0
|
||||
offset_right = 49.0
|
||||
offset_bottom = 47.0
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
@@ -0,0 +1,147 @@
|
||||
extends Control
|
||||
|
||||
signal disappeared
|
||||
|
||||
@export var lilypad_crossing_time: = 5.0
|
||||
@export var number_of_lilypad: = 25.0
|
||||
|
||||
const lilypad_class: = preload("res://sources/minigames/frog/lilypad/lilypad.tscn")
|
||||
|
||||
@onready var spawn_timer: = $SpawnTimer
|
||||
|
||||
var is_cleared: = false
|
||||
var stimuli: = []
|
||||
var are_they_distractors: = []
|
||||
var ready_to_spawn: = false
|
||||
var despawned_lilypads: = []
|
||||
var spawned_lilypads: = []
|
||||
var tweens: Array[Tween] = []
|
||||
var top_point: = Vector2.ZERO
|
||||
var bottom_point: = Vector2.ZERO
|
||||
var center_point: = Vector2.ZERO
|
||||
var lilypad_scale: = 1.0
|
||||
var top_to_bottom: = true
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
for i in range(number_of_lilypad):
|
||||
var lilypad: = lilypad_class.instantiate()
|
||||
add_child(lilypad)
|
||||
despawned_lilypads.append(lilypad)
|
||||
|
||||
lilypad.position = top_point
|
||||
|
||||
lilypad.frog_land.connect(_on_lilypad_frog_land.bind(lilypad))
|
||||
lilypad.frog_fall.connect(_on_lilypad_frog_fall.bind(lilypad))
|
||||
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
if ready_to_spawn and stimuli.size() != 0:
|
||||
var index: = randi() % stimuli.size()
|
||||
_spawn_lilypad(stimuli[index], are_they_distractors[index])
|
||||
|
||||
|
||||
func disappear() -> void:
|
||||
if spawned_lilypads.size() != 0:
|
||||
for i in range(1, spawned_lilypads.size()):
|
||||
_despawn_lilypad(spawned_lilypads[i])
|
||||
await _despawn_lilypad(spawned_lilypads[0])
|
||||
|
||||
disappeared.emit()
|
||||
|
||||
|
||||
func restart() -> void:
|
||||
_reset_tweens()
|
||||
|
||||
for lilypad in spawned_lilypads:
|
||||
_despawn_lilypad(lilypad)
|
||||
|
||||
ready_to_spawn = true
|
||||
is_cleared = false
|
||||
|
||||
|
||||
func _spawn_lilypad(stimulus: Dictionary, is_distractor: bool) -> void:
|
||||
if despawned_lilypads.size() != 0:
|
||||
var lilypad: Node2D = despawned_lilypads.pop_front()
|
||||
spawned_lilypads.append(lilypad)
|
||||
|
||||
var start: = Vector2.ZERO
|
||||
var end: = Vector2.ZERO
|
||||
if top_to_bottom:
|
||||
start = top_point
|
||||
end = bottom_point
|
||||
else:
|
||||
start = bottom_point
|
||||
end = top_point
|
||||
|
||||
lilypad.scale = Vector2(lilypad_scale, lilypad_scale)
|
||||
lilypad.stimulus = stimulus
|
||||
lilypad.is_distractor = is_distractor
|
||||
lilypad.position = start
|
||||
lilypad.appear()
|
||||
|
||||
var tween: = create_tween()
|
||||
tween.tween_property(lilypad, "position", end, lilypad_crossing_time)
|
||||
tween.finished.connect(_on_lilypad_traveling_ended.bind(lilypad, tween))
|
||||
tweens.append(tween)
|
||||
|
||||
ready_to_spawn = false
|
||||
spawn_timer.start(randf_range(0.5, 1.5))
|
||||
|
||||
|
||||
func _despawn_lilypad(lilypad: Node2D) -> void:
|
||||
if lilypad in spawned_lilypads:
|
||||
await lilypad.disappear()
|
||||
despawned_lilypads.append(lilypad)
|
||||
spawned_lilypads.erase(lilypad)
|
||||
lilypad.position = top_point
|
||||
|
||||
|
||||
func _reset_tweens() -> void:
|
||||
for tween in tweens:
|
||||
tween.pause()
|
||||
tween.kill()
|
||||
tweens = []
|
||||
|
||||
|
||||
func _on_lilypad_frog_land(lilypad: Node2D) -> void:
|
||||
_reset_tweens()
|
||||
|
||||
for other_lilypad in spawned_lilypads:
|
||||
if other_lilypad != lilypad:
|
||||
_despawn_lilypad(other_lilypad)
|
||||
|
||||
var tween: = create_tween()
|
||||
tween.tween_property(lilypad, "position", center_point, 0.5)
|
||||
tweens.append(tween)
|
||||
|
||||
spawn_timer.stop()
|
||||
ready_to_spawn = false
|
||||
is_cleared = true
|
||||
|
||||
|
||||
func _on_lilypad_frog_fall(lilypad: Node2D) -> void:
|
||||
_despawn_lilypad(lilypad)
|
||||
|
||||
|
||||
func _on_lilypad_traveling_ended(lilypad: Node2D, tween) -> void:
|
||||
_despawn_lilypad(lilypad)
|
||||
tweens.erase(tween)
|
||||
|
||||
|
||||
func _on_spawn_timer_timeout() -> void:
|
||||
ready_to_spawn = true
|
||||
|
||||
|
||||
func _on_resized() -> void:
|
||||
var rect: = get_rect()
|
||||
|
||||
top_point.x = size.x / 2.0
|
||||
top_point.y = 0
|
||||
|
||||
bottom_point.x = size.x / 2.0
|
||||
bottom_point.y = rect.size.y
|
||||
|
||||
center_point = rect.size / 2.0
|
||||
|
||||
lilypad_scale = rect.size.x / 100.0
|
||||
@@ -0,0 +1,22 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://co3l70wcwpyrj"]
|
||||
|
||||
[ext_resource type="Script" path="res://sources/minigames/frog/lilypad_track/lilypad_track.gd" id="1_lybcb"]
|
||||
|
||||
[node name="LiLypadTrack" type="Control"]
|
||||
custom_minimum_size = Vector2(0, 2800)
|
||||
layout_mode = 3
|
||||
anchors_preset = 14
|
||||
anchor_top = 0.5
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 0.5
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
mouse_filter = 2
|
||||
script = ExtResource("1_lybcb")
|
||||
|
||||
[node name="SpawnTimer" type="Timer" parent="."]
|
||||
|
||||
[connection signal="resized" from="." to="." method="_on_resized"]
|
||||
[connection signal="timeout" from="SpawnTimer" to="." method="_on_spawn_timer_timeout"]
|
||||
Reference in New Issue
Block a user