Rewrote the game in C#

Added sounds and music
This commit is contained in:
2024-03-21 11:53:40 +01:00
parent abf8bf23ba
commit afab78db12
53 changed files with 1117 additions and 741 deletions

15
game/arrow.tscn Normal file
View File

@@ -0,0 +1,15 @@
[gd_scene load_steps=2 format=3 uid="uid://cjc46cgqe1r20"]
[ext_resource type="Script" path="res://src/Game/Arrow.cs" id="1_fcyti"]
[node name="Outline" type="Polygon2D"]
color = Color(0, 0, 0, 1)
offset = Vector2(-32, -32)
antialiased = true
polygon = PackedVector2Array(0, 20, 0, 44, 20, 44, 20, 64, 32, 64, 64, 32, 32, 0, 20, 0, 20, 20)
script = ExtResource("1_fcyti")
[node name="Inner" type="Polygon2D" parent="."]
offset = Vector2(-32, -32)
antialiased = true
polygon = PackedVector2Array(4, 24, 4, 40, 24, 40, 24, 60, 30, 60, 58, 32, 30, 4, 24, 4, 24, 24)

View File

@@ -1,33 +0,0 @@
extends Polygon2D
class_name Arrow
@onready var inner := $Inner
@onready var player := $AnimationPlayer
@export_color_no_alpha var normal_color: Color = Color.WHITE
@export_color_no_alpha var done_color: Color = Color.KHAKI
var dir: Global.DIRS = Global.DIRS.RIGHT :
get:
return dir
set(v):
match v:
Global.DIRS.LEFT: rotation = PI
Global.DIRS.RIGHT: rotation = 0
Global.DIRS.UP: rotation = 3*PI/2
Global.DIRS.DOWN: rotation = PI/2
dir = v
var state: Global.ARROW_STATE = Global.ARROW_STATE.NORMAL :
get:
return state
set(v):
match v:
Global.ARROW_STATE.NORMAL:
if state == Global.ARROW_STATE.DONE:
player.play('done-error')
else:
inner.color = normal_color
Global.ARROW_STATE.DONE: inner.color = done_color
Global.ARROW_STATE.ERROR: player.play('error')
state = v

View File

@@ -1,88 +0,0 @@
[gd_scene load_steps=6 format=3 uid="uid://cjc46cgqe1r20"]
[ext_resource type="Script" path="res://game/arrow/arrow.gd" id="1_35aap"]
[sub_resource type="Animation" id="Animation_pyfum"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Inner:color")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Color(1, 1, 1, 1)]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath(".:modulate")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Color(1, 1, 1, 1)]
}
[sub_resource type="Animation" id="Animation_qo54c"]
resource_name = "done-error"
length = 0.5
step = 0.05
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Inner:color")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.15, 0.3, 0.5),
"transitions": PackedFloat32Array(1, 1, 1, 1),
"update": 0,
"values": [Color(0.941176, 0.901961, 0.54902, 1), Color(0.85098, 0.27451, 0.282353, 1), Color(0.85098, 0.27451, 0.282353, 1), Color(1, 1, 1, 1)]
}
[sub_resource type="Animation" id="Animation_1cugm"]
resource_name = "error"
length = 0.5
step = 0.05
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Inner:color")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.15, 0.3, 0.5),
"transitions": PackedFloat32Array(1, 1, 1, 1),
"update": 0,
"values": [Color(1, 1, 1, 1), Color(0.85098, 0.27451, 0.282353, 1), Color(0.85098, 0.27451, 0.282353, 1), Color(1, 1, 1, 1)]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_hujhs"]
_data = {
"RESET": SubResource("Animation_pyfum"),
"done-error": SubResource("Animation_qo54c"),
"error": SubResource("Animation_1cugm")
}
[node name="Outline" type="Polygon2D"]
color = Color(0, 0, 0, 1)
offset = Vector2(-32, -32)
antialiased = true
polygon = PackedVector2Array(0, 20, 0, 44, 20, 44, 20, 64, 32, 64, 64, 32, 32, 0, 20, 0, 20, 20)
script = ExtResource("1_35aap")
[node name="Inner" type="Polygon2D" parent="."]
offset = Vector2(-32, -32)
antialiased = true
polygon = PackedVector2Array(4, 24, 4, 40, 24, 40, 24, 60, 30, 60, 58, 32, 30, 4, 24, 4, 24, 24)
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
libraries = {
"": SubResource("AnimationLibrary_hujhs")
}

View File

@@ -1,111 +0,0 @@
extends Control
signal solved
signal input(correct: bool)
var InputHandler := preload('res://game/input.gd')
const all_data := preload('res://game/gems/data.gd').data
const ArrowScene := preload('res://game/arrow/arrow.tscn')
const total_width := 1920
const space_between_arrows := 8
const img_size := 48
@onready var icons := $Icons
@onready var name_label := $Name
@onready var arrows_container := $Arrows
@onready var error_timer := $ErrorTimer
@onready var player := $AnimationPlayer
var pos := -1
var arrow_count := 0
var raw_dirs: Array[Global.DIRS] = []
var arrows: Array[Arrow] = []
var in_error := true
var next_codes = []
func _on_error_timer_timeout() -> void:
in_error = false
func dir_input(dir: Global.DIRS) -> void:
if in_error:
return
if pos >= len(raw_dirs):
return
if dir == raw_dirs[pos]:
arrows[pos].state = Global.ARROW_STATE.DONE
pos += 1
if pos == arrow_count:
solved.emit()
start_new_round()
input.emit(true)
else:
in_error = true
error_timer.start()
arrows[pos].state = Global.ARROW_STATE.ERROR
for a in arrows:
a.state = Global.ARROW_STATE.NORMAL
pos = 0
input.emit(false)
func start_new_round() -> void:
InputHandler.start = null
var data = next_codes.pop_front()
next_codes.append(all_data[randi() % all_data.size()])
icons.update(data[1], next_codes)
in_error = true
if pos != -1:
raw_dirs.clear()
player.play('round-end')
await player.animation_finished
for n in arrows:
arrows_container.remove_child(n)
n.queue_free()
arrows.clear()
pos = 0
name_label.text = data[0]
raw_dirs.append_array(data[2])
arrow_count = len(data[2])
var total_arrow_width := 64 * arrow_count + space_between_arrows * (arrow_count - 1)
var start_x := (total_width - total_arrow_width) / 2.0
for d in data[2]:
var a: Arrow = ArrowScene.instantiate()
a.set_position(Vector2(start_x, 500))
a.dir = d
arrows.append(a)
arrows_container.add_child(a)
start_x += 64 + space_between_arrows
player.play('round-start')
await player.animation_finished
in_error = false
func _input(event: InputEvent) -> void:
var d = InputHandler._input(event)
if d != null:
dir_input(d)
if event.is_action_released('escape'):
get_tree().change_scene_to_packed(load('res://main_menu/main_menu.tscn'))
func _ready() -> void:
randomize()
for i in range(8):
next_codes.append(all_data[randi() % all_data.size()])
icons.update(null, next_codes)
start_new_round()
solved.connect($StatContainer/Solved._on_solved)
input.connect($StatContainer/Combo._on_input)

View File

@@ -1,306 +1,12 @@
[gd_scene load_steps=13 format=3 uid="uid://c4sq21c5gf4tr"]
[gd_scene load_steps=12 format=3 uid="uid://c4sq21c5gf4tr"]
[ext_resource type="Script" path="res://game/game.gd" id="1_dkhe3"]
[ext_resource type="Texture2D" uid="uid://ctuppqhifm5nr" path="res://game/gems/placeholder.png" id="2_1o8ih"]
[ext_resource type="Script" path="res://game/icons.gd" id="2_rgbt2"]
[sub_resource type="GDScript" id="GDScript_sce7k"]
script/source = "extends Label
var count = 0
func _on_solved() -> void:
count += 1
text = str(count)
"
[sub_resource type="GDScript" id="GDScript_ngbu4"]
script/source = "extends Label
var count = 0
func _on_input(correct: bool) -> void:
if correct:
count += 1
else:
count = 0
text = str(count)
"
[sub_resource type="Animation" id="Animation_v1pyg"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Icon:self_modulate")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Color(1, 1, 1, 1)]
}
tracks/1/type = "bezier"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("Icon:position:x")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"handle_modes": PackedInt32Array(0),
"points": PackedFloat32Array(72, -0.25, 0, 0.2, -1),
"times": PackedFloat32Array(0)
}
tracks/2/type = "value"
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/path = NodePath("Icon1:position")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector2(264, 136)]
}
tracks/3/type = "value"
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/path = NodePath("Icon2:position")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector2(456, 136)]
}
tracks/4/type = "value"
tracks/4/imported = false
tracks/4/enabled = true
tracks/4/path = NodePath("Icon3:position")
tracks/4/interp = 1
tracks/4/loop_wrap = true
tracks/4/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector2(648, 136)]
}
tracks/5/type = "value"
tracks/5/imported = false
tracks/5/enabled = true
tracks/5/path = NodePath("Icon4:position")
tracks/5/interp = 1
tracks/5/loop_wrap = true
tracks/5/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector2(840, 136)]
}
tracks/6/type = "value"
tracks/6/imported = false
tracks/6/enabled = true
tracks/6/path = NodePath("Icon5:position")
tracks/6/interp = 1
tracks/6/loop_wrap = true
tracks/6/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector2(1032, 136)]
}
tracks/7/type = "value"
tracks/7/imported = false
tracks/7/enabled = true
tracks/7/path = NodePath("Icon6:position")
tracks/7/interp = 1
tracks/7/loop_wrap = true
tracks/7/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector2(1224, 136)]
}
tracks/8/type = "value"
tracks/8/imported = false
tracks/8/enabled = true
tracks/8/path = NodePath("Icon7:position")
tracks/8/interp = 1
tracks/8/loop_wrap = true
tracks/8/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector2(1416, 136)]
}
tracks/9/type = "value"
tracks/9/imported = false
tracks/9/enabled = true
tracks/9/path = NodePath("Icon8:position")
tracks/9/interp = 1
tracks/9/loop_wrap = true
tracks/9/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector2(1608, 136)]
}
tracks/10/type = "value"
tracks/10/imported = false
tracks/10/enabled = true
tracks/10/path = NodePath("Icon8:self_modulate")
tracks/10/interp = 1
tracks/10/loop_wrap = true
tracks/10/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Color(1, 1, 1, 0)]
}
[sub_resource type="Animation" id="Animation_bevbe"]
resource_name = "round-change"
length = 0.4
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Icon:self_modulate")
tracks/0/interp = 1
tracks/0/loop_wrap = false
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.4),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [Color(1, 1, 1, 1), Color(1, 1, 1, 0)]
}
tracks/1/type = "bezier"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("Icon:position:x")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"handle_modes": PackedInt32Array(0, 0),
"points": PackedFloat32Array(72, -0.25, 0, 0.2, -1, -520, 0, 0, 0, 0),
"times": PackedFloat32Array(0, 0.4)
}
tracks/2/type = "value"
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/path = NodePath("Icon1:position")
tracks/2/interp = 2
tracks/2/loop_wrap = false
tracks/2/keys = {
"times": PackedFloat32Array(0.0001, 0.4),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [Vector2(264, 136), Vector2(72, 136)]
}
tracks/3/type = "value"
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/path = NodePath("Icon2:position")
tracks/3/interp = 2
tracks/3/loop_wrap = false
tracks/3/keys = {
"times": PackedFloat32Array(0, 0.4),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [Vector2(456, 136), Vector2(264, 136)]
}
tracks/4/type = "value"
tracks/4/imported = false
tracks/4/enabled = true
tracks/4/path = NodePath("Icon3:position")
tracks/4/interp = 2
tracks/4/loop_wrap = false
tracks/4/keys = {
"times": PackedFloat32Array(0, 0.4),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [Vector2(648, 136), Vector2(456, 136)]
}
tracks/5/type = "value"
tracks/5/imported = false
tracks/5/enabled = true
tracks/5/path = NodePath("Icon4:position")
tracks/5/interp = 2
tracks/5/loop_wrap = false
tracks/5/keys = {
"times": PackedFloat32Array(0, 0.4),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [Vector2(840, 136), Vector2(648, 136)]
}
tracks/6/type = "value"
tracks/6/imported = false
tracks/6/enabled = true
tracks/6/path = NodePath("Icon5:position")
tracks/6/interp = 2
tracks/6/loop_wrap = false
tracks/6/keys = {
"times": PackedFloat32Array(0, 0.4),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [Vector2(1032, 136), Vector2(840, 136)]
}
tracks/7/type = "value"
tracks/7/imported = false
tracks/7/enabled = true
tracks/7/path = NodePath("Icon6:position")
tracks/7/interp = 2
tracks/7/loop_wrap = false
tracks/7/keys = {
"times": PackedFloat32Array(0, 0.4),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [Vector2(1224, 136), Vector2(1032, 136)]
}
tracks/8/type = "value"
tracks/8/imported = false
tracks/8/enabled = true
tracks/8/path = NodePath("Icon7:position")
tracks/8/interp = 2
tracks/8/loop_wrap = false
tracks/8/keys = {
"times": PackedFloat32Array(0, 0.4),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [Vector2(1416, 136), Vector2(1224, 136)]
}
tracks/9/type = "value"
tracks/9/imported = false
tracks/9/enabled = true
tracks/9/path = NodePath("Icon8:position")
tracks/9/interp = 2
tracks/9/loop_wrap = false
tracks/9/keys = {
"times": PackedFloat32Array(0, 0.4),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [Vector2(1608, 136), Vector2(1416, 136)]
}
tracks/10/type = "value"
tracks/10/imported = false
tracks/10/enabled = true
tracks/10/path = NodePath("Icon8:self_modulate")
tracks/10/interp = 1
tracks/10/loop_wrap = true
tracks/10/keys = {
"times": PackedFloat32Array(0, 0.4),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [Color(1, 1, 1, 0), Color(1, 1, 1, 1)]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_bt825"]
_data = {
"RESET": SubResource("Animation_v1pyg"),
"round-change": SubResource("Animation_bevbe")
}
[ext_resource type="Script" path="res://src/Game/Game.cs" id="1_k7a4x"]
[ext_resource type="Script" path="res://src/Game/Stats.cs" id="2_u5dw2"]
[ext_resource type="Script" path="res://src/Game/Icons.cs" id="3_xkfay"]
[ext_resource type="AudioStream" uid="uid://u23ytxxg1iqg" path="res://sounds/swipe_ok.wav" id="4_2w4vj"]
[ext_resource type="AudioStream" uid="uid://b4pdua27sq0f7" path="res://music/_music.tres" id="4_arwoj"]
[ext_resource type="Script" path="res://src/Game/Audio.cs" id="4_xhtam"]
[ext_resource type="AudioStream" uid="uid://c3dpfownsatsb" path="res://sounds/error.wav" id="5_pklm0"]
[sub_resource type="Animation" id="Animation_2hnmi"]
length = 0.001
@@ -395,6 +101,7 @@ _data = {
[node name="Gem" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = 20.0
@@ -403,13 +110,14 @@ offset_right = -20.0
offset_bottom = -20.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_dkhe3")
script = ExtResource("1_k7a4x")
[node name="StatContainer" type="GridContainer" parent="."]
layout_mode = 0
offset_right = 132.0
offset_bottom = 104.0
columns = 2
script = ExtResource("2_u5dw2")
[node name="SolvedT" type="Label" parent="StatContainer"]
layout_mode = 2
@@ -420,7 +128,6 @@ custom_minimum_size = Vector2(50, 0)
layout_mode = 2
text = "0"
horizontal_alignment = 2
script = SubResource("GDScript_sce7k")
[node name="ComboT" type="Label" parent="StatContainer"]
layout_mode = 2
@@ -430,62 +137,10 @@ text = "Combo: "
layout_mode = 2
text = "0"
horizontal_alignment = 2
script = SubResource("GDScript_ngbu4")
[node name="Icons" type="Node2D" parent="."]
position = Vector2(448, 128)
script = ExtResource("2_rgbt2")
[node name="AnimationPlayer" type="AnimationPlayer" parent="Icons"]
libraries = {
"": SubResource("AnimationLibrary_bt825")
}
[node name="Icon" type="Sprite2D" parent="Icons"]
position = Vector2(72, 136)
scale = Vector2(3, 3)
texture = ExtResource("2_1o8ih")
[node name="Icon1" type="Sprite2D" parent="Icons"]
position = Vector2(264, 136)
scale = Vector2(3, 3)
texture = ExtResource("2_1o8ih")
[node name="Icon2" type="Sprite2D" parent="Icons"]
position = Vector2(456, 136)
scale = Vector2(3, 3)
texture = ExtResource("2_1o8ih")
[node name="Icon3" type="Sprite2D" parent="Icons"]
position = Vector2(648, 136)
scale = Vector2(3, 3)
texture = ExtResource("2_1o8ih")
[node name="Icon4" type="Sprite2D" parent="Icons"]
position = Vector2(840, 136)
scale = Vector2(3, 3)
texture = ExtResource("2_1o8ih")
[node name="Icon5" type="Sprite2D" parent="Icons"]
position = Vector2(1032, 136)
scale = Vector2(3, 3)
texture = ExtResource("2_1o8ih")
[node name="Icon6" type="Sprite2D" parent="Icons"]
position = Vector2(1224, 136)
scale = Vector2(3, 3)
texture = ExtResource("2_1o8ih")
[node name="Icon7" type="Sprite2D" parent="Icons"]
position = Vector2(1416, 136)
scale = Vector2(3, 3)
texture = ExtResource("2_1o8ih")
[node name="Icon8" type="Sprite2D" parent="Icons"]
self_modulate = Color(1, 1, 1, 0)
position = Vector2(1608, 136)
scale = Vector2(3, 3)
texture = ExtResource("2_1o8ih")
position = Vector2(448, 264)
script = ExtResource("3_xkfay")
[node name="Name" type="Label" parent="."]
layout_mode = 0
@@ -496,14 +151,29 @@ offset_bottom = 434.0
text = "Teseoxfugholxcfyhngioldyfhgoiljxcnfohgibncdxflhjnfgdlkh"
[node name="Arrows" type="Node2D" parent="."]
[node name="ErrorTimer" type="Timer" parent="."]
wait_time = 0.5
one_shot = true
position = Vector2(0, 500)
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
libraries = {
"": SubResource("AnimationLibrary_wklcx")
}
[connection signal="timeout" from="ErrorTimer" to="." method="_on_error_timer_timeout"]
[node name="Audio" type="Node" parent="."]
script = ExtResource("4_xhtam")
[node name="MusicPlayer" type="AudioStreamPlayer" parent="Audio"]
stream = ExtResource("4_arwoj")
volume_db = -14.0
autoplay = true
bus = &"Music"
[node name="OkSound" type="AudioStreamPlayer" parent="Audio"]
stream = ExtResource("4_2w4vj")
max_polyphony = 10
bus = &"Sound"
[node name="ErrorSound" type="AudioStreamPlayer" parent="Audio"]
stream = ExtResource("5_pklm0")
volume_db = -8.0
max_polyphony = 10
bus = &"Sound"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 639 B

View File

@@ -1,34 +0,0 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://ctuppqhifm5nr"
path="res://.godot/imported/placeholder.png-7df2040f50328a788de3559fa4c98f44.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://game/gems/placeholder.png"
dest_files=["res://.godot/imported/placeholder.png-7df2040f50328a788de3559fa4c98f44.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

View File

@@ -1,26 +0,0 @@
extends Node2D
@onready var player := $AnimationPlayer
@onready var main_icon := $Icon
@onready var icons := [
$Icon1,
$Icon2,
$Icon3,
$Icon4,
$Icon5,
$Icon6,
$Icon7,
$Icon8
]
func update(main, queue) -> void:
if main != null:
player.play('round-change')
await player.animation_finished
main_icon.texture = main
for i in range(8):
icons[i].texture = queue[i][1]
player.play('RESET')

View File

@@ -1,37 +0,0 @@
extends Object
static var start = null
static func calc_swipe(end):
if start == null:
return null
var delta = end - start
var biggest = max(abs(delta.x), abs(delta.y))
if biggest < 50:
return null
if abs(delta.x) > abs(delta.y):
if delta.x < 0:
return Global.DIRS.LEFT
else:
return Global.DIRS.RIGHT
else:
if delta.y < 0:
return Global.DIRS.UP
else:
return Global.DIRS.DOWN
static func _input(event: InputEvent):
var d = null
if event.is_action_pressed('left_mouse_button'):
start = event.get_position()
if event.is_action_released('left_mouse_button'):
d = calc_swipe(event.get_position())
if event.is_action_released('key_up'):
d = Global.DIRS.UP
if event.is_action_released('key_down'):
d = Global.DIRS.DOWN
if event.is_action_released('key_left'):
d = Global.DIRS.LEFT
if event.is_action_released('key_right'):
d = Global.DIRS.RIGHT
return d