Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added 2D Assets/KNATIVE.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions 2D Assets/KNATIVE.png.import
Original file line number Diff line number Diff line change
@@ -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
Binary file removed 2D Assets/background.png
Binary file not shown.
42 changes: 42 additions & 0 deletions ConveyerFilter.gd
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

<a href="https://youtu.be/TGGZJkpd9BY?si=goof7Bxukn1Ua_AM">
<img src="https://i.ytimg.com/an_webp/TGGZJkpd9BY/mqdefault_6s.webp?du=3000&sqp=CK79vb0G&rs=AOn4CLDPQJgBcXiwPIWef8jQcfigv-d2tg" width="800" alt="Watch the video">
</a>


## 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.
136 changes: 126 additions & 10 deletions Scenes/boxClick.tscn
Original file line number Diff line number Diff line change
@@ -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="."]
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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"]
Expand All @@ -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"]
1 change: 1 addition & 0 deletions Scenes/node_2d.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extends Node2D
26 changes: 19 additions & 7 deletions Scripts/ConveyerController.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
3 changes: 2 additions & 1 deletion Scripts/SinkClick.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand All @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions Scripts/conveyor.gd
Original file line number Diff line number Diff line change
@@ -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)

Loading