Small changes to parakeets
This commit is contained in:
@@ -42,20 +42,22 @@ var distractions: = []
|
||||
# Lives
|
||||
var current_lives: = 0 :
|
||||
set(value):
|
||||
if value == 0 and current_lives != 0:
|
||||
_lose()
|
||||
var previous_lives: = current_lives
|
||||
current_lives = value
|
||||
if minigame_ui:
|
||||
minigame_ui.set_number_of_lives(value)
|
||||
if value == 0 and previous_lives != 0:
|
||||
_lose()
|
||||
|
||||
# Progression
|
||||
var current_progression: = 0 :
|
||||
set(value):
|
||||
if value == max_progression and current_progression != max_progression:
|
||||
_win()
|
||||
var previous_progression: = current_progression
|
||||
current_progression = value
|
||||
if minigame_ui:
|
||||
minigame_ui.set_current_progression(value)
|
||||
if value == max_progression and previous_progression != max_progression:
|
||||
_win()
|
||||
|
||||
|
||||
# ------------ Initialisation ------------
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
[gd_scene load_steps=10 format=3 uid="uid://cmoeum0oc0p2"]
|
||||
|
||||
[ext_resource type="Script" path="res://sources/minigames/parakeets/parakeet.gd" id="1_dc5e0"]
|
||||
[ext_resource type="SpriteFrames" uid="uid://c4xffrugn6xgx" path="res://sources/minigames/parakeets/yellow_parakeet_spritesheet.tres" id="2_qdecy"]
|
||||
[ext_resource type="FontFile" uid="uid://b2l4jfylc1v41" path="res://resources/fonts/DidactGothic-Regular.ttf" id="5_k8sc4"]
|
||||
[ext_resource type="Script" path="res://sources/minigames/parakeets/parakeet.gd" id="1_p0nqk"]
|
||||
[ext_resource type="SpriteFrames" uid="uid://wybpq21deku7" path="res://sources/minigames/parakeets/red_parakeet_animations.tres" id="2_05lo6"]
|
||||
[ext_resource type="FontFile" uid="uid://b2l4jfylc1v41" path="res://assets/fonts/DidactGothic-Regular.ttf" id="5_k8sc4"]
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_chx0h"]
|
||||
font = ExtResource("5_k8sc4")
|
||||
@@ -19,12 +19,11 @@ font_size = 60
|
||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_45x46"]
|
||||
|
||||
[node name="Parakeet" type="Node2D"]
|
||||
script = ExtResource("1_dc5e0")
|
||||
sad_duration = null
|
||||
script = ExtResource("1_p0nqk")
|
||||
|
||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
||||
scale = Vector2(1.5, 1.5)
|
||||
sprite_frames = ExtResource("2_qdecy")
|
||||
sprite_frames = ExtResource("2_05lo6")
|
||||
animation = &"sad"
|
||||
autoplay = "idle_front"
|
||||
offset = Vector2(2.08165e-12, -82)
|
||||
|
||||
@@ -27,6 +27,7 @@ const audio_streams: = [
|
||||
@export var fly_duration: = 3.0
|
||||
|
||||
@onready var possible_positions_parent: = $GameRoot/PossiblePositions
|
||||
@onready var possible_start_positions_parent: = $GameRoot/FlyFrom
|
||||
@onready var parakeets_node: = $GameRoot/Parakeets
|
||||
@onready var nest_positions: Array[Vector2] = [$GameRoot/TreeNestFront/Position1.global_position, $GameRoot/TreeNestFront/Position2.global_position]
|
||||
@onready var fly_away_positions: Array[Vector2] = [$GameRoot/FlyAway/Position1.global_position, $GameRoot/FlyAway/Position2.global_position]
|
||||
@@ -35,7 +36,6 @@ const audio_streams: = [
|
||||
var parakeets: Array[Parakeet]
|
||||
var selected: Array[Parakeet]
|
||||
var state: = State.Locked
|
||||
var correct_count: = 0
|
||||
|
||||
const difficulty_settings: = {
|
||||
0 : {"pairs_count": 2},
|
||||
@@ -64,17 +64,18 @@ func _setup_minigame() -> void:
|
||||
var settings: Dictionary = difficulty_settings[difficulty]
|
||||
|
||||
var pairs_count: int = settings.pairs_count
|
||||
var possible_positions: = possible_positions_parent.get_children()
|
||||
possible_positions.shuffle()
|
||||
var possible_start_positions: Array = possible_start_positions_parent.get_children()
|
||||
possible_start_positions.shuffle()
|
||||
var stimuli2: = stimuli.duplicate()
|
||||
stimuli2.shuffle()
|
||||
max_progression = pairs_count
|
||||
for i in pairs_count:
|
||||
var new_parakeet1: Parakeet = Parakeet.instantiate()
|
||||
var new_parakeet2: Parakeet = Parakeet.instantiate()
|
||||
parakeets_node.add_child(new_parakeet1)
|
||||
parakeets_node.add_child(new_parakeet2)
|
||||
new_parakeet1.position = possible_positions[2 * i].position
|
||||
new_parakeet2.position = possible_positions[2 * i + 1].position
|
||||
new_parakeet1.global_position = possible_start_positions[2 * i].global_position
|
||||
new_parakeet2.global_position = possible_start_positions[2 * i + 1].global_position
|
||||
parakeets.append_array([new_parakeet1, new_parakeet2])
|
||||
var stimulus: Dictionary = stimuli2.pop_back()
|
||||
var stimulus_up: = stimulus.duplicate()
|
||||
@@ -97,6 +98,9 @@ func _find_stimuli_and_distractions() -> void:
|
||||
|
||||
|
||||
func _start() -> void:
|
||||
var possible_positions: = possible_positions_parent.get_children()
|
||||
possible_positions.shuffle()
|
||||
await _flying_arrival(possible_positions)
|
||||
_present_parakeets()
|
||||
|
||||
|
||||
@@ -145,17 +149,16 @@ func _correct() -> void:
|
||||
|
||||
await _fly_to(fly_away_positions)
|
||||
|
||||
correct_count += 1
|
||||
if correct_count * 2 >= parakeets.size():
|
||||
_win()
|
||||
else:
|
||||
state = State.Idle
|
||||
selected.clear()
|
||||
current_progression += 1
|
||||
state = State.Idle
|
||||
selected.clear()
|
||||
|
||||
|
||||
func _wrong() -> void:
|
||||
await _make_selected_sad()
|
||||
|
||||
current_lives -= 1
|
||||
|
||||
for parakeet in selected:
|
||||
parakeet.idle()
|
||||
await _parakeets_to_front(selected)
|
||||
@@ -223,3 +226,16 @@ func _turn(parakeet: Parakeet, to_back: bool) -> void:
|
||||
await parakeet.turn_to_back()
|
||||
else:
|
||||
await parakeet.turn_to_front()
|
||||
|
||||
|
||||
func _flying_arrival(to: Array) -> void:
|
||||
assert(parakeets.size() <= to.size(), "Some parakeets don't have a destination")
|
||||
var coroutine: = Coroutine.new()
|
||||
audio_player.stream = audio_streams[Audio.Fly]
|
||||
audio_player.play()
|
||||
coroutine.add_future(audio_player.finished)
|
||||
for i in parakeets.size():
|
||||
coroutine.add_future(parakeets[i].fly_to.bind(to[i].global_position, fly_duration))
|
||||
await coroutine.join()
|
||||
for parakeet in parakeets:
|
||||
parakeet.idle()
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
script = ExtResource("2_x6xn5")
|
||||
difficulty = 1
|
||||
fly_duration = 3.0
|
||||
max_number_of_lives = 5
|
||||
help_kalulu_speech = ExtResource("3_ofxb4")
|
||||
win_kalulu_speech = ExtResource("4_01e28")
|
||||
|
||||
@@ -233,3 +234,106 @@ offset_left = 186.0
|
||||
offset_top = 43.0
|
||||
offset_right = 226.0
|
||||
offset_bottom = 83.0
|
||||
|
||||
[node name="FlyFrom" type="Control" parent="GameRoot" index="12"]
|
||||
anchors_preset = 0
|
||||
offset_left = 2832.0
|
||||
offset_top = 1157.0
|
||||
offset_right = 2872.0
|
||||
offset_bottom = 1197.0
|
||||
|
||||
[node name="Position1" type="Control" parent="GameRoot/FlyFrom" index="0"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
offset_left = -2494.0
|
||||
offset_top = -1437.0
|
||||
offset_right = -2454.0
|
||||
offset_bottom = -1397.0
|
||||
|
||||
[node name="Position2" type="Control" parent="GameRoot/FlyFrom" index="1"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
offset_left = -1738.0
|
||||
offset_top = -1398.0
|
||||
offset_right = -1698.0
|
||||
offset_bottom = -1358.0
|
||||
|
||||
[node name="Position3" type="Control" parent="GameRoot/FlyFrom" index="2"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
offset_left = -944.0
|
||||
offset_top = -1341.0
|
||||
offset_right = -904.0
|
||||
offset_bottom = -1301.0
|
||||
|
||||
[node name="Position4" type="Control" parent="GameRoot/FlyFrom" index="3"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
offset_left = 154.0
|
||||
offset_top = -916.0
|
||||
offset_right = 194.0
|
||||
offset_bottom = -876.0
|
||||
|
||||
[node name="Position5" type="Control" parent="GameRoot/FlyFrom" index="4"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
offset_left = -4.0
|
||||
offset_top = -528.0
|
||||
offset_right = 36.0
|
||||
offset_bottom = -488.0
|
||||
|
||||
[node name="Position6" type="Control" parent="GameRoot/FlyFrom" index="5"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
offset_left = -39.0
|
||||
offset_top = -205.0
|
||||
offset_right = 1.0
|
||||
offset_bottom = -165.0
|
||||
|
||||
[node name="Position7" type="Control" parent="GameRoot/FlyFrom" index="6"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
offset_left = -33.0
|
||||
offset_top = 360.0
|
||||
offset_right = 7.0
|
||||
offset_bottom = 400.0
|
||||
|
||||
[node name="Position8" type="Control" parent="GameRoot/FlyFrom" index="7"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
offset_left = -3198.0
|
||||
offset_top = 164.0
|
||||
offset_right = -3158.0
|
||||
offset_bottom = 204.0
|
||||
|
||||
[node name="Position9" type="Control" parent="GameRoot/FlyFrom" index="8"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
offset_left = -3386.0
|
||||
offset_top = -297.0
|
||||
offset_right = -3346.0
|
||||
offset_bottom = -257.0
|
||||
|
||||
[node name="Position10" type="Control" parent="GameRoot/FlyFrom" index="9"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
offset_left = -3068.0
|
||||
offset_top = -579.0
|
||||
offset_right = -3028.0
|
||||
offset_bottom = -539.0
|
||||
|
||||
[node name="Position11" type="Control" parent="GameRoot/FlyFrom" index="10"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
offset_left = -3160.0
|
||||
offset_top = -967.0
|
||||
offset_right = -3120.0
|
||||
offset_bottom = -927.0
|
||||
|
||||
[node name="Position12" type="Control" parent="GameRoot/FlyFrom" index="11"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
offset_left = -2744.0
|
||||
offset_top = -1312.0
|
||||
offset_right = -2704.0
|
||||
offset_bottom = -1272.0
|
||||
|
||||
Reference in New Issue
Block a user