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
10 changes: 10 additions & 0 deletions .gdlintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
max-line-length: 120
disable:
- class-variable-name
- function-variable-name
- function-argument-name
- unused-argument
- load-constant-name
- class-definitions-order
- unnecessary-pass
- expression-not-assigned
13 changes: 13 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
repos:
- repo: https://github.com/Scony/godot-gdscript-toolkit
rev: 4.2.2
hooks:
# 1. gdformat: Automatically fixes spacing, indentation, and line breaks
- id: gdformat
files: \.gd$
additional_dependencies: [setuptools]

# 2. gdlint: Checks for naming conventions and unused variables
- id: gdlint
files: \.gd$
additional_dependencies: [setuptools]
21 changes: 14 additions & 7 deletions Scripts/ConveyerController.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ var selected
var events = []
var destination = []
var conveyer = []
var conveyerInd=0
var conveyerInd = 0
var dragging
var sendingEnd = false
var can_send = false
var started = false


func initialise():
self.selected
self.events = []
Expand All @@ -21,16 +22,18 @@ func initialise():
self.can_send = false
self.started = false


func setup(conveyer) -> void:
self.conveyer.append(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.
pass # Replace with function body.


# Called every frame. 'delta' is the elapsed time since the previous frame.
Expand All @@ -39,19 +42,23 @@ func _process(delta: float) -> void:
self.send_event()
pass


func create_conveyor():
conveyer[conveyerInd].set_point_position(0, selected.get_position())
conveyer[conveyerInd].set_point_position(1, destination[conveyerInd])
conveyerInd+=1

conveyerInd += 1


func send_event():
print("sending events!")
self.started = true
if conveyerInd!=0:
if conveyerInd != 0:
for n in events.size():
events[n].sending = true
var tween = get_tree().create_tween()
tween.tween_property(events[n], "position", destination[n%conveyerInd], 2).set_trans(tween.TRANS_LINEAR)
if n%conveyerInd==conveyerInd-1:
tween.tween_property(events[n], "position", destination[n % conveyerInd], 2).set_trans(
tween.TRANS_LINEAR
)
if n % conveyerInd == conveyerInd - 1:
await tween.finished
Level.next_level()
10 changes: 8 additions & 2 deletions Scripts/SinkClick.gd
Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@
extends Area2D


# Called when the node enters the scene tree for the first time.
func _input_event(viewport, event, shape_idx):
if event.is_pressed() and ConveyerController.selected != null:
self.on_click()


func on_click():
print("hey")
ConveyerController.destination.append(get_parent().get_position())
transfer_box()


func transfer_box():
print("sending")
ConveyerController.create_conveyor()
#draw_line(ConveyerController.selected.get_global_position(), get_global_position(), Color.GREEN)


func _on_body_entered(node: Node2D) -> void:
print("body entered")


func _on_area_entered(area: Area2D) -> void:
print("area entered")
if area.is_in_group("Box"):
Level.sinkUsed=true
Level.sinkUsed = true
print(get_parent().expectedType)
if area.get_parent().boxType != get_parent().expectedType:
print("Not Expected Box")
Level.sinkBoxMatchPresent=false
Level.sinkBoxMatchPresent = false
14 changes: 8 additions & 6 deletions Scripts/both_blockage.gd
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
extends Node2D

var consumed
var consumed


# Called when the node enters the scene tree for the first time.
func _ready():
consumed = false# Replace with function body.
consumed = false # Replace with function body.


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass



func _on_input_event(viewport: Node, event: InputEvent, shape_idx: int) -> void:
if event is InputEventMouseButton and event.pressed and event.button_index == 1:
print("clicked on right blockage")



func _on_area_2d_area_entered(area):
if( consumed == false):
$AnimationPlayer.play("crush")
if consumed == false:
$AnimationPlayer.play("crush")
consumed = true
# Replace with function body.
5 changes: 3 additions & 2 deletions Scripts/broker.gd
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
extends Sprite2D


const event_script = preload("res://Scripts/event_box.gd")


# Called when the node enters the scene tree for the first time.
func _ready() -> void:
create_event("")
pass # Replace with function body.
pass # Replace with function body.


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass


func create_event(color: String) -> void:
var event = Sprite2D.new()
event.texture = load("res://2D Assets/boxes/redBox.png")
Expand Down
1 change: 0 additions & 1 deletion Scripts/conveyor.gd
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ extends Line2D
func _ready() -> void:
print("conveyor ready")
ConveyerController.setup(self)

47 changes: 27 additions & 20 deletions Scripts/dlqPattern.gd
Original file line number Diff line number Diff line change
@@ -1,56 +1,63 @@
extends Node2D
@onready var DLS=$dls
@onready var blockagepoint= $Blockage
@onready var DLS = $dls
@onready var blockagepoint = $Blockage
var dlsclicked = false


func _ready() -> void:
ConveyerController.can_send = false
ConveyerController.can_send = false
pass



func _process(delta: float) -> void:
pass



func _on_blockage_left_area_entered(area: Area2D) -> void:
pass


#when DLS is clicked
func _on_dls_input_event(viewport: Node, event: InputEvent, shape_idx: int) -> void:


if event is InputEventMouseButton and event.pressed and event.button_index == 1:
dlsclicked=true
dlsclicked = true
#ConveyerController.conveyerInd+=1
var dlqTrigger=$dlsconveyor
dlqTrigger.set_point_position(0, Vector2(529,250))
dlqTrigger.set_point_position(1, DLS.position+Vector2(80,0))
var dlqTrigger = $dlsconveyor
dlqTrigger.set_point_position(0, Vector2(529, 250))
dlqTrigger.set_point_position(1, DLS.position + Vector2(80, 0))


func _on_dls_area_entered(area: Area2D) -> void:
if area.is_in_group("Box"):
print("box in DLS")
Level.dlsUsed = true


#when event get in the blockage area
func _on_area_2d_area_entered(area):
ConveyerController.can_send=false
ConveyerController.can_send = false
var blockedEvents = ConveyerController.events.duplicate()
if dlsclicked:

for event in blockedEvents:
if event == null or not event.is_inside_tree():
continue # skip already deleted or invalid nodes
event.sending = true

event.sending = true
var tween = get_tree().create_tween()
tween.tween_property(event, "position", DLS.position+Vector2(80,0), 2).set_trans(Tween.TRANS_LINEAR)
tween.tween_property(event, "position", DLS.position + Vector2(80, 0), 2).set_trans(
Tween.TRANS_LINEAR
)
await tween.finished
else:
for event in blockedEvents:
if event == null or not event.is_inside_tree():
continue # skip already deleted or invalid nodes
event.sending = true

event.sending = true
var tween = get_tree().create_tween()
tween.tween_property(event, "position", blockagepoint.position, 2).set_trans(Tween.TRANS_LINEAR)
tween.tween_property(event, "position", blockagepoint.position, 2).set_trans(
Tween.TRANS_LINEAR
)
await tween.finished

# Replace with function body.
# Replace with function body.
4 changes: 3 additions & 1 deletion Scripts/draggable_filter.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ var draggable = false
var bodyref
@export var filterColor: String


# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
pass # Replace with function body.


# Called every frame. 'delta' is the elapsed time since the previous frame.
Expand All @@ -20,6 +21,7 @@ func _process(delta: float) -> void:
ConveyerController.dragging = false
global_position = get_global_mouse_position()


func _on_mouse_entered() -> void:
if not ConveyerController.dragging:
draggable = true
Expand Down
5 changes: 4 additions & 1 deletion Scripts/event_box.gd
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@ extends Sprite2D
@export var boxType: String
@export var sending = false


func _ready() -> void:
print("event ready")
print("event is color", boxType)
ConveyerController.events.append(self)


func _input_event(viewport, event, shape_idx) -> void:
print(event)
if event.is_pressed():
self.on_click()



func on_click():
print("hi")
ConveyerController.selected = self
2 changes: 2 additions & 0 deletions Scripts/event_box_clickable.gd
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
extends Area2D


func _ready() -> void:
pass


func _input_event(viewport, event, shape_idx) -> void:
if event.is_pressed():
get_parent().on_click()
2 changes: 1 addition & 1 deletion Scripts/event_button.gd
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ extends Control

# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
pass # Replace with function body.


# Called every frame. 'delta' is the elapsed time since the previous frame.
Expand Down
46 changes: 24 additions & 22 deletions Scripts/level.gd
Original file line number Diff line number Diff line change
@@ -1,44 +1,46 @@
extends Node
var sinkBoxMatchNeeded=[false,true,true,false]
var sinkBoxMatchNeeded = [false, true, true, false]
var sinkBoxMatchPresent
var sinkUsed
var dlsRequired=[false,false,false,true]
var dlsRequired = [false, false, false, true]
var dlsUsed
var totalbox=[2,2,3]
var totalbox = [2, 2, 3]
var nextLevel
var levels=["basicEventFlow","boxClick","multiSink","dlqPattern"]
var levelind=0
var levels = ["basicEventFlow", "boxClick", "multiSink", "dlqPattern"]
var levelind = 0


func initialise():
sinkBoxMatchPresent=true
sinkUsed=false
totalbox=0
nextLevel=false
dlsUsed=false
sinkBoxMatchPresent = true
sinkUsed = false
totalbox = 0
nextLevel = false
dlsUsed = false


func next_level():
func next_level():
if sinkUsed:
if not sinkBoxMatchNeeded[levelind] and not dlsRequired[levelind]:
print("if next level entered",sinkBoxMatchNeeded,dlsRequired)
nextLevel=true
print("if next level entered", sinkBoxMatchNeeded, dlsRequired)
nextLevel = true
elif sinkBoxMatchNeeded[levelind] and sinkBoxMatchPresent:
print("elif next level entered",sinkBoxMatchNeeded,sinkBoxMatchPresent)
nextLevel=true
print("elif next level entered", sinkBoxMatchNeeded, sinkBoxMatchPresent)
nextLevel = true
elif dlsRequired[levelind] and dlsUsed:
print("elif dls",dlsUsed)
nextLevel=true
print("elif dls", dlsUsed)
nextLevel = true

var message_display = preload("res://Scenes/message_display.tscn").instantiate()
add_child(message_display)
message_display.z_index = 999
message_display.z_index = 999
if nextLevel:
print("success")
message_display.show_message("Success")
await message_display.show_message_for_duration(2.0)
message_display.visible = false
levelind+=1
if levelind!=levels.size():
var next_level_path="res://Scenes/"+levels[levelind]+".tscn"
levelind += 1
if levelind != levels.size():
var next_level_path = "res://Scenes/" + levels[levelind] + ".tscn"
get_tree().change_scene_to_file(next_level_path)
ConveyerController.initialise()
else:
Expand Down
Loading