diff --git a/Module.tscn b/Module.tscn index ac2c192..fb3efd7 100644 --- a/Module.tscn +++ b/Module.tscn @@ -1,6 +1,3 @@ -[gd_scene load_steps=2 format=3 uid="uid://b87b68ghm4dkk"] +[gd_scene load_steps=2 format=3] -[ext_resource type="Script" path="res://Module.gd" id="1_42v8k"] - -[node name="Node" type="Node"] -script = ExtResource("1_42v8k") +[ext_resource type="Script" path="res://scripts/Modules/Module.gd" id="1_42v8k"] diff --git a/Nodes/cannon.tscn b/Nodes/cannon.tscn new file mode 100644 index 0000000..6782155 --- /dev/null +++ b/Nodes/cannon.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://kupfq75m0v37"] + +[ext_resource type="Script" path="res://scripts/Modules/Cannon.gd" id="1_vdn0s"] + +[node name="Cannon" type="Node"] +script = ExtResource("1_vdn0s") diff --git a/Nodes/game.tscn b/Nodes/game.tscn new file mode 100644 index 0000000..8bf6463 --- /dev/null +++ b/Nodes/game.tscn @@ -0,0 +1,53 @@ +[gd_scene load_steps=5 format=3 uid="uid://bl1yrgr7g06db"] + +[ext_resource type="Script" path="res://scripts/Logic/Game.gd" id="1_iox18"] + +[sub_resource type="Curve3D" id="Curve3D_42kdk"] +_data = { +"points": PackedVector3Array(-8, 0, 0, 8, 0, 0, 0, 0, -8, -16, 0, 0, 16, 0, 0, 72, 0, -16, 0, 0, -16, 0, 0, 16, 88, 0, 0, 16, 0, 0, -16, 0, 0, 72, 0, 16, 0, 0, 16, 0, 0, -16, 56, 0, 0, -16, 0, 0, 16, 0, 0, 72, 0, -16, 0, 0, -16, 0, 0, 16, 88, 0, 0, 16, 0, 0, -16, 0, 0, 72, 0, 16, 8, 0, 0, -8, 0, 0, 0, 0, 8, 0, 0, 8, 0, 0, -8, -8, 0, 0, -8, 0, 0, 8, 0, 0, 0, 0, -8, 0, 0, -8, 0, 0, 8, 8, 0, 0, 8, 0, 0, -8, 0, 0, 0, 0, 8, 0, 0, 8, 0, 0, -8, -8, 0, 0, -8, 0, 0, 8, 0, 0, 0, 0, -8), +"tilts": PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) +} +point_count = 15 + +[sub_resource type="BoxMesh" id="BoxMesh_3vwcb"] +size = Vector3(1, 1, 2) + +[sub_resource type="Curve3D" id="Curve3D_ycdkn"] +_data = { +"points": PackedVector3Array(-16, 0, 0, 16, 0, 0, 0, 0, -16, 0, 0, -16, 0, 0, 16, 16, 0, 0, 16, 0, 0, -16, 0, 0, 0, 0, 16, 0, 0, 16, 0, 0, -16, -15.9109, 0.0032196, 0.0159729, -16, 0, 0, 16, 0, 0, 0, 0, -16, -8, 0, 0, 8, 0, 0, 72, 0, -8, 0, 0, -8, 0, 0, 8, 80, 0, 0, 8, 0, 0, -8, 0, 0, 72, 0, 8, 0, 0, 8, 0, 0, -8, 64, 0, 0, -8, 0, 0, 8, 0, 0, 72, 0, -8, 0, 0, -8, 0, 0, 8, 80, 0, 0, 8, 0, 0, -8, 0, 0, 72, 0, 8, 16, 0, 0, -16, 0, 0, 0, 0, 16, 0, 0, 16, 0, 0, -16, -16, 0, 0, -16, 0, 0, 16, 0, 0, 0, 0, -16), +"tilts": PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) +} +point_count = 15 + +[node name="Game" type="Node"] +script = ExtResource("1_iox18") + +[node name="Camera3D" type="Camera3D" parent="."] +transform = Transform3D(1, 1.77636e-14, 7.76471e-22, 0, -4.37114e-08, 1, 1.77636e-14, -1, -4.37114e-08, 36.5305, 43.522, 0.295507) + +[node name="Player1Path" type="Path3D" parent="."] +curve = SubResource("Curve3D_42kdk") + +[node name="PathFollow3D" type="PathFollow3D" parent="Player1Path"] +transform = Transform3D(-4.37107e-08, 0, 0.999984, 0, 1, 0, -0.999984, 0, -4.37107e-08, 0, 0, -8) + +[node name="root" type="Node3D" parent="Player1Path/PathFollow3D"] + +[node name="Zug1" type="MeshInstance3D" parent="Player1Path/PathFollow3D/root"] +transform = Transform3D(1, 0, -7.10543e-15, 0, 1, 0, 7.10543e-15, 0, 1, 0, 0, 0) +mesh = SubResource("BoxMesh_3vwcb") +skeleton = NodePath("../..") + +[node name="Player2Path" type="Path3D" parent="."] +curve = SubResource("Curve3D_ycdkn") + +[node name="PathFollow3D" type="PathFollow3D" parent="Player2Path"] +transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, 0, -16) + +[node name="root" type="Node3D" parent="Player2Path/PathFollow3D"] +transform = Transform3D(-0.0154456, -6.75146e-10, -0.999881, -5.21344e-12, 1, -6.75146e-10, 0.999881, -5.21341e-12, -0.0154456, 0, 0, 0) + +[node name="Zug1" type="MeshInstance3D" parent="Player2Path/PathFollow3D/root"] +transform = Transform3D(1, 0, -7.10543e-15, 0, 1, 0, 7.10543e-15, 0, 1, 0, 0, 0) +mesh = SubResource("BoxMesh_3vwcb") +skeleton = NodePath("../..") diff --git a/cannon.tscn b/cannon.tscn deleted file mode 100644 index 4c528ea..0000000 --- a/cannon.tscn +++ /dev/null @@ -1,6 +0,0 @@ -[gd_scene load_steps=2 format=3 uid="uid://d2g0of2prwwj4"] - -[ext_resource type="Script" path="res://Cannon.gd" id="1_mopo1"] - -[node name="Cannon" type="Node"] -script = ExtResource("1_mopo1") diff --git a/project.godot b/project.godot index 401df3a..6943375 100644 --- a/project.godot +++ b/project.godot @@ -12,22 +12,22 @@ _global_script_classes=[{ "base": "Module", "class": &"Cannon", "language": &"GDScript", -"path": "res://Cannon.gd" +"path": "res://scripts/Modules/Cannon.gd" }, { "base": "Node", "class": &"Module", "language": &"GDScript", -"path": "res://Module.gd" +"path": "res://scripts/Modules/Module.gd" }, { "base": "Module", "class": &"Storage", "language": &"GDScript", -"path": "res://Storage.gd" +"path": "res://scripts/Modules/Storage.gd" }, { "base": "Module", "class": &"TrainEngine", "language": &"GDScript", -"path": "res://Engine.gd" +"path": "res://scripts/Modules/Engine.gd" }] _global_script_class_icons={ "Cannon": "", diff --git a/scripts/Logic/Game.gd b/scripts/Logic/Game.gd new file mode 100644 index 0000000..c5fb60f --- /dev/null +++ b/scripts/Logic/Game.gd @@ -0,0 +1,27 @@ +extends Node + +#Signals +signal ammo_pickup +signal shoot + +var t = 0.0 +@onready var tween = create_tween() as Tween +@onready var p1 = $Player1Path/PathFollow3D +@onready var p2 = $Player2Path/PathFollow3D + + +func _ready(): + start_tween() + +func start_tween(): + tween.set_trans(Tween.TRANS_LINEAR) + tween.set_parallel(true) + tween.tween_property(p1, "progress_ratio", 1, 5) + tween.tween_property(p2, "progress_ratio", -1, 5) + +func _process(delta): + if round(p1.position.distance_to(p2.position)) == 9: + emit_signal("shoot") + + + diff --git a/Cannon.gd b/scripts/Modules/Cannon.gd similarity index 92% rename from Cannon.gd rename to scripts/Modules/Cannon.gd index e392237..0cdf903 100644 --- a/Cannon.gd +++ b/scripts/Modules/Cannon.gd @@ -7,7 +7,7 @@ enum STATE {INACTIVE, RELOADING, SHOOTING} #------------Methods-------------# func _ready(): var root = get_tree().root.get_child(0) - root.shooting.connect(_on_signal_shooting) + root.shoot.connect(_on_signal_shooting) maxStashValue = 1 currentStashValue = 0 currentState = STATE.INACTIVE @@ -23,6 +23,7 @@ func interact(): return func _on_signal_shooting(): + print("hit") if currentStashValue >= 1 and currentState == STATE.INACTIVE: currentState = STATE.SHOOTING currentStashValue -= 1 diff --git a/Engine.gd b/scripts/Modules/Engine.gd similarity index 100% rename from Engine.gd rename to scripts/Modules/Engine.gd diff --git a/Module.gd b/scripts/Modules/Module.gd similarity index 100% rename from Module.gd rename to scripts/Modules/Module.gd diff --git a/Storage.gd b/scripts/Modules/Storage.gd similarity index 100% rename from Storage.gd rename to scripts/Modules/Storage.gd