work on monkeys

This commit is contained in:
BimDav
2023-03-10 16:25:44 +01:00
parent ba0eaccece
commit 82fb0d8f91
47 changed files with 1535 additions and 10 deletions
+10 -8
View File
@@ -50,14 +50,7 @@ var current_lives: = 0 :
_lose()
# Progression
var current_progression: = 0 :
set(value):
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()
var current_progression: = 0 : set = set_current_progression
# ------------ Initialisation ------------
@@ -209,3 +202,12 @@ func _on_minigame_ui_voice_volume_changed(volume) -> void:
func _on_minigame_ui_effects_volume_changed(volume) -> void:
UserDataManager.set_effects_volume(volume)
func set_current_progression(p_current_progression: int) -> void:
var previous_progression: = current_progression
current_progression = p_current_progression
if minigame_ui:
minigame_ui.set_current_progression(p_current_progression)
if p_current_progression == max_progression and previous_progression != max_progression:
_win()
+9
View File
@@ -0,0 +1,9 @@
extends Node2D
@onready var label: = $Label
var text: String :
set(value):
text = value
label.text = text
+24
View File
@@ -0,0 +1,24 @@
[gd_scene load_steps=4 format=3 uid="uid://2mwfjg3c68p1"]
[ext_resource type="Texture2D" uid="uid://bh28uja7gs8u4" path="res://assets/minigames/monkeys/graphic/coconut.png" id="1_fvymg"]
[ext_resource type="Script" path="res://sources/minigames/monkeys/coconut.gd" id="1_yojn5"]
[ext_resource type="FontFile" uid="uid://b2l4jfylc1v41" path="res://assets/fonts/DidactGothic-Regular.ttf" id="2_nj887"]
[node name="Coconut" type="Node2D"]
script = ExtResource("1_yojn5")
[node name="Sprite2D" type="Sprite2D" parent="."]
scale = Vector2(2, 2)
texture = ExtResource("1_fvymg")
[node name="Label" type="Label" parent="."]
custom_minimum_size = Vector2(110, 2.08165e-12)
offset_left = -57.0
offset_top = -53.0
offset_right = 53.0
offset_bottom = 43.0
theme_override_fonts/font = ExtResource("2_nj887")
theme_override_font_sizes/font_size = 70
text = "ent"
horizontal_alignment = 1
vertical_alignment = 1
+296
View File
@@ -0,0 +1,296 @@
[gd_scene load_steps=38 format=3 uid="uid://b8r26vroslasj"]
[ext_resource type="Texture2D" uid="uid://boxmlmbplr12i" path="res://assets/minigames/monkeys/graphic/king_spritesheet.png" id="1_l8txe"]
[sub_resource type="AtlasTexture" id="AtlasTexture_61ga5"]
atlas = ExtResource("1_l8txe")
region = Rect2(0, 0, 240, 221)
[sub_resource type="AtlasTexture" id="AtlasTexture_psyih"]
atlas = ExtResource("1_l8txe")
region = Rect2(240, 0, 240, 221)
[sub_resource type="AtlasTexture" id="AtlasTexture_5er35"]
atlas = ExtResource("1_l8txe")
region = Rect2(480, 0, 240, 221)
[sub_resource type="AtlasTexture" id="AtlasTexture_luq25"]
atlas = ExtResource("1_l8txe")
region = Rect2(720, 0, 240, 221)
[sub_resource type="AtlasTexture" id="AtlasTexture_dnce3"]
atlas = ExtResource("1_l8txe")
region = Rect2(0, 663, 240, 221)
[sub_resource type="AtlasTexture" id="AtlasTexture_nklip"]
atlas = ExtResource("1_l8txe")
region = Rect2(240, 663, 240, 221)
[sub_resource type="AtlasTexture" id="AtlasTexture_4fxv0"]
atlas = ExtResource("1_l8txe")
region = Rect2(480, 663, 240, 221)
[sub_resource type="AtlasTexture" id="AtlasTexture_w0q21"]
atlas = ExtResource("1_l8txe")
region = Rect2(720, 663, 240, 221)
[sub_resource type="AtlasTexture" id="AtlasTexture_xqhx3"]
atlas = ExtResource("1_l8txe")
region = Rect2(960, 663, 240, 221)
[sub_resource type="AtlasTexture" id="AtlasTexture_qcdea"]
atlas = ExtResource("1_l8txe")
region = Rect2(1200, 663, 240, 221)
[sub_resource type="AtlasTexture" id="AtlasTexture_t7nj3"]
atlas = ExtResource("1_l8txe")
region = Rect2(0, 884, 240, 221)
[sub_resource type="AtlasTexture" id="AtlasTexture_iuthd"]
atlas = ExtResource("1_l8txe")
region = Rect2(240, 884, 240, 221)
[sub_resource type="AtlasTexture" id="AtlasTexture_12sr7"]
atlas = ExtResource("1_l8txe")
region = Rect2(480, 884, 240, 221)
[sub_resource type="AtlasTexture" id="AtlasTexture_xjxvo"]
atlas = ExtResource("1_l8txe")
region = Rect2(720, 884, 240, 221)
[sub_resource type="AtlasTexture" id="AtlasTexture_jb1ly"]
atlas = ExtResource("1_l8txe")
region = Rect2(960, 884, 240, 221)
[sub_resource type="AtlasTexture" id="AtlasTexture_06cqm"]
atlas = ExtResource("1_l8txe")
region = Rect2(1200, 884, 240, 221)
[sub_resource type="AtlasTexture" id="AtlasTexture_ebv4a"]
atlas = ExtResource("1_l8txe")
region = Rect2(0, 1105, 240, 221)
[sub_resource type="AtlasTexture" id="AtlasTexture_dl12t"]
atlas = ExtResource("1_l8txe")
region = Rect2(240, 1105, 240, 221)
[sub_resource type="AtlasTexture" id="AtlasTexture_u6pif"]
atlas = ExtResource("1_l8txe")
region = Rect2(480, 1105, 240, 221)
[sub_resource type="AtlasTexture" id="AtlasTexture_e5k8v"]
atlas = ExtResource("1_l8txe")
region = Rect2(720, 1105, 240, 221)
[sub_resource type="AtlasTexture" id="AtlasTexture_j0v1k"]
atlas = ExtResource("1_l8txe")
region = Rect2(960, 1105, 240, 221)
[sub_resource type="AtlasTexture" id="AtlasTexture_lwrmq"]
atlas = ExtResource("1_l8txe")
region = Rect2(1200, 1105, 240, 221)
[sub_resource type="AtlasTexture" id="AtlasTexture_gyis7"]
atlas = ExtResource("1_l8txe")
region = Rect2(1440, 1105, 240, 221)
[sub_resource type="AtlasTexture" id="AtlasTexture_ilp1g"]
atlas = ExtResource("1_l8txe")
region = Rect2(0, 442, 240, 221)
[sub_resource type="AtlasTexture" id="AtlasTexture_usu48"]
atlas = ExtResource("1_l8txe")
region = Rect2(240, 442, 240, 221)
[sub_resource type="AtlasTexture" id="AtlasTexture_54mkd"]
atlas = ExtResource("1_l8txe")
region = Rect2(480, 442, 240, 221)
[sub_resource type="AtlasTexture" id="AtlasTexture_uhqj6"]
atlas = ExtResource("1_l8txe")
region = Rect2(720, 442, 240, 221)
[sub_resource type="AtlasTexture" id="AtlasTexture_51v3c"]
atlas = ExtResource("1_l8txe")
region = Rect2(960, 442, 240, 221)
[sub_resource type="AtlasTexture" id="AtlasTexture_0xk7i"]
atlas = ExtResource("1_l8txe")
region = Rect2(1200, 442, 240, 221)
[sub_resource type="AtlasTexture" id="AtlasTexture_qyjhi"]
atlas = ExtResource("1_l8txe")
region = Rect2(0, 221, 240, 221)
[sub_resource type="AtlasTexture" id="AtlasTexture_aupla"]
atlas = ExtResource("1_l8txe")
region = Rect2(240, 221, 240, 221)
[sub_resource type="AtlasTexture" id="AtlasTexture_q8d8l"]
atlas = ExtResource("1_l8txe")
region = Rect2(480, 221, 240, 221)
[sub_resource type="AtlasTexture" id="AtlasTexture_uo0xs"]
atlas = ExtResource("1_l8txe")
region = Rect2(720, 221, 240, 221)
[sub_resource type="AtlasTexture" id="AtlasTexture_k8vhj"]
atlas = ExtResource("1_l8txe")
region = Rect2(960, 221, 240, 221)
[sub_resource type="AtlasTexture" id="AtlasTexture_r5alq"]
atlas = ExtResource("1_l8txe")
region = Rect2(1200, 221, 240, 221)
[sub_resource type="SpriteFrames" id="SpriteFrames_jgg6t"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_61ga5")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_psyih")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_5er35")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_luq25")
}],
"loop": false,
"name": &"catch",
"speed": 8.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_dnce3")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_nklip")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_4fxv0")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_w0q21")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_xqhx3")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_qcdea")
}],
"loop": true,
"name": &"idle",
"speed": 7.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_t7nj3")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_iuthd")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_12sr7")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_xjxvo")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_jb1ly")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_06cqm")
}],
"loop": true,
"name": &"idle_blink",
"speed": 7.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_ebv4a")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_dl12t")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_u6pif")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_e5k8v")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_j0v1k")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_lwrmq")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_gyis7")
}],
"loop": false,
"name": &"read",
"speed": 7.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_ilp1g")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_usu48")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_54mkd")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_uhqj6")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_51v3c")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_0xk7i")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_usu48")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ilp1g")
}],
"loop": false,
"name": &"right",
"speed": 8.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_qyjhi")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_aupla")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_q8d8l")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_uo0xs")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_k8vhj")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_r5alq")
}],
"loop": false,
"name": &"wrong",
"speed": 8.0
}]
[node name="KingMonkey" type="Node2D"]
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
scale = Vector2(2, 2)
sprite_frames = SubResource("SpriteFrames_jgg6t")
animation = &"wrong"
autoplay = "idle"
offset = Vector2(-12, -74)
+82
View File
@@ -0,0 +1,82 @@
@tool
extends Node2D
signal pressed()
signal dragged_into_self()
signal dragged_into(vector)
const instance_scene: = "res://sources/minigames/monkeys/monkey.tscn"
@onready var coconut: = $Marker2D/Coconut
@onready var animation_player: = $AnimationPlayer
@onready var drag_preview_label: = $Button/DragPreview/Label
@onready var drag_preview: = $Button/DragPreview
@onready var button: = $Button
var stimulus: Dictionary :
set(value):
stimulus = value
coconut.text = value.Grapheme
drag_preview_label.text = value.Grapheme
static func instantiate():
return load(instance_scene).instantiate()
func _ready() -> void:
button.set_drag_forwarding(_get_drag_data, _can_drop_data, _drop_data)
func _on_button_pressed() -> void:
pressed.emit()
func talk() -> void:
animation_player.play("talk")
await animation_player.animation_finished
animation_player.play_backwards("talk")
await animation_player.animation_finished
animation_player.play("idle")
func _on_animation_player_animation_finished(anim_name: StringName) -> void:
if anim_name == "idle":
if randf() < 0.25:
animation_player.play("idle_blink")
else:
animation_player.play("idle")
elif anim_name == "idle_blink":
animation_player.play("idle")
func _on_button_dragging() -> void:
coconut.hide()
func _get_drag_data(at_position: Vector2):
var _drag_preview = drag_preview.duplicate()
_drag_preview.show()
button.set_drag_preview(_drag_preview)
print(at_position)
coconut.hide()
return {
object = self,
start_position = button.global_position + at_position,
}
func _can_drop_data(_at_position: Vector2, _data) -> bool:
return true
func _drop_data(at_position: Vector2, data) -> void:
if data.object == self:
dragged_into_self.emit()
else:
dragged_into.emit(button.global_position + at_position - data.start_position)
func _on_drag_preview_tree_exiting() -> void:
coconut.show()
+372
View File
@@ -0,0 +1,372 @@
[gd_scene load_steps=20 format=3 uid="uid://bp0b4xkr7nwed"]
[ext_resource type="Script" path="res://sources/minigames/monkeys/monkey.gd" id="1_cvvgu"]
[ext_resource type="Texture2D" uid="uid://d0jobqj4fvrwy" path="res://assets/minigames/monkeys/graphic/monkey_spritesheet.png" id="2_awb1x"]
[ext_resource type="PackedScene" uid="uid://2mwfjg3c68p1" path="res://sources/minigames/monkeys/coconut.tscn" id="3_tws3c"]
[ext_resource type="Texture2D" uid="uid://bh28uja7gs8u4" path="res://assets/minigames/monkeys/graphic/coconut.png" id="4_8r7im"]
[ext_resource type="FontFile" uid="uid://b2l4jfylc1v41" path="res://assets/fonts/DidactGothic-Regular.ttf" id="5_4f7ge"]
[sub_resource type="Animation" id="Animation_y7l2o"]
resource_name = "idle"
length = 0.857157
step = 0.142857
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Sprite2D:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.142857, 0.285714, 0.428571, 0.571429, 0.714286),
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1),
"update": 1,
"values": [18, 19, 20, 21, 22, 23]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("Marker2D:position")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0, 0.285714, 0.428571, 0.714286),
"transitions": PackedFloat32Array(1, 1, 1, 1),
"update": 0,
"values": [Vector2(-124, -99), Vector2(-121, -79), Vector2(-121, -79), Vector2(-124, -99)]
}
tracks/2/type = "value"
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/path = NodePath("Marker2D:rotation")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/keys = {
"times": PackedFloat32Array(0, 0.285714, 0.428571, 0.714286),
"transitions": PackedFloat32Array(1, 1, 1, 1),
"update": 0,
"values": [0.0, -0.0837758, -0.0837758, 0.0]
}
[sub_resource type="Animation" id="Animation_64f28"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Sprite2D:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [18]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("Marker2D:position")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector2(-124, -99)]
}
tracks/2/type = "value"
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/path = NodePath("Marker2D:rotation")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [3.48787e-16]
}
[sub_resource type="Animation" id="Animation_vwrnb"]
resource_name = "talk"
length = 0.428586
step = 0.142857
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Sprite2D:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.142857, 0.285714, 0.428571),
"transitions": PackedFloat32Array(1, 1, 1, 1),
"update": 1,
"values": [36, 37, 38, 39]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("Marker2D:rotation")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0, 0.428571),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [0.0, 0.0628319]
}
[sub_resource type="Animation" id="Animation_cp6hn"]
resource_name = "throw"
length = 0.625013
step = 0.125
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Sprite2D:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.125, 0.25, 0.375, 0.5, 0.625),
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1),
"update": 1,
"values": [30, 31, 32, 33, 34, 35]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("Marker2D:rotation")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0, 0.125, 0.625),
"transitions": PackedFloat32Array(1, 1, 1),
"update": 0,
"values": [0.0, 0.349066, -0.174533]
}
tracks/2/type = "value"
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/path = NodePath("Marker2D:position")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/keys = {
"times": PackedFloat32Array(0, 0.125, 0.625),
"transitions": PackedFloat32Array(1, 1, 1),
"update": 0,
"values": [Vector2(-124, -99), Vector2(-72, -144), Vector2(-192, -180)]
}
[sub_resource type="Animation" id="Animation_fm776"]
resource_name = "hit"
length = 0.40001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Sprite2D:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.1, 0.2, 0.3),
"transitions": PackedFloat32Array(1, 1, 1, 1),
"update": 1,
"values": [12, 13, 14, 15]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("Marker2D:rotation")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0, 0.4),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [0.261799, -0.10472]
}
tracks/2/type = "value"
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/path = NodePath("Marker2D:position")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/keys = {
"times": PackedFloat32Array(0, 0.4),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [Vector2(-74, -151), Vector2(-121, -61)]
}
[sub_resource type="Animation" id="Animation_ol2dg"]
resource_name = "stunned"
length = 0.857157
loop_mode = 1
step = 0.142857
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Marker2D:position")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector2(-121, -61)]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("Marker2D:rotation")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [-0.10472]
}
tracks/2/type = "value"
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/path = NodePath("Sprite2D:frame")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/keys = {
"times": PackedFloat32Array(0, 0.142857, 0.285714, 0.428571, 0.571429, 0.714286),
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1),
"update": 1,
"values": [42, 43, 44, 45, 46, 47]
}
[sub_resource type="Animation" id="Animation_c3yrh"]
resource_name = "idle_blink"
length = 0.857157
step = 0.142857
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Sprite2D:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.142857, 0.285714, 0.428571, 0.571429, 0.714286),
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1),
"update": 1,
"values": [24, 25, 26, 27, 28, 29]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("Marker2D:position")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0, 0.285714, 0.428571, 0.714286),
"transitions": PackedFloat32Array(1, 1, 1, 1),
"update": 0,
"values": [Vector2(-124, -99), Vector2(-121, -79), Vector2(-121, -79), Vector2(-124, -99)]
}
tracks/2/type = "value"
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/path = NodePath("Marker2D:rotation")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/keys = {
"times": PackedFloat32Array(0, 0.285714, 0.428571, 0.714286),
"transitions": PackedFloat32Array(1, 1, 1, 1),
"update": 0,
"values": [0.0, -0.0837758, -0.0837758, 0.0]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_rnatx"]
_data = {
"RESET": SubResource("Animation_64f28"),
"hit": SubResource("Animation_fm776"),
"idle": SubResource("Animation_y7l2o"),
"idle_blink": SubResource("Animation_c3yrh"),
"stunned": SubResource("Animation_ol2dg"),
"talk": SubResource("Animation_vwrnb"),
"throw": SubResource("Animation_cp6hn")
}
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_cbnv3"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_o7lt8"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_ma8s2"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_i3dnl"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_d4bmj"]
[sub_resource type="GDScript" id="GDScript_fxkfh"]
script/source = "extends Button
signal dragging()
@onready var drag_preview_model: = $DragPreview
"
[node name="Monkey" type="Node2D"]
script = ExtResource("1_cvvgu")
[node name="Sprite2D" type="Sprite2D" parent="."]
scale = Vector2(2, 2)
texture = ExtResource("2_awb1x")
offset = Vector2(2.08165e-12, -54)
hframes = 6
vframes = 9
frame = 18
[node name="Marker2D" type="Marker2D" parent="."]
position = Vector2(-124, -99)
gizmo_extents = 20.0
[node name="Coconut" parent="Marker2D" instance=ExtResource("3_tws3c")]
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
autoplay = "idle"
libraries = {
"": SubResource("AnimationLibrary_rnatx")
}
[node name="Button" type="Button" parent="."]
offset_left = -182.0
offset_top = -220.0
offset_right = 81.0
offset_bottom = 1.0
theme_override_styles/normal = SubResource("StyleBoxEmpty_cbnv3")
theme_override_styles/hover = SubResource("StyleBoxEmpty_o7lt8")
theme_override_styles/pressed = SubResource("StyleBoxEmpty_ma8s2")
theme_override_styles/disabled = SubResource("StyleBoxEmpty_i3dnl")
theme_override_styles/focus = SubResource("StyleBoxEmpty_d4bmj")
script = SubResource("GDScript_fxkfh")
[node name="DragPreview" type="TextureRect" parent="Button"]
visible = false
layout_mode = 0
offset_right = 128.0
offset_bottom = 128.0
texture = ExtResource("4_8r7im")
[node name="Label" type="Label" parent="Button/DragPreview"]
custom_minimum_size = Vector2(110, 2.08165e-12)
layout_mode = 0
offset_left = 7.0
offset_top = 7.0
offset_right = 117.0
offset_bottom = 103.0
theme_override_fonts/font = ExtResource("5_4f7ge")
theme_override_font_sizes/font_size = 70
text = "ent"
horizontal_alignment = 1
vertical_alignment = 1
[connection signal="animation_finished" from="AnimationPlayer" to="." method="_on_animation_player_animation_finished"]
[connection signal="dragging" from="Button" to="." method="_on_button_dragging"]
[connection signal="pressed" from="Button" to="." method="_on_button_pressed"]
[connection signal="tree_exiting" from="Button/DragPreview" to="." method="_on_drag_preview_tree_exiting"]
@@ -0,0 +1,110 @@
@tool
extends Minigame
const Monkey: = preload("res://sources/minigames/monkeys/monkey.gd")
const difficulty_settings: = {
0 : {"distractors_count": 1},
1 : {"distractors_count": 2},
2 : {"distractors_count": 3},
3 : {"distractors_count": 4},
4 : {"distractors_count": 5},
}
@export var difficulty: = 1
@export var lesson_nb: = 4
@export var words_count: = 3
@onready var monkeys_node: = $GameRoot/Monkeys
@onready var possible_positions_parent: = $GameRoot/PalmTreeMonkeys
@onready var king: = $GameRoot/PlamTreeKing/KingMonkey
@onready var word_label: = $GameRoot/TextPlank/MarginContainer/Label
var monkeys: Array[Monkey] = []
var _current_letter: = 0: set = _set_current_letter
# Find and set the parameters of the minigame, like the number of lives or the victory conditions.
func _setup_minigame() -> void:
super._setup_minigame()
var max_difficulty: = 0
for d in difficulty_settings.keys():
if d > max_difficulty:
max_difficulty = d
if difficulty > max_difficulty:
difficulty = max_difficulty
var settings: Dictionary = difficulty_settings[difficulty]
var possible_positions: = possible_positions_parent.get_children()
for i in settings.distractors_count + 1:
var monkey: Monkey = Monkey.instantiate()
monkeys_node.add_child(monkey)
monkey.global_position = possible_positions[i].global_position
monkey.dragged_into.connect(_on_coconut_drag_end)
monkeys.append(monkey)
# Will set up first word and monkeys
current_progression = 0
monkeys_node.set_drag_forwarding(Callable(), _monkeys_can_drop_data, _monkeys_drop_data)
func set_current_progression(p_current_progression: int) -> void:
super(p_current_progression)
word_label.text = "_".repeat(stimuli[current_progression].Word.length())
_current_letter = 0
func _set_current_letter(p_current_letter: int) -> void:
_current_letter = p_current_letter
var ind_good: = randi_range(0, monkeys.size() - 1)
var grapheme_distractions: Array = distractions[current_progression][_current_letter]
grapheme_distractions.shuffle()
for i in monkeys.size():
var monkey: = monkeys[i]
if i == ind_good:
monkey.stimulus = stimuli[current_progression].GPs[_current_letter]
elif i < ind_good:
monkey.stimulus = grapheme_distractions[min(i, grapheme_distractions.size() - 1)]
else:
monkey.stimulus = grapheme_distractions[min(i - 1, grapheme_distractions.size() - 1)]
## this is to use the drag and drop feature without its icons
#func _process(delta: float) -> void:
# DisplayServer.cursor_set_shape(DisplayServer.CURSOR_ARROW)
# Find the stimuli and distractions of the minigame.
func _find_stimuli_and_distractions() -> void:
var words_list: = Database.get_words_for_lesson(lesson_nb)
words_list.shuffle()
stimuli = []
distractions = []
for i in words_count:
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_grapheme_distrators_for_grapheme(GP.Grapheme, lesson_nb))
distractions.append(grapheme_distractions)
func _monkeys_drop_data(at_position: Vector2, data) -> void:
_on_coconut_drag_end(at_position - data.start_position)
func _monkeys_can_drop_data(_at_position: Vector2, _data) -> bool:
return true
func _on_coconut_drag_end(vector: Vector2) -> void:
print(vector.x)
@@ -0,0 +1,137 @@
[gd_scene load_steps=13 format=3 uid="uid://r5ug718aoo3u"]
[ext_resource type="PackedScene" uid="uid://8awe4usnucyv" path="res://sources/minigames/base/base_minigame.tscn" id="1_6nhsm"]
[ext_resource type="Script" path="res://sources/minigames/monkeys/monkeys_minigame.gd" id="2_12lw5"]
[ext_resource type="AudioStream" uid="uid://du2r8wbs2dclx" path="res://assets/minigames/monkeys/audio/kalulu_intro_monkeys_language.mp3" id="3_hhwrg"]
[ext_resource type="Texture2D" uid="uid://demg0gbj4lwic" path="res://assets/minigames/monkeys/graphic/background.png" id="3_xpybj"]
[ext_resource type="Texture2D" uid="uid://b6k16tfsm2p4u" path="res://assets/minigames/monkeys/graphic/ground.png" id="4_m2hoh"]
[ext_resource type="AudioStream" uid="uid://cu52j5ro8vhyg" path="res://assets/minigames/monkeys/audio/kalulu_end_monkeys_language.mp3" id="4_oe2vh"]
[ext_resource type="Texture2D" uid="uid://eor7gaddgj5d" path="res://assets/minigames/monkeys/graphic/palmtree_01.png" id="5_2qxen"]
[ext_resource type="Texture2D" uid="uid://fex5yvybinsx" path="res://assets/minigames/monkeys/graphic/palmtree_02.png" id="6_f5ri1"]
[ext_resource type="PackedScene" uid="uid://b8r26vroslasj" path="res://sources/minigames/monkeys/king_monkey.tscn" id="7_43p1x"]
[ext_resource type="FontFile" uid="uid://b2l4jfylc1v41" path="res://assets/fonts/DidactGothic-Regular.ttf" id="8_fem7m"]
[ext_resource type="Texture2D" uid="uid://disgg14rdmp81" path="res://assets/minigames/monkeys/graphic/textplank.png" id="8_w0ndh"]
[sub_resource type="FontVariation" id="FontVariation_br573"]
base_font = ExtResource("8_fem7m")
spacing_glyph = 20
[node name="Monkeys" instance=ExtResource("1_6nhsm")]
script = ExtResource("2_12lw5")
difficulty = 4
lesson_nb = 10
words_count = 3
help_kalulu_speech = ExtResource("3_hhwrg")
win_kalulu_speech = ExtResource("4_oe2vh")
[node name="Environment" type="VBoxContainer" parent="GameRoot" index="0"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/separation = 0
[node name="Background" type="TextureRect" parent="GameRoot/Environment" index="0"]
layout_mode = 2
size_flags_vertical = 3
texture = ExtResource("3_xpybj")
[node name="Ground" type="TextureRect" parent="GameRoot/Environment" index="1"]
custom_minimum_size = Vector2(2.08165e-12, 250)
layout_mode = 2
texture = ExtResource("4_m2hoh")
[node name="PalmTreeMonkeys" type="TextureRect" parent="GameRoot" index="1"]
layout_mode = 0
offset_left = 1646.0
offset_top = 120.0
offset_right = 2366.0
offset_bottom = 1686.0
texture = ExtResource("5_2qxen")
[node name="Position2" type="Control" parent="GameRoot/PalmTreeMonkeys" index="0"]
anchors_preset = 0
offset_left = 362.0
offset_top = 706.0
offset_right = 402.0
offset_bottom = 746.0
[node name="Position3" type="Control" parent="GameRoot/PalmTreeMonkeys" index="1"]
anchors_preset = 0
offset_left = 362.0
offset_top = 1084.0
offset_right = 402.0
offset_bottom = 1124.0
[node name="Position4" type="Control" parent="GameRoot/PalmTreeMonkeys" index="2"]
anchors_preset = 0
offset_left = 362.0
offset_top = 1474.0
offset_right = 402.0
offset_bottom = 1514.0
[node name="Position" type="Control" parent="GameRoot/PalmTreeMonkeys" index="3"]
anchors_preset = 0
offset_left = 362.0
offset_top = 220.0
offset_right = 402.0
offset_bottom = 260.0
[node name="Position5" type="Control" parent="GameRoot/PalmTreeMonkeys" index="4"]
anchors_preset = 0
offset_left = 131.0
offset_top = 395.0
offset_right = 171.0
offset_bottom = 435.0
[node name="Position6" type="Control" parent="GameRoot/PalmTreeMonkeys" index="5"]
anchors_preset = 0
offset_left = 600.0
offset_top = 395.0
offset_right = 640.0
offset_bottom = 435.0
[node name="PlamTreeKing" type="TextureRect" parent="GameRoot" index="2"]
layout_mode = 0
offset_left = 370.0
offset_top = 272.0
offset_right = 1078.0
offset_bottom = 1662.0
texture = ExtResource("6_f5ri1")
[node name="KingMonkey" parent="GameRoot/PlamTreeKing" index="0" instance=ExtResource("7_43p1x")]
position = Vector2(362, 308)
[node name="TextPlank" type="TextureRect" parent="GameRoot" index="3"]
layout_mode = 0
offset_left = 457.0
offset_top = 1487.0
offset_right = 1641.0
offset_bottom = 1734.0
texture = ExtResource("8_w0ndh")
[node name="MarginContainer" type="MarginContainer" parent="GameRoot/TextPlank" index="0"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_left = 130
theme_override_constants/margin_top = -10
[node name="Label" type="RichTextLabel" parent="GameRoot/TextPlank/MarginContainer" index="0"]
layout_mode = 2
theme_override_fonts/normal_font = SubResource("FontVariation_br573")
theme_override_font_sizes/normal_font_size = 180
text = "fort"
[node name="Monkeys" type="Control" parent="GameRoot" index="4"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
+6 -2
View File
@@ -24,6 +24,7 @@ const animations: = [
func _ready() -> void:
animated_sprite.sprite_frames = animations[randi() % animations.size()]
animated_sprite.play("idle_front")
func _on_button_pressed() -> void:
@@ -49,8 +50,11 @@ func turn_to_front() -> void:
func _on_animated_sprite_2d_animation_looped() -> void:
if animated_sprite.animation == "idle_front" and randi() % 4 == 0:
animated_sprite.play("idle_front_blink")
if animated_sprite.animation == "idle_front":
if randi() % 4 == 0:
animated_sprite.play("idle_front_blink")
elif animated_sprite.animation == "idle_front_blink":
animated_sprite.play("idle_front")
func fly_to(target: Vector2, duration: float) -> void:
+27
View File
@@ -8,6 +8,7 @@ const db_path: = "res://language_resources/fr/fr.db"
func _ready() -> void:
db.path = db_path
db.open_db()
_update_gps_with_type()
func _exit_tree() -> void:
@@ -34,6 +35,16 @@ func get_words_containing_grapheme(grapheme: String) -> Array:
return db.query_result
func get_words_for_lesson(lesson_nb: int) -> Array:
db.query_with_bindings("SELECT DISTINCT Word FROM Words INNER JOIN GPsInWords INNER JOIN GPs INNER JOIN Lessons on Words.ID = GPsInWords.WordID AND GPS.ID = GPsInWords.GPID AND Lessons.GPID = GPs.ID AND Lessons.LessonNb <= ?", [lesson_nb])
return db.query_result
func get_grapheme_distrators_for_grapheme(grapheme: String, lesson_nb: int) -> Array:
db.query_with_bindings("SELECT DISTINCT distractor.Grapheme From GPs stimuli INNER JOIN GPs distractor INNER JOIN Lessons ON stimuli.Grapheme=? AND distractor.type = stimuli.type AND distractor.Grapheme != stimuli.Grapheme AND Lessons.GPID = distractor.ID AND Lessons.LessonNb <= ?", [grapheme, lesson_nb])
return db.query_result
func copy_without_double_graphemes(input: Array) -> Array:
var output: = []
var graphemes: = {}
@@ -59,6 +70,22 @@ func _import_gps() -> void:
print(db.query_result)
func _update_gps_with_type() -> void:
var file = FileAccess.open("res://gp_list.json", FileAccess.READ)
var dict = JSON.parse_string(file.get_line())
for e in dict.values():
var g = e.GRAPHEME
var p = e.PHONEME
db.query_with_bindings("SELECT * FROM GPs WHERE Grapheme=? AND Phoneme=?", [g, p])
var id = db.query_result[0].ID
var type = 0
if e.CV == "V":
type = 1
elif e.CV == "C":
type = 2
db.query_with_bindings("UPDATE GPs SET Type=? WHERE id=?", [type, id])
func _import_words() -> void:
var file = FileAccess.open("res://data3/words_list.json", FileAccess.READ)
var dict = JSON.parse_string(file.get_line())