Finishes spawning of turtles. Adds interactions between turtles and the island

This commit is contained in:
Dylan Sarrazyn
2024-04-30 16:26:04 +02:00
committed by BimDav
parent d1338a81ec
commit 9cc01de386
9 changed files with 100 additions and 45 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bxbs8osui2o8f"
path="res://.godot/imported/turtles_mask.png-20f05d7972f96ab47bc204fca2e3e93d.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/minigames/turtles/graphic/turtles_mask.png"
dest_files=["res://.godot/imported/turtles_mask.png-20f05d7972f96ab47bc204fca2e3e93d.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
+3 -4
View File
@@ -3,7 +3,6 @@ class_name Island
@onready var label : Label = $Label @onready var label : Label = $Label
var stimulus: Dictionary:
func _on_area_entered(area): set(value):
print(area) label.text = "_".repeat(stimulus.Word.length())
print(area.owner)
+3 -3
View File
@@ -4,6 +4,7 @@
[ext_resource type="Texture2D" uid="uid://c3i6riv7blkux" path="res://assets/minigames/turtles/graphic/turtle_Island.png" id="1_shxj4"] [ext_resource type="Texture2D" uid="uid://c3i6riv7blkux" path="res://assets/minigames/turtles/graphic/turtle_Island.png" id="1_shxj4"]
[node name="Island" type="Area2D"] [node name="Island" type="Area2D"]
collision_layer = 0
script = ExtResource("1_bl1e4") script = ExtResource("1_bl1e4")
[node name="Sprite2D" type="Sprite2D" parent="."] [node name="Sprite2D" type="Sprite2D" parent="."]
@@ -20,7 +21,6 @@ horizontal_alignment = 1
vertical_alignment = 1 vertical_alignment = 1
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="."] [node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="."]
position = Vector2(0, 8)
scale = Vector2(2, 2) scale = Vector2(2, 2)
polygon = PackedVector2Array(144, -148, 176, -124, 192, -100, 204, -84, 220, -52, 228, -20, 228, 20, 216, 56, 196, 84, 172, 108, 152, 120, 120, 132, 76, 144, 36, 148, -40, 156, -8, 152, -56, 160, -72, 160, -88, 160, -112, 152, -132, 144, -152, 136, -168, 124, -200, 100, -220, 72, -228, 36, -224, 4, -200, -28, -164, -52, -120, -68, -72, -80, -24, -132, 8, -152, 56, -164, 100, -160) polygon = PackedVector2Array(136, -124, 160, -104, 180, -80, 196, -36, 196, 12, 184, 56, 156, 88, 104, 112, 72, 124, 24, 128, -56, 128, -104, 124, -140, 116, -180, 92, -196, 68, -200, 24, -180, -12, -156, -28, -120, -36, -76, -52, -48, -72, -4, -116, 44, -140, 92, -140)
[connection signal="area_entered" from="." to="." method="_on_area_entered"]
+14 -7
View File
@@ -6,21 +6,20 @@ signal animation_changed(position: Vector2)
@onready var body: Node2D = $Body @onready var body: Node2D = $Body
@onready var sprite: AnimatedSprite2D = $Body/AnimatedSprite2D @onready var sprite: AnimatedSprite2D = $Body/AnimatedSprite2D
@onready var label: Label = $Label @onready var label: Label = $Label
@onready var head_area: Area2D = %HeadArea @onready var head_area_collision_shape: CollisionShape2D = $Body/HeadArea/CollisionShape2D
@onready var body_area: Area2D = %BodyArea @onready var body_area_collision_shape: CollisionShape2D = $Body/BodyArea/CollisionShape2D
@onready var highlight_fx: HighlightFX = $HighlightFX @onready var highlight_fx: HighlightFX = $HighlightFX
@onready var right_fx: RightFX = $RightFX @onready var right_fx: RightFX = $RightFX
@onready var wrong_fx: WrongFX = $WrongFX @onready var wrong_fx: WrongFX = $WrongFX
@onready var button: Button = $Button
var velocity: float = 0. var velocity: float = 0.
var direction: Vector2 = Vector2(0,-1): var direction: Vector2 = Vector2(0,-1):
set = _set_direction set = _set_direction
var is_moving: bool = true
func _process(delta): func _process(delta):
position = position + velocity * delta * direction if is_moving:
position += velocity * delta * direction
func _set_direction(new_direction: Vector2) -> void: func _set_direction(new_direction: Vector2) -> void:
@@ -53,20 +52,24 @@ func highlight(value: bool = true) -> void:
func right() -> void: func right() -> void:
is_moving = false
sprite.play("victory") sprite.play("victory")
right_fx.play() right_fx.play()
await right_fx.finished await right_fx.finished
func wrong() -> void: func wrong() -> void:
is_moving = false
wrong_fx.play() wrong_fx.play()
await wrong_fx.finished await wrong_fx.finished
func disappear() -> void: func disappear() -> void:
is_moving = false
head_area_collision_shape.set_deferred("disabled", true)
body_area_collision_shape.set_deferred("disabled", true)
sprite.play("disappear") sprite.play("disappear")
#endregion #endregion
#region Connections #region Connections
@@ -90,4 +93,8 @@ func _on_animated_sprite_2d_animation_finished():
func _on_visible_on_screen_notifier_2d_screen_exited(): func _on_visible_on_screen_notifier_2d_screen_exited():
queue_free() queue_free()
func _on_body_area_area_entered(area):
disappear()
#endregion #endregion
+24 -24
View File
@@ -1,10 +1,10 @@
[gd_scene load_steps=45 format=3 uid="uid://djykrpdu58f3v"] [gd_scene load_steps=45 format=3 uid="uid://djykrpdu58f3v"]
[ext_resource type="Script" path="res://sources/utils/fx/highlight.gd" id="1_fpcej"]
[ext_resource type="Texture2D" uid="uid://bi8db32muvyqp" path="res://assets/minigames/turtles/graphic/turtle_disappears_0000.png" id="1_phg5d"] [ext_resource type="Texture2D" uid="uid://bi8db32muvyqp" path="res://assets/minigames/turtles/graphic/turtle_disappears_0000.png" id="1_phg5d"]
[ext_resource type="Script" path="res://sources/minigames/turtles/turtle.gd" id="1_vx1yr"] [ext_resource type="Script" path="res://sources/minigames/turtles/turtle.gd" id="1_vx1yr"]
[ext_resource type="PackedScene" uid="uid://cn2rw06pltyiu" path="res://sources/utils/fx/right.tscn" id="2_dmkbj"] [ext_resource type="PackedScene" uid="uid://cn2rw06pltyiu" path="res://sources/utils/fx/right.tscn" id="2_dmkbj"]
[ext_resource type="Texture2D" uid="uid://b04s06613lgyo" path="res://assets/minigames/turtles/graphic/turtle_disappears_0001.png" id="2_qodey"] [ext_resource type="Texture2D" uid="uid://b04s06613lgyo" path="res://assets/minigames/turtles/graphic/turtle_disappears_0001.png" id="2_qodey"]
[ext_resource type="PackedScene" uid="uid://cge0uyn30tcpv" path="res://sources/utils/fx/highlight.tscn" id="2_rllc5"]
[ext_resource type="Texture2D" uid="uid://dncvc4dkurogg" path="res://assets/minigames/turtles/graphic/turtle_disappears_0002.png" id="3_pinqg"] [ext_resource type="Texture2D" uid="uid://dncvc4dkurogg" path="res://assets/minigames/turtles/graphic/turtle_disappears_0002.png" id="3_pinqg"]
[ext_resource type="Texture2D" uid="uid://dvwkb0orntj6j" path="res://assets/minigames/turtles/graphic/turtle_disappears_0003.png" id="4_bk8j5"] [ext_resource type="Texture2D" uid="uid://dvwkb0orntj6j" path="res://assets/minigames/turtles/graphic/turtle_disappears_0003.png" id="4_bk8j5"]
[ext_resource type="Texture2D" uid="uid://18okbnsktp37" path="res://assets/minigames/turtles/graphic/turtle_disappears_0004.png" id="5_1gjjo"] [ext_resource type="Texture2D" uid="uid://18okbnsktp37" path="res://assets/minigames/turtles/graphic/turtle_disappears_0004.png" id="5_1gjjo"]
@@ -35,11 +35,11 @@
[ext_resource type="Texture2D" uid="uid://30w5sssd8c1e" path="res://assets/minigames/turtles/graphic/turtle_swim_right_0007.png" id="38_dmtwb"] [ext_resource type="Texture2D" uid="uid://30w5sssd8c1e" path="res://assets/minigames/turtles/graphic/turtle_swim_right_0007.png" id="38_dmtwb"]
[ext_resource type="Texture2D" uid="uid://c5kar2p8ae8yu" path="res://assets/minigames/turtles/graphic/turtle_victory_0000.png" id="39_a8d4f"] [ext_resource type="Texture2D" uid="uid://c5kar2p8ae8yu" path="res://assets/minigames/turtles/graphic/turtle_victory_0000.png" id="39_a8d4f"]
[ext_resource type="Texture2D" uid="uid://pcty3etq3036" path="res://assets/minigames/turtles/graphic/turtle_victory_0001.png" id="40_rg80s"] [ext_resource type="Texture2D" uid="uid://pcty3etq3036" path="res://assets/minigames/turtles/graphic/turtle_victory_0001.png" id="40_rg80s"]
[ext_resource type="PackedScene" uid="uid://dlmbxcgiv8tpr" path="res://sources/utils/fx/wrong.tscn" id="40_vguhy"]
[ext_resource type="Texture2D" uid="uid://bg6603ct43g00" path="res://assets/minigames/turtles/graphic/turtle_victory_0002.png" id="41_hkvwr"] [ext_resource type="Texture2D" uid="uid://bg6603ct43g00" path="res://assets/minigames/turtles/graphic/turtle_victory_0002.png" id="41_hkvwr"]
[ext_resource type="Texture2D" uid="uid://25h5xdesr8mk" path="res://assets/minigames/turtles/graphic/turtle_victory_0003.png" id="42_1is74"] [ext_resource type="Texture2D" uid="uid://25h5xdesr8mk" path="res://assets/minigames/turtles/graphic/turtle_victory_0003.png" id="42_1is74"]
[ext_resource type="Texture2D" uid="uid://vgqt4v6pgerb" path="res://assets/minigames/turtles/graphic/turtle_victory_0004.png" id="43_lvi8j"] [ext_resource type="Texture2D" uid="uid://vgqt4v6pgerb" path="res://assets/minigames/turtles/graphic/turtle_victory_0004.png" id="43_lvi8j"]
[ext_resource type="Texture2D" uid="uid://64w00rvu3xfe" path="res://assets/minigames/turtles/graphic/turtle_victory_0005.png" id="44_w2vrc"] [ext_resource type="Texture2D" uid="uid://64w00rvu3xfe" path="res://assets/minigames/turtles/graphic/turtle_victory_0005.png" id="44_w2vrc"]
[ext_resource type="Script" path="res://sources/utils/fx/wrong.gd" id="47_d8u8j"]
[ext_resource type="PackedScene" uid="uid://cjg6pgc7yfp1p" path="res://sources/utils/swipe_detector.tscn" id="49_0qwwy"] [ext_resource type="PackedScene" uid="uid://cjg6pgc7yfp1p" path="res://sources/utils/swipe_detector.tscn" id="49_0qwwy"]
[sub_resource type="SpriteFrames" id="SpriteFrames_1emmd"] [sub_resource type="SpriteFrames" id="SpriteFrames_1emmd"]
@@ -123,7 +123,7 @@ animations = [{
}], }],
"loop": false, "loop": false,
"name": &"swim_left", "name": &"swim_left",
"speed": 12.0 "speed": 18.0
}, { }, {
"frames": [{ "frames": [{
"duration": 1.0, "duration": 1.0,
@@ -152,7 +152,7 @@ animations = [{
}], }],
"loop": false, "loop": false,
"name": &"swim_right", "name": &"swim_right",
"speed": 12.0 "speed": 18.0
}, { }, {
"frames": [{ "frames": [{
"duration": 1.0, "duration": 1.0,
@@ -179,20 +179,17 @@ animations = [{
}] }]
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_uo0u3"] [sub_resource type="CapsuleShape2D" id="CapsuleShape2D_uo0u3"]
radius = 40.0 radius = 24.0
height = 112.0 height = 80.0
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_xsnve"] [sub_resource type="CapsuleShape2D" id="CapsuleShape2D_xsnve"]
radius = 112.0 radius = 88.0
height = 256.0 height = 224.0
[node name="Turtle" type="Node2D"] [node name="Turtle" type="Node2D"]
script = ExtResource("1_vx1yr") script = ExtResource("1_vx1yr")
[node name="HighlightFX" type="Control" parent="."] [node name="HighlightFX" parent="." instance=ExtResource("2_rllc5")]
layout_mode = 3
anchors_preset = 0
script = ExtResource("1_fpcej")
[node name="RightFX" parent="." instance=ExtResource("2_dmkbj")] [node name="RightFX" parent="." instance=ExtResource("2_dmkbj")]
@@ -200,44 +197,46 @@ script = ExtResource("1_fpcej")
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="Body"] [node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="Body"]
unique_name_in_owner = true unique_name_in_owner = true
position = Vector2(0, -16)
scale = Vector2(2, 2) scale = Vector2(2, 2)
sprite_frames = SubResource("SpriteFrames_1emmd") sprite_frames = SubResource("SpriteFrames_1emmd")
animation = &"disappear" animation = &"disappear"
autoplay = "swim" autoplay = "swim"
[node name="VisibleOnScreenNotifier2D" type="VisibleOnScreenNotifier2D" parent="Body"]
position = Vector2(0, 16)
[node name="HeadArea" type="Area2D" parent="Body"] [node name="HeadArea" type="Area2D" parent="Body"]
unique_name_in_owner = true position = Vector2(0, -16)
collision_mask = 0
monitoring = false
[node name="CollisionShape2D" type="CollisionShape2D" parent="Body/HeadArea"] [node name="CollisionShape2D" type="CollisionShape2D" parent="Body/HeadArea"]
position = Vector2(0, -160) position = Vector2(0, -152)
shape = SubResource("CapsuleShape2D_uo0u3") shape = SubResource("CapsuleShape2D_uo0u3")
debug_color = Color(0.129412, 0.458824, 0, 0.505882) debug_color = Color(0.129412, 0.458824, 0, 0.505882)
[node name="BodyArea" type="Area2D" parent="Body"] [node name="BodyArea" type="Area2D" parent="Body"]
unique_name_in_owner = true position = Vector2(0, -16)
collision_layer = 0
monitorable = false
[node name="CollisionShape2D" type="CollisionShape2D" parent="Body/BodyArea"] [node name="CollisionShape2D" type="CollisionShape2D" parent="Body/BodyArea"]
position = Vector2(0, 32) position = Vector2(0, 32)
shape = SubResource("CapsuleShape2D_xsnve") shape = SubResource("CapsuleShape2D_xsnve")
debug_color = Color(0.870588, 0.117647, 0, 0.388235) debug_color = Color(0.870588, 0.117647, 0, 0.388235)
[node name="VisibleOnScreenNotifier2D" type="VisibleOnScreenNotifier2D" parent="Body"]
position = Vector2(0, 256)
[node name="Label" type="Label" parent="."] [node name="Label" type="Label" parent="."]
offset_left = -64.0 offset_left = -64.0
offset_top = -64.0 offset_top = -88.0
offset_right = 64.0 offset_right = 64.0
offset_bottom = 96.0 offset_bottom = 72.0
theme_override_font_sizes/font_size = 92 theme_override_font_sizes/font_size = 92
text = "ent" text = "ent"
horizontal_alignment = 1 horizontal_alignment = 1
vertical_alignment = 1 vertical_alignment = 1
[node name="WrongFX" type="Control" parent="."] [node name="WrongFX" parent="." instance=ExtResource("40_vguhy")]
layout_mode = 3
anchors_preset = 0
script = ExtResource("47_d8u8j")
[node name="SwipeDetector" parent="." instance=ExtResource("49_0qwwy")] [node name="SwipeDetector" parent="." instance=ExtResource("49_0qwwy")]
offset_left = -152.0 offset_left = -152.0
@@ -248,4 +247,5 @@ offset_bottom = 192.0
[connection signal="animation_changed" from="Body/AnimatedSprite2D" to="." method="_on_animated_sprite_2d_animation_changed"] [connection signal="animation_changed" from="Body/AnimatedSprite2D" to="." method="_on_animated_sprite_2d_animation_changed"]
[connection signal="animation_finished" from="Body/AnimatedSprite2D" to="." method="_on_animated_sprite_2d_animation_finished"] [connection signal="animation_finished" from="Body/AnimatedSprite2D" to="." method="_on_animated_sprite_2d_animation_finished"]
[connection signal="screen_exited" from="Body/VisibleOnScreenNotifier2D" to="." method="_on_visible_on_screen_notifier_2d_screen_exited"] [connection signal="screen_exited" from="Body/VisibleOnScreenNotifier2D" to="." method="_on_visible_on_screen_notifier_2d_screen_exited"]
[connection signal="area_entered" from="Body/BodyArea" to="." method="_on_body_area_area_entered"]
[connection signal="swipe" from="SwipeDetector" to="." method="_on_swipe_detector_swipe"] [connection signal="swipe" from="SwipeDetector" to="." method="_on_swipe_detector_swipe"]
+18 -6
View File
@@ -29,7 +29,7 @@ var difficulty_settings: Array[DifficultySettings] = [
@onready var water: TextureRect = $GameRoot/Water @onready var water: TextureRect = $GameRoot/Water
@onready var island: Island = $GameRoot/Island @onready var island: Island = $GameRoot/Island
@onready var turtles: Control = $GameRoot/Turtles @onready var turtles: Control = %Turtles
@onready var spawn_location: PathFollow2D = $GameRoot/SpawnPath/SpawnLocation @onready var spawn_location: PathFollow2D = $GameRoot/SpawnPath/SpawnLocation
@onready var spawn_timer: Timer = $GameRoot/SpawnTimer @onready var spawn_timer: Timer = $GameRoot/SpawnTimer
@@ -39,7 +39,6 @@ var turtle_count: int = 0:
if turtle_count >= max_turtle_count and value < max_turtle_count: if turtle_count >= max_turtle_count and value < max_turtle_count:
can_spawn_turtle.emit() can_spawn_turtle.emit()
turtle_count = value turtle_count = value
var last_spawn_location_ratio: float
# Find and set the parameters of the minigame, like the number of lives or the victory conditions. # Find and set the parameters of the minigame, like the number of lives or the victory conditions.
func _setup_minigame() -> void: func _setup_minigame() -> void:
@@ -56,11 +55,11 @@ func _setup_minigame() -> void:
func _start() -> void: func _start() -> void:
super._start() super._start()
spawn_timer.start() _on_spawn_timer_timeout()
func _spawn_water_ring(position: Vector2): func _spawn_water_ring(position: Vector2):
print(position) #print(position)
pass pass
@@ -76,11 +75,13 @@ func _on_spawn_timer_timeout():
var position_found: bool = false var position_found: bool = false
while not position_found: while not position_found:
spawn_location.progress_ratio = randf() spawn_location.progress_ratio = randf()
var all_position_ok: bool = true
# Check if there are other turtles near # Check if there are other turtles near
for other_turtle: Turtle in turtles.get_children(): for other_turtle: Turtle in turtles.get_children():
if other_turtle.position.distance_to(spawn_location.position) < 4: if other_turtle.position.distance_squared_to(spawn_location.position) < 250000:
all_position_ok = false
break break
position_found = all_position_ok
turtle.position = spawn_location.position turtle.position = spawn_location.position
turtle.velocity = settings.velocity turtle.velocity = settings.velocity
@@ -103,4 +104,15 @@ func _on_spawn_timer_timeout():
# Restarts timer # Restarts timer
spawn_timer.start() spawn_timer.start()
func _on_island_area_entered(area):
var turtle = area.owner as Turtle
if not turtle:
return
# Check if the turtle is a distractor or the awaited GP TODO
await turtle.wrong()
# Make the turtle disappear
turtle.disappear()
@@ -16,6 +16,7 @@ point_count = 5
[node name="TurtlesMinigame" instance=ExtResource("1_geqym")] [node name="TurtlesMinigame" instance=ExtResource("1_geqym")]
script = ExtResource("2_f5de7") script = ExtResource("2_f5de7")
difficulty = 1
minigame_number = 1 minigame_number = 1
max_number_of_lives = 5 max_number_of_lives = 5
max_progression = 5 max_progression = 5
@@ -38,6 +39,7 @@ texture = ExtResource("6_l6je2")
position = Vector2(1280, 830) position = Vector2(1280, 830)
[node name="Turtles" type="Control" parent="GameRoot" index="2"] [node name="Turtles" type="Control" parent="GameRoot" index="2"]
unique_name_in_owner = true
layout_mode = 1 layout_mode = 1
anchors_preset = 15 anchors_preset = 15
anchor_right = 1.0 anchor_right = 1.0
@@ -54,4 +56,5 @@ position = Vector2(-256, -256)
[node name="SpawnTimer" type="Timer" parent="GameRoot" index="4"] [node name="SpawnTimer" type="Timer" parent="GameRoot" index="4"]
one_shot = true one_shot = true
[connection signal="area_entered" from="GameRoot/Island" to="." method="_on_island_area_entered"]
[connection signal="timeout" from="GameRoot/SpawnTimer" to="." method="_on_spawn_timer_timeout"] [connection signal="timeout" from="GameRoot/SpawnTimer" to="." method="_on_spawn_timer_timeout"]
@@ -7,6 +7,6 @@ shader = ExtResource("1_3btqb")
shader_parameter/WATER_COL = Color(0.352941, 0.713726, 0.67451, 1) shader_parameter/WATER_COL = Color(0.352941, 0.713726, 0.67451, 1)
shader_parameter/WATER2_COL = Color(0.329412, 0.670588, 0.619608, 1) shader_parameter/WATER2_COL = Color(0.329412, 0.670588, 0.619608, 1)
shader_parameter/FOAM_COL = Color(0.65098, 0.882353, 0.847059, 1) shader_parameter/FOAM_COL = Color(0.65098, 0.882353, 0.847059, 1)
shader_parameter/distortion_speed = 0.66 shader_parameter/distortion_speed = 0.75
shader_parameter/tile = Vector2(0.4, 0.4) shader_parameter/tile = Vector2(0.4, 0.4)
shader_parameter/offset = Vector2(0, 0) shader_parameter/offset = Vector2(0, 0)