diff --git a/Nodes/cannon.tscn b/Nodes/cannon.tscn index 6782155..1771df1 100644 --- a/Nodes/cannon.tscn +++ b/Nodes/cannon.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=2 format=3 uid="uid://kupfq75m0v37"] +[gd_scene load_steps=2 format=3 uid="uid://byo1m0n20yl45"] [ext_resource type="Script" path="res://scripts/Modules/Cannon.gd" id="1_vdn0s"] diff --git a/Nodes/game.tscn b/Nodes/game.tscn index 7c530eb..6b577f6 100644 --- a/Nodes/game.tscn +++ b/Nodes/game.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=5 format=3 uid="uid://bl1yrgr7g06db"] +[gd_scene load_steps=5 format=3 uid="uid://n7w0ff7u25yc"] [ext_resource type="Script" path="res://scripts/Logic/Game.gd" id="1_iox18"] diff --git a/project.godot b/project.godot index 6943375..0e16438 100644 --- a/project.godot +++ b/project.godot @@ -41,3 +41,11 @@ _global_script_class_icons={ config/name="Semester Game Jam 2022" config/features=PackedStringArray("4.0", "Forward Plus") config/icon="res://icon.svg" + +[input] + +test={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":70,"unicode":0,"echo":false,"script":null) +] +} diff --git a/scripts/Logic/Game.gd b/scripts/Logic/Game.gd index 24c4ef4..76cdbfe 100644 --- a/scripts/Logic/Game.gd +++ b/scripts/Logic/Game.gd @@ -5,21 +5,33 @@ signal ammo_pickup signal shoot var t = 0.0 -@onready var tween = create_tween() as Tween -@export var p1 : PathFollow3D -@export var p2 : PathFollow3D +@onready var tween = create_tween() as Tween + +@onready var p1 = $Player1Path/PathFollow3D +@onready var p2 = $Player2Path/PathFollow3D + +var speed_p1 = 10 +var speed_p2 = 10 func _ready(): start_tween() func start_tween(): + tween.stop() + tween = create_tween() + tween.set_parallel() tween.set_trans(Tween.TRANS_LINEAR) - tween.set_parallel(true) - tween.tween_property(p1, "progress_ratio", 1, 20) - tween.tween_property(p2, "progress_ratio", -1, 20) + tween.tween_property(p1, "progress_ratio", 1, speed_p1) + tween.tween_property(p2, "progress_ratio", -1, speed_p2) + + func _process(delta): + if Input.is_action_pressed("test"): + speed_p1 = 5 + start_tween() + if round(p1.position.distance_to(p2.position)) == 9: emit_signal("shoot") diff --git a/scripts/Modules/Cannon.gd b/scripts/Modules/Cannon.gd index 0cdf903..83e5b63 100644 --- a/scripts/Modules/Cannon.gd +++ b/scripts/Modules/Cannon.gd @@ -4,6 +4,8 @@ class_name Cannon enum STATE {INACTIVE, RELOADING, SHOOTING} +var CAN_ENGAGE = true + #------------Methods-------------# func _ready(): var root = get_tree().root.get_child(0) @@ -23,10 +25,14 @@ func interact(): return func _on_signal_shooting(): - print("hit") + if not CAN_ENGAGE: + return + CAN_ENGAGE = false + create_tween().tween_callback(func(): CAN_ENGAGE = true).set_delay(2) + if currentStashValue >= 1 and currentState == STATE.INACTIVE: currentState = STATE.SHOOTING currentStashValue -= 1 - #TODO: SHOOTING + print("hit") currentState = STATE.INACTIVE return diff --git a/scripts/Modules/Storage.gd b/scripts/Modules/Storage.gd index 54f8ac7..baf1804 100644 --- a/scripts/Modules/Storage.gd +++ b/scripts/Modules/Storage.gd @@ -14,10 +14,10 @@ func _ready(): currentStashValue = 0 func interact(): if currentStashValue >= 1: - --currentStashValue + currentStashValue -= 1 return func _on_signal_storing(): if currentStashValue < maxStashValue: - ++currentStashValue + currentStashValue += 1 return