diff --git a/2D Assets/KNATIVE.png b/2D Assets/KNATIVE.png new file mode 100644 index 0000000..efb7321 Binary files /dev/null and b/2D Assets/KNATIVE.png differ diff --git a/2D Assets/KNATIVE.png.import b/2D Assets/KNATIVE.png.import new file mode 100644 index 0000000..99279ad --- /dev/null +++ b/2D Assets/KNATIVE.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://c5hqlla5086kp" +path="res://.godot/imported/KNATIVE.png-1c9e246b573182a59d4c482c09479981.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://2D Assets/KNATIVE.png" +dest_files=["res://.godot/imported/KNATIVE.png-1c9e246b573182a59d4c482c09479981.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 diff --git a/2D Assets/background.png b/2D Assets/background.png deleted file mode 100644 index 79c2c67..0000000 Binary files a/2D Assets/background.png and /dev/null differ diff --git a/ConveyerFilter.gd b/ConveyerFilter.gd new file mode 100644 index 0000000..eb6d087 --- /dev/null +++ b/ConveyerFilter.gd @@ -0,0 +1,42 @@ +extends Node2D + +var selected +var events = [] +var destination +var conveyer +var dragging +var sendingEnd = false +var can_send = false +var started = false + +func setup(conveyer) -> void: + self.conveyer = conveyer + self.can_send = false + self.sendingEnd = false + self.started = false + self.events = [] + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta: float) -> void: + if self.can_send and not self.started and self.destination != null: + self.send_event() + pass + +func create_conveyor(): + conveyer.set_point_position(0, selected.get_position()) + conveyer.set_point_position(1, destination) + +func send_event(): + print("sending events!") + self.started = true + for n in events.size(): + events[n].sending = true + var tween = get_tree().create_tween() + print("event sent ", n); + tween.tween_property(events[n], "position", destination, 2).set_trans(tween.TRANS_LINEAR) + await tween.finished diff --git a/README.md b/README.md new file mode 100644 index 0000000..71d9c9b --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ +# Knative Educational Venting Game +This project is a fork of the [Knative]([https://youtu.be/Dn6qFXBi1wc?si=WHQbPkcfeDBLlcP5](https://github.com/knative-extensions/educational-game)). This version includes enhanced functionality for multi-sink venting, allowing events to be directed to multiple sinks based on their color. + +### Video Demonstration + + + Watch the video + + + +## Features +- **Conveyor Belt System**: Events move along a conveyor belt. +- **Color Filters**: Filters allow events to pass through based on their color. +- **Multi-Sink Venting**: Events can now be directed to multiple sinks based on their color, enhancing the gameplay experience. +- **Interactive UI**: Players can drag filters and click buttons to control the flow of events. diff --git a/Scenes/boxClick.tscn b/Scenes/boxClick.tscn index 21991f8..5c0d423 100644 --- a/Scenes/boxClick.tscn +++ b/Scenes/boxClick.tscn @@ -1,21 +1,27 @@ -[gd_scene load_steps=13 format=3 uid="uid://c8lin6dur1umi"] +[gd_scene load_steps=18 format=3 uid="uid://c8lin6dur1umi"] -[ext_resource type="Texture2D" uid="uid://crbbdu26tlg2k" path="res://2D Assets/background.png" id="1_fdm6s"] +[ext_resource type="Texture2D" uid="uid://c5hqlla5086kp" path="res://2D Assets/KNATIVE.png" id="1_tf1jf"] [ext_resource type="Texture2D" uid="uid://dlnjpu1sbekqf" path="res://2D Assets/conveyer texture.png" id="2_ocbiy"] [ext_resource type="Script" path="res://Scripts/conveyor.gd" id="3_5pogt"] [ext_resource type="PackedScene" uid="uid://whu4rwgsyl8u" path="res://Scenes/sink.tscn" id="4_2wh4q"] +[ext_resource type="Texture2D" uid="uid://dehcuwck0lv0e" path="res://2D Assets/sinks/redSink.png" id="5_16xat"] [ext_resource type="PackedScene" uid="uid://p2kk0a6bpmai" path="res://Scenes/event_box.tscn" id="6_gdfin"] +[ext_resource type="Texture2D" uid="uid://w1o1bf6t5054" path="res://2D Assets/sinks/greenSink.png" id="6_l1rfj"] [ext_resource type="PackedScene" uid="uid://cg1qlr4r42xs6" path="res://Scenes/box_b.tscn" id="7_j7uju"] +[ext_resource type="Texture2D" uid="uid://bdn2dphqbqnhh" path="res://2D Assets/boxes/greenBox.png" id="9_37vjj"] [ext_resource type="Script" path="res://Scripts/event_button.gd" id="9_va8kg"] [ext_resource type="Script" path="res://Scripts/restart.gd" id="10_rwca5"] [ext_resource type="Texture2D" uid="uid://cs6prh1shv4bh" path="res://2D Assets/funnels/blueFunnel.png" id="10_w4xqm"] [ext_resource type="Script" path="res://Scripts/draggable_filter.gd" id="10_xwwl6"] [ext_resource type="Texture2D" uid="uid://bpkn0kgyf867u" path="res://2D Assets/funnels/redFunnel.png" id="11_2hn41"] +[ext_resource type="AudioStream" uid="uid://8si5vt7ptv0k" path="res://SoundEffects/sfx_click_start.mp3" id="11_vi78o"] +[ext_resource type="Texture2D" uid="uid://dreyprum5m05y" path="res://2D Assets/funnels/greenFunnel.png" id="16_ucfe2"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_e8kq8"] size = Vector2(160, 185) [node name="base" type="Node2D"] +position = Vector2(3, 1) scale = Vector2(0.6, 0.6) [node name="Panel" type="Panel" parent="."] @@ -26,7 +32,8 @@ mouse_filter = 2 layout_mode = 0 offset_right = 1920.0 offset_bottom = 1080.0 -texture = ExtResource("1_fdm6s") +scale = Vector2(1.03659, 0.994286) +texture = ExtResource("1_tf1jf") [node name="Conveyor" type="Line2D" parent="."] texture_repeat = 2 @@ -36,14 +43,104 @@ texture = ExtResource("2_ocbiy") texture_mode = 1 script = ExtResource("3_5pogt") -[node name="Sink" parent="." instance=ExtResource("4_2wh4q")] +[node name="Conveyor2" type="Line2D" parent="."] +texture_repeat = 2 +points = PackedVector2Array(0, 0, 0, 0) +width = 100.0 +texture = ExtResource("2_ocbiy") +texture_mode = 1 +script = ExtResource("3_5pogt") +conveyorIndex = 1 + +[node name="Conveyor3" type="Line2D" parent="."] +texture_repeat = 2 +points = PackedVector2Array(0, 0, 0, 0) +width = 100.0 +texture = ExtResource("2_ocbiy") +texture_mode = 1 +script = ExtResource("3_5pogt") +conveyorIndex = 1 + +[node name="Sink 1" parent="." instance=ExtResource("4_2wh4q")] +position = Vector2(301.667, 851.667) +texture = ExtResource("5_16xat") +expectedType = "Red" + +[node name="RichTextLabel" type="RichTextLabel" parent="Sink 1"] +offset_left = -135.0 +offset_top = 88.0 +offset_right = -74.0 +offset_bottom = 106.0 +scale = Vector2(5.36905, 4.76596) +text = "SINK 1" +fit_content = true +scroll_active = false + +[node name="Sink2" parent="." instance=ExtResource("4_2wh4q")] +position = Vector2(781.667, 855) expectedType = "Blue" +[node name="RichTextLabel" type="RichTextLabel" parent="Sink2"] +offset_left = -135.0 +offset_top = 88.0 +offset_right = -74.0 +offset_bottom = 106.0 +scale = Vector2(5.36905, 4.76596) +text = "SINK 2" +fit_content = true +scroll_active = false + +[node name="Sink 3" parent="." instance=ExtResource("4_2wh4q")] +position = Vector2(1266.67, 855) +texture = ExtResource("6_l1rfj") +expectedType = "Green" + +[node name="RichTextLabel" type="RichTextLabel" parent="Sink 3"] +offset_left = -135.0 +offset_top = 88.0 +offset_right = -74.0 +offset_bottom = 106.0 +scale = Vector2(5.36905, 4.76596) +text = "SINK 3" +fit_content = true +scroll_active = false + [node name="BoxA" parent="." instance=ExtResource("6_gdfin")] +position = Vector2(786.167, 120.667) [node name="BoxB" parent="." instance=ExtResource("7_j7uju")] +position = Vector2(791.167, 124) +boxType = "Blue" + +[node name="BoxC" parent="." instance=ExtResource("7_j7uju")] +position = Vector2(785, 121.667) +texture = ExtResource("9_37vjj") +boxType = "Green" + +[node name="BoxA2" parent="." instance=ExtResource("6_gdfin")] +position = Vector2(784.5, 129) + +[node name="BoxB2" parent="." instance=ExtResource("7_j7uju")] +position = Vector2(782.833, 127.333) +boxType = "Blue" + +[node name="BoxC2" parent="." instance=ExtResource("7_j7uju")] +position = Vector2(791.667, 125) +texture = ExtResource("9_37vjj") +boxType = "Green" + +[node name="BoxA3" parent="." instance=ExtResource("6_gdfin")] +position = Vector2(786.167, 120.667) + +[node name="BoxB3" parent="." instance=ExtResource("7_j7uju")] +position = Vector2(791.167, 124) boxType = "Blue" +[node name="BoxC3" parent="." instance=ExtResource("7_j7uju")] +position = Vector2(791.667, 126.667) +texture = ExtResource("9_37vjj") +boxType = "Green" + [node name="Control" type="Control" parent="."] layout_mode = 3 anchors_preset = 0 @@ -68,6 +165,10 @@ theme_override_font_sizes/normal_font_size = 50 bbcode_enabled = true text = "[center]START" +[node name="SfxClickStart" type="AudioStreamPlayer2D" parent="Control"] +position = Vector2(154.997, 58.3331) +stream = ExtResource("11_vi78o") + [node name="Control2" type="Control" parent="."] layout_mode = 3 anchors_preset = 0 @@ -92,32 +193,43 @@ theme_override_font_sizes/normal_font_size = 50 bbcode_enabled = true text = "[center]RESTART" +[node name="SfxClickStart" type="AudioStreamPlayer2D" parent="Control2"] +position = Vector2(154.997, 58.3331) +stream = ExtResource("11_vi78o") + [node name="Draggable Filter" type="Area2D" parent="."] -position = Vector2(288.333, 205) +position = Vector2(1728.33, 121.667) script = ExtResource("10_xwwl6") filterColor = "Blue" [node name="CollisionShape2D" type="CollisionShape2D" parent="Draggable Filter"] -position = Vector2(0.333374, -0.5) shape = SubResource("RectangleShape2D_e8kq8") [node name="Sprite2D" type="Sprite2D" parent="Draggable Filter"] -position = Vector2(0.333374, 0.333313) texture = ExtResource("10_w4xqm") [node name="Draggable Filter2" type="Area2D" parent="."] -position = Vector2(286.667, 431.667) +position = Vector2(1735, 335) script = ExtResource("10_xwwl6") filterColor = "Red" [node name="CollisionShape2D" type="CollisionShape2D" parent="Draggable Filter2"] -position = Vector2(0.333374, -0.5) shape = SubResource("RectangleShape2D_e8kq8") [node name="Sprite2D" type="Sprite2D" parent="Draggable Filter2"] -position = Vector2(0.333374, 0.333313) texture = ExtResource("11_2hn41") +[node name="Draggable Filter3" type="Area2D" parent="."] +position = Vector2(1736.67, 545) +script = ExtResource("10_xwwl6") +filterColor = "Green" + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Draggable Filter3"] +shape = SubResource("RectangleShape2D_e8kq8") + +[node name="Sprite2D" type="Sprite2D" parent="Draggable Filter3"] +texture = ExtResource("16_ucfe2") + [connection signal="pressed" from="Control/Button" to="Control" method="_on_button_pressed"] [connection signal="pressed" from="Control2/Button" to="Control2" method="_on_button_pressed"] [connection signal="area_entered" from="Draggable Filter" to="Draggable Filter" method="_on_area_entered"] @@ -128,3 +240,7 @@ texture = ExtResource("11_2hn41") [connection signal="body_shape_exited" from="Draggable Filter2" to="Draggable Filter2" method="_on_body_shape_exited"] [connection signal="mouse_entered" from="Draggable Filter2" to="Draggable Filter2" method="_on_mouse_entered"] [connection signal="mouse_exited" from="Draggable Filter2" to="Draggable Filter2" method="_on_mouse_exited"] +[connection signal="area_entered" from="Draggable Filter3" to="Draggable Filter3" method="_on_area_entered"] +[connection signal="body_shape_exited" from="Draggable Filter3" to="Draggable Filter3" method="_on_body_shape_exited"] +[connection signal="mouse_entered" from="Draggable Filter3" to="Draggable Filter3" method="_on_mouse_entered"] +[connection signal="mouse_exited" from="Draggable Filter3" to="Draggable Filter3" method="_on_mouse_exited"] diff --git a/Scenes/node_2d.gd b/Scenes/node_2d.gd new file mode 100644 index 0000000..e251cf8 --- /dev/null +++ b/Scenes/node_2d.gd @@ -0,0 +1 @@ +extends Node2D diff --git a/Scripts/ConveyerController.gd b/Scripts/ConveyerController.gd index 32a65a0..6de1725 100644 --- a/Scripts/ConveyerController.gd +++ b/Scripts/ConveyerController.gd @@ -2,15 +2,16 @@ extends Node2D var selected var events = [] -var destination -var conveyer +var destination = [] +var conveyer = [] +var conveyerInd = 0 var dragging var sendingEnd = false var can_send = false var started = false func setup(conveyer) -> void: - self.conveyer = conveyer + self.conveyer.append(conveyer) self.can_send = false self.sendingEnd = false self.started = false @@ -20,22 +21,33 @@ func setup(conveyer) -> void: func _ready() -> void: pass # Replace with function body. - # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta: float) -> void: if self.can_send and not self.started and self.destination != null: self.send_event() pass + func create_conveyor(): - conveyer.set_point_position(0, selected.get_position()) - conveyer.set_point_position(1, destination.get_position()) + conveyer[conveyerInd].set_point_position(0, selected.get_position()) + conveyer[conveyerInd].set_point_position(1, destination[conveyerInd]) + + conveyerInd+=1 + if(conveyerInd>conveyer.size()-1): conveyerInd = 0 + func send_event(): print("sending events!") self.started = true + var ind = 0 for n in events.size(): + if(ind==3): conveyerInd+=1 + if(ind==6): conveyerInd+=1 + if(conveyerInd>conveyer.size()-1): conveyerInd = 0 events[n].sending = true var tween = get_tree().create_tween() - tween.tween_property(events[n], "position", destination.get_position(), 2).set_trans(tween.TRANS_LINEAR) + print("event sent ", n); + tween.tween_property(events[n], "position", destination[conveyerInd], 2).set_trans(tween.TRANS_LINEAR) await tween.finished + #$SfxClickStart.play() + ind+=1 diff --git a/Scripts/SinkClick.gd b/Scripts/SinkClick.gd index 4120687..1da0618 100644 --- a/Scripts/SinkClick.gd +++ b/Scripts/SinkClick.gd @@ -8,7 +8,7 @@ func _input_event(viewport, event, shape_idx): func on_click(): print("hey") - ConveyerController.destination = get_parent() + ConveyerController.destination.append(get_parent().get_position()) transfer_box() func transfer_box(): @@ -21,6 +21,7 @@ func _on_body_entered(node: Node2D) -> void: func _on_area_entered(area: Area2D) -> void: print("area entered") + #$SfxClickStart.play() #if area.is_in_group("Box"): #if area.get_parent().boxType != filterColor and area.get_parent().sending == true: #print("kill it") diff --git a/Scripts/conveyor.gd b/Scripts/conveyor.gd index 217557e..e50bd65 100644 --- a/Scripts/conveyor.gd +++ b/Scripts/conveyor.gd @@ -1,8 +1,8 @@ extends Line2D - +@export var conveyorIndex: int # Called when the node enters the scene tree for the first time. func _ready() -> void: - print("conveyor ready") + print("conveyor ready", conveyorIndex) ConveyerController.setup(self) diff --git a/Scripts/draggable_filter.gd b/Scripts/draggable_filter.gd index 5bd0f6f..e8a718b 100644 --- a/Scripts/draggable_filter.gd +++ b/Scripts/draggable_filter.gd @@ -6,9 +6,21 @@ var bodyref # Called when the node enters the scene tree for the first time. func _ready() -> void: - pass # Replace with function body. - - + pass + +#func _input_event(viewport, event, shape_idx): + #if event.is_pressed() and ConveyerController.selected != null: + #self.on_click() +# +#func on_click(): + #print("hey filter") + #ConveyerController.destination = position + #transfer_box() +# +#func transfer_box(): + #print("sending") + #ConveyerController.create_conveyor() + # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta: float) -> void: if draggable: @@ -32,8 +44,10 @@ func _on_mouse_exited() -> void: scale = Vector2(1, 1) +var events = [] func _on_area_entered(area: Area2D) -> void: if area.is_in_group("Box"): + events.append(area.get_parent()) if area.get_parent().boxType != filterColor and area.get_parent().sending == true: print("kill it") area.get_parent().queue_free() diff --git a/Scripts/event_button.gd b/Scripts/event_button.gd index e9fd197..e36e2e5 100644 --- a/Scripts/event_button.gd +++ b/Scripts/event_button.gd @@ -1,6 +1,5 @@ extends Control - # Called when the node enters the scene tree for the first time. func _ready() -> void: pass # Replace with function body. @@ -12,4 +11,6 @@ func _process(delta: float) -> void: func _on_button_pressed() -> void: + print("Start Button Pressed") + $SfxClickStart.play() ConveyerController.can_send = true diff --git a/Scripts/restart.gd b/Scripts/restart.gd index f30f74e..1413d02 100644 --- a/Scripts/restart.gd +++ b/Scripts/restart.gd @@ -12,4 +12,5 @@ func _process(delta: float) -> void: func _on_button_pressed() -> void: print("restart clicked") + $SfxClickStart.play() get_tree().reload_current_scene() diff --git a/Scripts/sink.gd b/Scripts/sink.gd index 4939319..7a085e8 100644 --- a/Scripts/sink.gd +++ b/Scripts/sink.gd @@ -1,12 +1,12 @@ extends Sprite2D @export var expectedType: String - +#@export var sinkIndex: int # Called when the node enters the scene tree for the first time. func _ready() -> void: pass # Replace with function body. - + #ConveyerController.conveyer.append(self) # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta: float) -> void: diff --git a/SoundEffects/music.mp3.import b/SoundEffects/music.mp3.import new file mode 100644 index 0000000..03ef3a4 --- /dev/null +++ b/SoundEffects/music.mp3.import @@ -0,0 +1,19 @@ +[remap] + +importer="mp3" +type="AudioStreamMP3" +uid="uid://h4fgt6foxbje" +path="res://.godot/imported/music.mp3-46a78da060ffb05d4d66e1145443a004.mp3str" + +[deps] + +source_file="res://SoundEffects/music.mp3" +dest_files=["res://.godot/imported/music.mp3-46a78da060ffb05d4d66e1145443a004.mp3str"] + +[params] + +loop=false +loop_offset=0 +bpm=0 +beat_count=0 +bar_beats=4 diff --git a/SoundEffects/sfx_click_start.mp3 b/SoundEffects/sfx_click_start.mp3 new file mode 100644 index 0000000..0e33689 Binary files /dev/null and b/SoundEffects/sfx_click_start.mp3 differ diff --git a/SoundEffects/sfx_click_start.mp3.import b/SoundEffects/sfx_click_start.mp3.import new file mode 100644 index 0000000..c6ae87f --- /dev/null +++ b/SoundEffects/sfx_click_start.mp3.import @@ -0,0 +1,19 @@ +[remap] + +importer="mp3" +type="AudioStreamMP3" +uid="uid://8si5vt7ptv0k" +path="res://.godot/imported/sfx_click_start.mp3-36ae1c77cf86f28bc45914035b055940.mp3str" + +[deps] + +source_file="res://SoundEffects/sfx_click_start.mp3" +dest_files=["res://.godot/imported/sfx_click_start.mp3-36ae1c77cf86f28bc45914035b055940.mp3str"] + +[params] + +loop=false +loop_offset=0 +bpm=0 +beat_count=0 +bar_beats=4