diff --git a/assets/sounds/base-slow-down.wav b/assets/sounds/base-slow-down.wav new file mode 100644 index 0000000..ca38f26 Binary files /dev/null and b/assets/sounds/base-slow-down.wav differ diff --git a/assets/sounds/base-slow-down.wav.import b/assets/sounds/base-slow-down.wav.import new file mode 100644 index 0000000..4869d2e --- /dev/null +++ b/assets/sounds/base-slow-down.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://ctgnj1ppqutqb" +path="res://.godot/imported/base-slow-down.wav-3a6ef1170d81f84cc5088f9f222fd549.sample" + +[deps] + +source_file="res://assets/sounds/base-slow-down.wav" +dest_files=["res://.godot/imported/base-slow-down.wav-3a6ef1170d81f84cc5088f9f222fd549.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/assets/sounds/base-slow-down.xrns b/assets/sounds/base-slow-down.xrns new file mode 100644 index 0000000..299d6aa Binary files /dev/null and b/assets/sounds/base-slow-down.xrns differ diff --git a/assets/sounds/end-slow-down.ogg b/assets/sounds/end-slow-down.ogg new file mode 100644 index 0000000..650ce58 Binary files /dev/null and b/assets/sounds/end-slow-down.ogg differ diff --git a/assets/sounds/end-slow-down.ogg.import b/assets/sounds/end-slow-down.ogg.import new file mode 100644 index 0000000..4f223a3 --- /dev/null +++ b/assets/sounds/end-slow-down.ogg.import @@ -0,0 +1,19 @@ +[remap] + +importer="oggvorbisstr" +type="AudioStreamOggVorbis" +uid="uid://34ymwv6kgxrr" +path="res://.godot/imported/end-slow-down.ogg-f909228c04477182acb4402d07af9cae.oggvorbisstr" + +[deps] + +source_file="res://assets/sounds/end-slow-down.ogg" +dest_files=["res://.godot/imported/end-slow-down.ogg-f909228c04477182acb4402d07af9cae.oggvorbisstr"] + +[params] + +loop=false +loop_offset=0 +bpm=0 +beat_count=0 +bar_beats=4 diff --git a/assets/sounds/loop-slow-down.ogg b/assets/sounds/loop-slow-down.ogg new file mode 100644 index 0000000..6d36acb Binary files /dev/null and b/assets/sounds/loop-slow-down.ogg differ diff --git a/assets/sounds/loop-slow-down.ogg.import b/assets/sounds/loop-slow-down.ogg.import new file mode 100644 index 0000000..7ccb8b9 --- /dev/null +++ b/assets/sounds/loop-slow-down.ogg.import @@ -0,0 +1,19 @@ +[remap] + +importer="oggvorbisstr" +type="AudioStreamOggVorbis" +uid="uid://byo5ot6khpma1" +path="res://.godot/imported/loop-slow-down.ogg-4c94de2fb5d31e370d68a5441b2d2708.oggvorbisstr" + +[deps] + +source_file="res://assets/sounds/loop-slow-down.ogg" +dest_files=["res://.godot/imported/loop-slow-down.ogg-4c94de2fb5d31e370d68a5441b2d2708.oggvorbisstr"] + +[params] + +loop=false +loop_offset=0 +bpm=0 +beat_count=0 +bar_beats=4 diff --git a/assets/sounds/satisfying-pop.wav b/assets/sounds/satisfying-pop.wav new file mode 100644 index 0000000..3a18528 Binary files /dev/null and b/assets/sounds/satisfying-pop.wav differ diff --git a/assets/sounds/satisfying-pop.wav.import b/assets/sounds/satisfying-pop.wav.import new file mode 100644 index 0000000..f893094 --- /dev/null +++ b/assets/sounds/satisfying-pop.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://dd8qenyeo60he" +path="res://.godot/imported/satisfying-pop.wav-7cfbb3a826c46a04a9e2011e37046c81.sample" + +[deps] + +source_file="res://assets/sounds/satisfying-pop.wav" +dest_files=["res://.godot/imported/satisfying-pop.wav-7cfbb3a826c46a04a9e2011e37046c81.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/assets/sounds/satisfying-pop.xrns b/assets/sounds/satisfying-pop.xrns new file mode 100644 index 0000000..e64ffc8 Binary files /dev/null and b/assets/sounds/satisfying-pop.xrns differ diff --git a/assets/sounds/start-slow-down.ogg b/assets/sounds/start-slow-down.ogg new file mode 100644 index 0000000..05f4223 Binary files /dev/null and b/assets/sounds/start-slow-down.ogg differ diff --git a/assets/sounds/start-slow-down.ogg.import b/assets/sounds/start-slow-down.ogg.import new file mode 100644 index 0000000..96c6ed6 --- /dev/null +++ b/assets/sounds/start-slow-down.ogg.import @@ -0,0 +1,19 @@ +[remap] + +importer="oggvorbisstr" +type="AudioStreamOggVorbis" +uid="uid://bn0sh471n3imb" +path="res://.godot/imported/start-slow-down.ogg-3246e67ff8f88aae0b9631b6e38b0984.oggvorbisstr" + +[deps] + +source_file="res://assets/sounds/start-slow-down.ogg" +dest_files=["res://.godot/imported/start-slow-down.ogg-3246e67ff8f88aae0b9631b6e38b0984.oggvorbisstr"] + +[params] + +loop=false +loop_offset=0 +bpm=0 +beat_count=0 +bar_beats=4 diff --git a/assets/sounds/unsatisfying-oomf.wav b/assets/sounds/unsatisfying-oomf.wav new file mode 100644 index 0000000..c593d64 Binary files /dev/null and b/assets/sounds/unsatisfying-oomf.wav differ diff --git a/assets/sounds/unsatisfying-oomf.wav.import b/assets/sounds/unsatisfying-oomf.wav.import new file mode 100644 index 0000000..4367d6e --- /dev/null +++ b/assets/sounds/unsatisfying-oomf.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://h1m0caxm0dkp" +path="res://.godot/imported/unsatisfying-oomf.wav-883f7d7558ab5891c6461261eb6b23c2.sample" + +[deps] + +source_file="res://assets/sounds/unsatisfying-oomf.wav" +dest_files=["res://.godot/imported/unsatisfying-oomf.wav-883f7d7558ab5891c6461261eb6b23c2.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/project.godot b/project.godot index 9cd7513..843e409 100644 --- a/project.godot +++ b/project.godot @@ -29,6 +29,7 @@ window/stretch/mode="viewport" [global_group] collectable="" +audio="" [rendering] diff --git a/scenes/debug/MouseLoop.gd b/scenes/debug/MouseLoop.gd index f80f8db..1349011 100644 --- a/scenes/debug/MouseLoop.gd +++ b/scenes/debug/MouseLoop.gd @@ -45,13 +45,30 @@ func create_loop_object(loop:Array): add_child(scene) await get_tree().create_timer(.2).timeout var contents = scene.get_contained_nodes() - print(contents) + process_collection(contents) + +func process_collection(contents:Array) -> void: var collectables = get_tree().get_nodes_in_group("collectable") - for i in contents: - if not (i in collectables): + var type : int = -1 + var count : int = 0 + var mistakes : int = 0 + + for i in range(len(contents)): + var obj = contents[i] + + if not (obj in collectables): continue - # TODO: color matching logic - i.remove() + + if type == -1 or obj.type == type: + type = obj.type + count += 1 + else: + obj.is_good = false + mistakes += 1 + + obj.remove(i) + + print("Good: " + str(count) + "; Bad: " + str(mistakes)) func _on_cursor_started_drawing(pos:Vector2) -> void: print("started drawing") @@ -62,8 +79,11 @@ func _on_cursor_started_drawing(pos:Vector2) -> void: $StartMarker.visible = true $LineProgress.visible = true is_drawing = true + $AudioSlowDownStart.play() + await $AudioSlowDownStart.finished + $AudioSlowDownLoop.play() -func _on_cursor_stopped_drawing() -> void: +func _on_cursor_stopped_drawing(data:Array) -> void: print("stopped drawing") var cam = get_viewport().get_camera_2d() var t = get_tree().create_tween() @@ -71,3 +91,11 @@ func _on_cursor_stopped_drawing() -> void: $StartMarker.visible = false $LineProgress.visible = false is_drawing = false + if CURSOR.loop_stack.size() == 0: + var err_loop = Globals.SCENE_LOOP.instantiate() + err_loop.is_error = true + err_loop.points = data + add_child(err_loop) + $AudioSlowDownStart.stop() + $AudioSlowDownLoop.stop() + $AudioSlowDownEnd.play() diff --git a/scenes/debug/MouseLoop.tscn b/scenes/debug/MouseLoop.tscn index dd58be8..0c2a47b 100644 --- a/scenes/debug/MouseLoop.tscn +++ b/scenes/debug/MouseLoop.tscn @@ -1,10 +1,15 @@ -[gd_scene load_steps=10 format=3 uid="uid://d1bduqxqx10jb"] +[gd_scene load_steps=15 format=3 uid="uid://d1bduqxqx10jb"] [ext_resource type="Script" uid="uid://b1ddnopgn4scy" path="res://scenes/debug/MouseLoop.gd" id="1_x04i4"] [ext_resource type="PackedScene" uid="uid://byipv4uqxdtfk" path="res://scenes/objects/Cursor.tscn" id="3_aaj44"] [ext_resource type="Texture2D" uid="uid://c7en2ehk2mvk0" path="res://assets/textures/lined-paper.png" id="3_u4ca0"] [ext_resource type="PackedScene" uid="uid://dnr505je252gd" path="res://scenes/objects/StartMarker.tscn" id="4_u4ca0"] [ext_resource type="PackedScene" uid="uid://dnkw8qq4rm0td" path="res://scenes/objects/InkWell.tscn" id="5_olkr6"] +[ext_resource type="AudioStream" uid="uid://bn0sh471n3imb" path="res://assets/sounds/start-slow-down.ogg" id="6_32d1g"] +[ext_resource type="AudioStream" uid="uid://34ymwv6kgxrr" path="res://assets/sounds/end-slow-down.ogg" id="7_udeto"] +[ext_resource type="AudioStream" uid="uid://byo5ot6khpma1" path="res://assets/sounds/loop-slow-down.ogg" id="8_thiq5"] +[ext_resource type="AudioStream" uid="uid://dd8qenyeo60he" path="res://assets/sounds/satisfying-pop.wav" id="9_udeto"] +[ext_resource type="AudioStream" uid="uid://h1m0caxm0dkp" path="res://assets/sounds/unsatisfying-oomf.wav" id="10_thiq5"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_va2mg"] size = Vector2(100, 591) @@ -67,5 +72,21 @@ z_index = -1 [node name="InkWell" parent="LineProgress" instance=ExtResource("5_olkr6")] +[node name="AudioSlowDownStart" type="AudioStreamPlayer" parent="." groups=["audio"]] +stream = ExtResource("6_32d1g") + +[node name="AudioSlowDownEnd" type="AudioStreamPlayer" parent="." groups=["audio"]] +stream = ExtResource("7_udeto") + +[node name="AudioSlowDownLoop" type="AudioStreamPlayer" parent="." groups=["audio"]] +stream = ExtResource("8_thiq5") +parameters/looping = true + +[node name="PopSound" type="AudioStreamPlayer" parent="." groups=["audio"]] +stream = ExtResource("9_udeto") + +[node name="OomfSound" type="AudioStreamPlayer" parent="." groups=["audio"]] +stream = ExtResource("10_thiq5") + [connection signal="started_drawing" from="Cursor" to="." method="_on_cursor_started_drawing"] [connection signal="stopped_drawing" from="Cursor" to="." method="_on_cursor_stopped_drawing"] diff --git a/scenes/objects/Collectable.tscn b/scenes/objects/Collectable.tscn index 988a813..036e133 100644 --- a/scenes/objects/Collectable.tscn +++ b/scenes/objects/Collectable.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=4 format=3 uid="uid://c0srxosarykx7"] +[gd_scene load_steps=9 format=3 uid="uid://c0srxosarykx7"] [ext_resource type="Script" uid="uid://bmke2komimx40" path="res://scenes/objects/collectable.gd" id="1_dtuyt"] [ext_resource type="Texture2D" uid="uid://54uy8wr13v7y" path="res://assets/sprites/monster-programmer.png" id="2_dtuyt"] @@ -6,13 +6,123 @@ [sub_resource type="RectangleShape2D" id="RectangleShape2D_aaj44"] size = Vector2(48, 46) +[sub_resource type="Animation" id="Animation_dtuyt"] +resource_name = "Walking" +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Sprite2D:rotation") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 0.25, 0.5, 0.75, 1), +"transitions": PackedFloat32Array(1, 1, 1, 1, 1), +"update": 0, +"values": [0.0, -0.0872665, 0.0, 0.0872665, 0.0] +} + +[sub_resource type="Animation" id="Animation_ym61t"] +length = 0.001 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Sprite2D:rotation") +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("Sprite2D:scale") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Vector2(1.25, 1.25)] +} + +[sub_resource type="Animation" id="Animation_2crgn"] +resource_name = "BadGrab" +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Sprite2D:rotation") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 0.125, 0.25, 0.375), +"transitions": PackedFloat32Array(1, 1, 1, 1), +"update": 0, +"values": [0.0, -0.174533, 0.174533, 0.0] +} +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("Sprite2D:scale") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0, 0.375), +"transitions": PackedFloat32Array(1, 1), +"update": 0, +"values": [Vector2(1, 1), Vector2(1.25, 1.25)] +} + +[sub_resource type="Animation" id="Animation_5hcc2"] +resource_name = "GoodGrab" +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Sprite2D:rotation") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 1), +"transitions": PackedFloat32Array(1, 1), +"update": 0, +"values": [0.0, -6.28319] +} +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("Sprite2D:scale") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0, 1), +"transitions": PackedFloat32Array(1, 1), +"update": 0, +"values": [Vector2(1, 1), Vector2(1e-05, 1e-05)] +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_5hcc2"] +_data = { +&"BadGrab": SubResource("Animation_2crgn"), +&"GoodGrab": SubResource("Animation_5hcc2"), +&"RESET": SubResource("Animation_ym61t"), +&"Walking": SubResource("Animation_dtuyt") +} + [node name="Collectable" type="CharacterBody2D" groups=["collectable"]] z_index = -1 script = ExtResource("1_dtuyt") -[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +[node name="CollisionShape2D" type="CollisionShape2D" parent="." groups=["collectable"]] position = Vector2(1, 0) shape = SubResource("RectangleShape2D_aaj44") [node name="Sprite2D" type="Sprite2D" parent="."] +scale = Vector2(1.25, 1.25) texture = ExtResource("2_dtuyt") + +[node name="AnimationPlayer" type="AnimationPlayer" parent="."] +libraries = { +&"": SubResource("AnimationLibrary_5hcc2") +} diff --git a/scenes/objects/collectable.gd b/scenes/objects/collectable.gd index 021b49d..6b818f1 100644 --- a/scenes/objects/collectable.gd +++ b/scenes/objects/collectable.gd @@ -1,6 +1,7 @@ extends CharacterBody2D @export_enum("color", "red", "blue", "green", "black") var type : int = 3 +var is_good : bool = true func _ready() -> void: velocity = Vector2.from_angle(randf() * PI * 2) * 25 @@ -17,5 +18,16 @@ func _process(delta: float) -> void: func vibrate() -> void: $Sprite2D.offset = Vector2((randf() - .5) * 2, (randf() - .5) * 2) * 1 -func remove() -> void: +func remove(delay:int) -> void: + if is_good: + $AnimationPlayer.play("GoodGrab") + else: + $AnimationPlayer.play("BadGrab") + + await get_tree().create_timer(delay * 0.1).timeout + + if is_good: + get_parent().get_node("PopSound").play() + else: + get_parent().get_node("OomfSound").play() get_tree().queue_delete(self) diff --git a/scenes/objects/cursor.gd b/scenes/objects/cursor.gd index f954968..fa47ed0 100644 --- a/scenes/objects/cursor.gd +++ b/scenes/objects/cursor.gd @@ -40,10 +40,10 @@ func _input(event: InputEvent) -> void: else: if is_close_to_loop(): create_valid_loop() - init_history_stack() if is_drawing: - emit_signal("stopped_drawing") + emit_signal("stopped_drawing", positions_history) is_drawing = false + init_history_stack() func get_tail(max_length: int = 32) -> Array: var tail_length = min(positions_history.size(), max_length) @@ -51,7 +51,7 @@ func get_tail(max_length: int = 32) -> Array: return output func is_close_to_loop () -> bool: - if positions_history.size() < 4: + if positions_history.size() < 16: return false var to = positions_history[positions_history.size() - 1] @@ -71,6 +71,13 @@ func create_valid_loop() -> void: var smoothed_loop = positions_history var last = 0 + # clean up a bit + while (smoothed_loop.pop_back() as Vector2).distance_to(smoothed_loop[0]) < Globals.SNAP_DISTANCE / 2: + smoothed_loop.pop_back() + for i in range(1,8): + if (smoothed_loop[1] as Vector2).distance_to(smoothed_loop[0]) < Globals.SNAP_DISTANCE / 2: + smoothed_loop.pop_front() + # simplify for j in range(1): var new_loop = []