From 2fb20600e28c73451711f0d82f0e5520edfbf820 Mon Sep 17 00:00:00 2001 From: Lukas Moungos Date: Sat, 10 Dec 2022 09:38:18 +0100 Subject: [PATCH] delete gitignore files --- .gitignore | 22 ++++++ Backround.gd | 26 ++++++ LICENSE | 21 +++++ Module.tscn | 3 + Nodes/Player.tscn | 28 +++++++ Nodes/StartNode.tscn | 73 +++++++++++++++++ Nodes/StraightMapNode.tscn | 6 ++ Nodes/TurnMapNode.tscn | 6 ++ Nodes/cannon.tscn | 6 ++ Nodes/game.tscn | 64 +++++++++++++++ Storage.tscn | 7 ++ background.tscn | 6 ++ background_straight.tscn | 8 ++ icon.svg | 1 + icon.svg.import | 39 +++++++++ menu/MainMenu.gd | 26 ++++++ menu/VBoxContainer.gd | 17 ++++ menu/VolSlider.gd | 21 +++++ menu/VolumeSlider.gd | 20 +++++ menu/credits_screen.tscn | 36 +++++++++ menu/main_menu.tscn | 66 ++++++++++++++++ project.godot | 132 +++++++++++++++++++++++++++++++ scripts/Logic/Game.gd | 69 ++++++++++++++++ scripts/Logic/MapNode.gd | 14 ++++ scripts/Logic/StraightMapNode.gd | 9 +++ scripts/Logic/TurnMapNode.gd | 21 +++++ scripts/Modules/Cannon.gd | 38 +++++++++ scripts/Modules/Engine.gd | 25 ++++++ scripts/Modules/Module.gd | 47 +++++++++++ scripts/Modules/Storage.gd | 25 ++++++ scripts/Player.gd | 59 ++++++++++++++ scripts/Train.gd | 33 ++++++++ 32 files changed, 974 insertions(+) create mode 100644 .gitignore create mode 100644 Backround.gd create mode 100644 LICENSE create mode 100644 Module.tscn create mode 100644 Nodes/Player.tscn create mode 100644 Nodes/StartNode.tscn create mode 100644 Nodes/StraightMapNode.tscn create mode 100644 Nodes/TurnMapNode.tscn create mode 100644 Nodes/cannon.tscn create mode 100644 Nodes/game.tscn create mode 100644 Storage.tscn create mode 100644 background.tscn create mode 100644 background_straight.tscn create mode 100644 icon.svg create mode 100644 icon.svg.import create mode 100644 menu/MainMenu.gd create mode 100644 menu/VBoxContainer.gd create mode 100644 menu/VolSlider.gd create mode 100644 menu/VolumeSlider.gd create mode 100644 menu/credits_screen.tscn create mode 100644 menu/main_menu.tscn create mode 100644 project.godot create mode 100644 scripts/Logic/Game.gd create mode 100644 scripts/Logic/MapNode.gd create mode 100644 scripts/Logic/StraightMapNode.gd create mode 100644 scripts/Logic/TurnMapNode.gd create mode 100644 scripts/Modules/Cannon.gd create mode 100644 scripts/Modules/Engine.gd create mode 100644 scripts/Modules/Module.gd create mode 100644 scripts/Modules/Storage.gd create mode 100644 scripts/Player.gd create mode 100644 scripts/Train.gd diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2b039c2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,22 @@ +# Godot 4+ specific ignores +.godot/ + +# Godot-specific ignores +.import/ +export.cfg +export_presets.cfg +# Dummy HTML5 export presets file for continuous integration +!.github/dist/export_presets.cfg + +# Imported translations (automatically generated from CSV files) +*.translation + +# Mono-specific ignores +.mono/ +data_*/ +mono_crash.*.json + +# System/tool-specific ignores +.directory +.DS_Store +*~ diff --git a/Backround.gd b/Backround.gd new file mode 100644 index 0000000..32b6855 --- /dev/null +++ b/Backround.gd @@ -0,0 +1,26 @@ +extends Node + + +const pre_background_straight = preload("res://background_straight.tscn") +const pre_background_left = preload("res://Backround.gd") +const pre_background_right = preload("res://Backround.gd") + +var background_straight +var background_left +var background_right + +var level + + +func _ready(): + level = get_node("game") + background_straight = pre_background_straight.instance() + background_left = pre_background_left.instance() + background_right = pre_background_right.instance() + add_straight() + + + +func add_straight(): + var single_straight = background_straight.get_child("straight").dublicate() + level.add_child(single_straight) diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..a7ffde2 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 Nathan Hoad + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/Module.tscn b/Module.tscn new file mode 100644 index 0000000..fb3efd7 --- /dev/null +++ b/Module.tscn @@ -0,0 +1,3 @@ +[gd_scene load_steps=2 format=3] + +[ext_resource type="Script" path="res://scripts/Modules/Module.gd" id="1_42v8k"] diff --git a/Nodes/Player.tscn b/Nodes/Player.tscn new file mode 100644 index 0000000..c55ae0e --- /dev/null +++ b/Nodes/Player.tscn @@ -0,0 +1,28 @@ +[gd_scene load_steps=5 format=3 uid="uid://vwjd5od63jgh"] + +[ext_resource type="Script" path="res://scripts/Player.gd" id="1_dta8q"] +[ext_resource type="Texture2D" uid="uid://cy6x8d3xe8lux" path="res://icon.svg" id="2_yjfj7"] + +[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_p76ml"] +radius = 0.500599 +height = 1.99403 + +[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_ndwdl"] +radius = 0.567567 + +[node name="CharacterBody3D" type="CharacterBody3D"] +script = ExtResource("1_dta8q") + +[node name="CollisionShape3D" type="CollisionShape3D" parent="."] +visible = false +shape = SubResource("CapsuleShape3D_p76ml") + +[node name="Sprite3D" type="Sprite3D" parent="."] +transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 2, 0) +texture = ExtResource("2_yjfj7") + +[node name="HitBox" type="Area3D" parent="."] +collision_mask = 5 + +[node name="CollisionShape3D" type="CollisionShape3D" parent="HitBox"] +shape = SubResource("CapsuleShape3D_ndwdl") diff --git a/Nodes/StartNode.tscn b/Nodes/StartNode.tscn new file mode 100644 index 0000000..515c90c --- /dev/null +++ b/Nodes/StartNode.tscn @@ -0,0 +1,73 @@ +[gd_scene load_steps=4 format=3 uid="uid://bqe8ucbruto1j"] + +[ext_resource type="Script" path="res://scripts/Logic/StraightMapNode.gd" id="1_a5pbl"] +[ext_resource type="PackedScene" uid="uid://bup2ps8l2ifj8" path="res://Nodes/StraightMapNode.tscn" id="2_wj4hp"] +[ext_resource type="PackedScene" uid="uid://c3ynfb5ky5p8g" path="res://Nodes/TurnMapNode.tscn" id="3_xy8vi"] + +[node name="StartNode" type="Node" node_paths=PackedStringArray("next")] +script = ExtResource("1_a5pbl") +next = NodePath("StraightMapNode") + +[node name="StraightMapNode" parent="." node_paths=PackedStringArray("next") instance=ExtResource("2_wj4hp")] +next = NodePath("../StraightMapNode2") + +[node name="StraightMapNode2" parent="." node_paths=PackedStringArray("next") instance=ExtResource("2_wj4hp")] +next = NodePath("../TurnMapNode") + +[node name="TurnMapNode" parent="." node_paths=PackedStringArray("turn_node", "next") instance=ExtResource("3_xy8vi")] +turn_node = NodePath("StraightMapNode") +next = NodePath("../StraightMapNode3") + +[node name="StraightMapNode" parent="TurnMapNode" node_paths=PackedStringArray("next") instance=ExtResource("2_wj4hp")] +next = NodePath("../StraightMapNode2") + +[node name="StraightMapNode2" parent="TurnMapNode" node_paths=PackedStringArray("next") instance=ExtResource("2_wj4hp")] +next = NodePath("../StraightMapNode3") + +[node name="StraightMapNode3" parent="TurnMapNode" node_paths=PackedStringArray("next") instance=ExtResource("2_wj4hp")] +next = NodePath("../StraightMapNode4") + +[node name="StraightMapNode4" parent="TurnMapNode" node_paths=PackedStringArray("next") instance=ExtResource("2_wj4hp")] +next = NodePath("../StraightMapNode5") + +[node name="StraightMapNode5" parent="TurnMapNode" node_paths=PackedStringArray("next") instance=ExtResource("2_wj4hp")] +next = NodePath("../StraightMapNode6") + +[node name="StraightMapNode6" parent="TurnMapNode" node_paths=PackedStringArray("next") instance=ExtResource("2_wj4hp")] +next = NodePath("../StraightMapNode7") + +[node name="StraightMapNode7" parent="TurnMapNode" node_paths=PackedStringArray("next") instance=ExtResource("2_wj4hp")] +next = NodePath("../../StraightMapNode11") + +[node name="StraightMapNode3" parent="." node_paths=PackedStringArray("next") instance=ExtResource("2_wj4hp")] +next = NodePath("../StraightMapNode4") + +[node name="StraightMapNode4" parent="." node_paths=PackedStringArray("next") instance=ExtResource("2_wj4hp")] +next = NodePath("../StraightMapNode5") + +[node name="StraightMapNode5" parent="." node_paths=PackedStringArray("next") instance=ExtResource("2_wj4hp")] +next = NodePath("../StraightMapNode6") + +[node name="StraightMapNode6" parent="." node_paths=PackedStringArray("next") instance=ExtResource("2_wj4hp")] +next = NodePath("../StraightMapNode7") + +[node name="StraightMapNode7" parent="." node_paths=PackedStringArray("next") instance=ExtResource("2_wj4hp")] +next = NodePath("../StraightMapNode8") + +[node name="StraightMapNode8" parent="." node_paths=PackedStringArray("next") instance=ExtResource("2_wj4hp")] +next = NodePath("../StraightMapNode9") + +[node name="StraightMapNode9" parent="." node_paths=PackedStringArray("next") instance=ExtResource("2_wj4hp")] +next = NodePath("../StraightMapNode10") + +[node name="StraightMapNode10" parent="." node_paths=PackedStringArray("next") instance=ExtResource("2_wj4hp")] +next = NodePath("../StraightMapNode11") + +[node name="StraightMapNode11" parent="." node_paths=PackedStringArray("next") instance=ExtResource("2_wj4hp")] +next = NodePath("../StraightMapNode12") + +[node name="StraightMapNode12" parent="." node_paths=PackedStringArray("next") instance=ExtResource("2_wj4hp")] +next = NodePath("../StraightMapNode13") + +[node name="StraightMapNode13" parent="." node_paths=PackedStringArray("next") instance=ExtResource("2_wj4hp")] +next = NodePath("..") diff --git a/Nodes/StraightMapNode.tscn b/Nodes/StraightMapNode.tscn new file mode 100644 index 0000000..a52bd3d --- /dev/null +++ b/Nodes/StraightMapNode.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://bup2ps8l2ifj8"] + +[ext_resource type="Script" path="res://scripts/Logic/StraightMapNode.gd" id="1_1ejkw"] + +[node name="StraightMapNode" type="Node"] +script = ExtResource("1_1ejkw") diff --git a/Nodes/TurnMapNode.tscn b/Nodes/TurnMapNode.tscn new file mode 100644 index 0000000..cf8ab9f --- /dev/null +++ b/Nodes/TurnMapNode.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://c3ynfb5ky5p8g"] + +[ext_resource type="Script" path="res://scripts/Logic/TurnMapNode.gd" id="1_wbnsc"] + +[node name="TurnMapNode" type="Node"] +script = ExtResource("1_wbnsc") diff --git a/Nodes/cannon.tscn b/Nodes/cannon.tscn new file mode 100644 index 0000000..1771df1 --- /dev/null +++ b/Nodes/cannon.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://byo1m0n20yl45"] + +[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..f42b257 --- /dev/null +++ b/Nodes/game.tscn @@ -0,0 +1,64 @@ +[gd_scene load_steps=9 format=3 uid="uid://n7w0ff7u25yc"] + +[ext_resource type="Script" path="res://scripts/Logic/Game.gd" id="1_iox18"] +[ext_resource type="PackedScene" uid="uid://bqe8ucbruto1j" path="res://Nodes/StartNode.tscn" id="2_61aog"] +[ext_resource type="PackedScene" uid="uid://byo1m0n20yl45" path="res://Nodes/cannon.tscn" id="2_vrf6k"] +[ext_resource type="Script" path="res://scripts/Train.gd" id="2_xl0he"] +[ext_resource type="PackedScene" uid="uid://vwjd5od63jgh" path="res://Nodes/Player.tscn" id="4_1ipcp"] + +[sub_resource type="BoxMesh" id="BoxMesh_ognqx"] +size = Vector3(13, 1, 25) + +[sub_resource type="ConcavePolygonShape3D" id="ConcavePolygonShape3D_p3d4e"] +data = PackedVector3Array(-6.5, 0.5, 12.5, 6.5, 0.5, 12.5, -6.5, -0.5, 12.5, 6.5, 0.5, 12.5, 6.5, -0.5, 12.5, -6.5, -0.5, 12.5, 6.5, 0.5, -12.5, -6.5, 0.5, -12.5, 6.5, -0.5, -12.5, -6.5, 0.5, -12.5, -6.5, -0.5, -12.5, 6.5, -0.5, -12.5, 6.5, 0.5, 12.5, 6.5, 0.5, -12.5, 6.5, -0.5, 12.5, 6.5, 0.5, -12.5, 6.5, -0.5, -12.5, 6.5, -0.5, 12.5, -6.5, 0.5, -12.5, -6.5, 0.5, 12.5, -6.5, -0.5, -12.5, -6.5, 0.5, 12.5, -6.5, -0.5, 12.5, -6.5, -0.5, -12.5, 6.5, 0.5, 12.5, -6.5, 0.5, 12.5, 6.5, 0.5, -12.5, -6.5, 0.5, 12.5, -6.5, 0.5, -12.5, 6.5, 0.5, -12.5, -6.5, -0.5, 12.5, 6.5, -0.5, 12.5, -6.5, -0.5, -12.5, 6.5, -0.5, 12.5, 6.5, -0.5, -12.5, -6.5, -0.5, -12.5) + +[sub_resource type="ConcavePolygonShape3D" id="ConcavePolygonShape3D_l76gd"] +data = PackedVector3Array(-6.5, 0.5, 12.5, 6.5, 0.5, 12.5, -6.5, -0.5, 12.5, 6.5, 0.5, 12.5, 6.5, -0.5, 12.5, -6.5, -0.5, 12.5, 6.5, 0.5, -12.5, -6.5, 0.5, -12.5, 6.5, -0.5, -12.5, -6.5, 0.5, -12.5, -6.5, -0.5, -12.5, 6.5, -0.5, -12.5, 6.5, 0.5, 12.5, 6.5, 0.5, -12.5, 6.5, -0.5, 12.5, 6.5, 0.5, -12.5, 6.5, -0.5, -12.5, 6.5, -0.5, 12.5, -6.5, 0.5, -12.5, -6.5, 0.5, 12.5, -6.5, -0.5, -12.5, -6.5, 0.5, 12.5, -6.5, -0.5, 12.5, -6.5, -0.5, -12.5, 6.5, 0.5, 12.5, -6.5, 0.5, 12.5, 6.5, 0.5, -12.5, -6.5, 0.5, 12.5, -6.5, 0.5, -12.5, 6.5, 0.5, -12.5, -6.5, -0.5, 12.5, 6.5, -0.5, 12.5, -6.5, -0.5, -12.5, 6.5, -0.5, 12.5, 6.5, -0.5, -12.5, -6.5, -0.5, -12.5) + +[node name="Game" type="Node"] +script = ExtResource("1_iox18") + +[node name="StartNode" parent="." instance=ExtResource("2_61aog")] + +[node name="Camera3D" type="Camera3D" parent="."] +transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 20, 0) + +[node name="Player1" type="Node3D" parent="."] +transform = Transform3D(1, 0, 3.55271e-15, 0, 1, 0, -3.55271e-15, 0, 1, -8, 0, 8) +script = ExtResource("2_xl0he") + +[node name="Cannon" parent="Player1" instance=ExtResource("2_vrf6k")] + +[node name="MeshInstance3D2" type="MeshInstance3D" parent="Player1"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2, 0, -8) +mesh = SubResource("BoxMesh_ognqx") + +[node name="StaticBody3D" type="StaticBody3D" parent="Player1/MeshInstance3D2"] + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Player1/MeshInstance3D2/StaticBody3D"] +shape = SubResource("ConcavePolygonShape3D_p3d4e") + +[node name="CharacterBody3D" parent="Player1" instance=ExtResource("4_1ipcp")] +transform = Transform3D(1, 0, -3.55271e-15, 0, 1, 0, 3.55271e-15, 0, 1, -1.18815, 1, -11.064) + +[node name="Cannon2" parent="Player1" instance=ExtResource("2_vrf6k")] + +[node name="Player2" type="Node3D" parent="."] +transform = Transform3D(-0.0154456, -6.75145e-10, -0.999879, -5.21344e-12, 1, -6.75146e-10, 0.999879, -5.2134e-12, -0.0154456, -8, 0, -32) +script = ExtResource("2_xl0he") + +[node name="MeshInstance3D" type="MeshInstance3D" parent="Player2"] +transform = Transform3D(-0.0154456, -5.21524e-12, 0.999881, -6.75146e-10, 1, -5.21521e-12, -0.999881, -6.75146e-10, -0.0154456, 31.7182, -1.23195e-08, -18.4921) +mesh = SubResource("BoxMesh_ognqx") + +[node name="StaticBody3D" type="StaticBody3D" parent="Player2/MeshInstance3D"] + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Player2/MeshInstance3D/StaticBody3D"] +transform = Transform3D(1, 8.23952e-25, 0, -1.6479e-25, 1, 0, 0, -1.65436e-24, 1, 0, 0, 0) +shape = SubResource("ConcavePolygonShape3D_l76gd") + +[node name="CharacterBody3D" parent="Player2" instance=ExtResource("4_1ipcp")] +transform = Transform3D(-0.0154457, -5.21527e-12, 0.999882, -6.75147e-10, 1, -5.21524e-12, -0.999882, -6.75146e-10, -0.0154457, 31.3762, 1.5, -17.7157) + +[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 0.258819, 0.965926, 0, -0.965926, 0.258819, 0, 0, 0) diff --git a/Storage.tscn b/Storage.tscn new file mode 100644 index 0000000..4828e40 --- /dev/null +++ b/Storage.tscn @@ -0,0 +1,7 @@ +[gd_scene load_steps=2 format=3 uid="uid://cet80w4yr8rse"] + +[ext_resource type="Script" path="res://scripts/Modules/Storage.gd" id="1_guwoh"] + +[node name="Storage" type="Node"] +script = ExtResource("1_guwoh") +currentType = 0 diff --git a/background.tscn b/background.tscn new file mode 100644 index 0000000..47ca9f6 --- /dev/null +++ b/background.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://27eaxr1cxhjl"] + +[ext_resource type="Script" path="res://Backround.gd" id="1_hqtcb"] + +[node name="Background" type="Node"] +script = ExtResource("1_hqtcb") diff --git a/background_straight.tscn b/background_straight.tscn new file mode 100644 index 0000000..4865949 --- /dev/null +++ b/background_straight.tscn @@ -0,0 +1,8 @@ +[gd_scene load_steps=2 format=3 uid="uid://cgnegi0q52i3n"] + +[ext_resource type="Texture2D" uid="uid://cy6x8d3xe8lux" path="res://icon.svg" id="1_a2wr2"] + +[node name="Background_straight" type="Node"] + +[node name="Sprite2D" type="Sprite2D" parent="."] +texture = ExtResource("1_a2wr2") diff --git a/icon.svg b/icon.svg new file mode 100644 index 0000000..adc26df --- /dev/null +++ b/icon.svg @@ -0,0 +1 @@ + diff --git a/icon.svg.import b/icon.svg.import new file mode 100644 index 0000000..28894bf --- /dev/null +++ b/icon.svg.import @@ -0,0 +1,39 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cy6x8d3xe8lux" +path.s3tc="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.s3tc.ctex" +path.etc2="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.etc2.ctex" +metadata={ +"imported_formats": ["s3tc", "etc2"], +"vram_texture": true +} + +[deps] + +source_file="res://icon.svg" +dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.s3tc.ctex", "res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.etc2.ctex"] + +[params] + +compress/mode=2 +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/bptc_ldr=0 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=true +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=0 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/menu/MainMenu.gd b/menu/MainMenu.gd new file mode 100644 index 0000000..bbbd491 --- /dev/null +++ b/menu/MainMenu.gd @@ -0,0 +1,26 @@ +extends Control + + +# Called when the node enters the scene tree for the first time. +# Called when the node enters the scene tree for the first time. +func _ready(): + $VBoxContainer/Start.grab_focus() # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +#func _process(delta): +# pass + + +func _on_start_pressed(): + get_tree().change_scene_to_file("res://Nodes/game.tscn") +# Replace with function body. + + +func _on_tutorial_pressed(): + get_tree().change_scene_to_file("res://Nodes/game.tscn") # Replace with function body. + + +func _on_quit_pressed(): + get_tree().quit() + diff --git a/menu/VBoxContainer.gd b/menu/VBoxContainer.gd new file mode 100644 index 0000000..42a3a8d --- /dev/null +++ b/menu/VBoxContainer.gd @@ -0,0 +1,17 @@ +extends VBoxContainer + + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + pass + + +func _on_up_pressed(): + pass + #InputHelper.set_action_key(action: String, key: String, swap_if_taken: bool = true) -> void + #Replace with function body. diff --git a/menu/VolSlider.gd b/menu/VolSlider.gd new file mode 100644 index 0000000..e25f059 --- /dev/null +++ b/menu/VolSlider.gd @@ -0,0 +1,21 @@ +extends HSlider + + +var master_bus = AudioServer.get_bus_index("Master") + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + pass + + +func _on_value_changed(value): + AudioServer.set_bus_volume_db(master_bus, value) + if value == -30: + AudioServer.set_bus_mute(master_bus, true) + else: + AudioServer.set_bus_mute(master_bus,false) # Replace with function body. diff --git a/menu/VolumeSlider.gd b/menu/VolumeSlider.gd new file mode 100644 index 0000000..1793073 --- /dev/null +++ b/menu/VolumeSlider.gd @@ -0,0 +1,20 @@ +extends HSlider + +var master_bus = AudioServer.get_bus_index("Master") + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + pass + + +func _on_value_changed(value): + AudioServer.set_bus_volume_db(master_bus, value) + if value == -30: + AudioServer.set_bus_mute(master_bus, true) + else: + AudioServer.set_bus_mute(master_bus,false) # Replace with function body. diff --git a/menu/credits_screen.tscn b/menu/credits_screen.tscn new file mode 100644 index 0000000..a12fb91 --- /dev/null +++ b/menu/credits_screen.tscn @@ -0,0 +1,36 @@ +[gd_scene format=3 uid="uid://c301ttbip7xm4"] + +[node name="CreditsScreen" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 + +[node name="ColorRect" type="ColorRect" parent="."] +layout_mode = 0 +offset_right = 40.0 +offset_bottom = 40.0 +color = Color(0.0784314, 0.243137, 0.552941, 1) + +[node name="VBoxContainer" type="VBoxContainer" parent="."] +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -20.0 +offset_top = -20.0 +offset_right = 20.0 +offset_bottom = 20.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="RichTextLabel" type="RichTextLabel" parent="VBoxContainer"] +layout_mode = 2 +text = "Lukas +Jonas +Arthur +Lena +Albion +..." diff --git a/menu/main_menu.tscn b/menu/main_menu.tscn new file mode 100644 index 0000000..91d0824 --- /dev/null +++ b/menu/main_menu.tscn @@ -0,0 +1,66 @@ +[gd_scene load_steps=3 format=3 uid="uid://bsmsdlf5jiukx"] + +[ext_resource type="Script" path="res://menu/MainMenu.gd" id="1_hyw8p"] +[ext_resource type="Script" path="res://menu/VolSlider.gd" id="2_h85ei"] + +[node name="MainMenu" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_hyw8p") + +[node name="ColorRect" type="ColorRect" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +color = Color(0.513726, 0.403922, 0.27451, 1) + +[node name="VBoxContainer" type="VBoxContainer" parent="."] +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -20.0 +offset_top = -28.0 +offset_right = 20.0 +offset_bottom = 28.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="Start" type="Button" parent="VBoxContainer"] +layout_mode = 2 +text = "Start +" + +[node name="Tutorial" type="Button" parent="VBoxContainer"] +layout_mode = 2 +text = "Tutorial +" + +[node name="Settings" type="Button" parent="VBoxContainer"] +layout_mode = 2 +text = "Volume:" + +[node name="VolSlider" type="HSlider" parent="VBoxContainer"] +layout_mode = 2 +min_value = -30.0 +max_value = 0.0 +script = ExtResource("2_h85ei") + +[node name="Quit" type="Button" parent="VBoxContainer"] +layout_mode = 2 +text = "Quit" + +[connection signal="pressed" from="VBoxContainer/Start" to="." method="_on_start_pressed"] +[connection signal="pressed" from="VBoxContainer/Tutorial" to="." method="_on_tutorial_pressed"] +[connection signal="pressed" from="VBoxContainer/Settings" to="." method="_on_settings_pressed"] +[connection signal="value_changed" from="VBoxContainer/VolSlider" to="VBoxContainer/VolSlider" method="_on_value_changed"] +[connection signal="pressed" from="VBoxContainer/Quit" to="." method="_on_quit_pressed"] diff --git a/project.godot b/project.godot new file mode 100644 index 0000000..2c46326 --- /dev/null +++ b/project.godot @@ -0,0 +1,132 @@ +; Engine configuration file. +; It's best edited using the editor UI and not directly, +; since the parameters that go here are not all obvious. +; +; Format: +; [section] ; section goes between [] +; param=value ; assign values to parameters + +config_version=5 + +_global_script_classes=[{ +"base": "Module", +"class": &"Cannon", +"language": &"GDScript", +"path": "res://scripts/Modules/Cannon.gd" +}, { +"base": "Node", +"class": &"Game", +"language": &"GDScript", +"path": "res://scripts/Logic/Game.gd" +}, { +"base": "Node", +"class": &"MapNode", +"language": &"GDScript", +"path": "res://scripts/Logic/MapNode.gd" +}, { +"base": "Node", +"class": &"Module", +"language": &"GDScript", +"path": "res://scripts/Modules/Module.gd" +}, { +"base": "Module", +"class": &"Storage", +"language": &"GDScript", +"path": "res://scripts/Modules/Storage.gd" +}, { +"base": "MapNode", +"class": &"StraightMapNode", +"language": &"GDScript", +"path": "res://scripts/Logic/StraightMapNode.gd" +}, { +"base": "Node", +"class": &"Train", +"language": &"GDScript", +"path": "res://scripts/Train.gd" +}, { +"base": "Module", +"class": &"TrainEngine", +"language": &"GDScript", +"path": "res://scripts/Modules/Engine.gd" +}, { +"base": "StraightMapNode", +"class": &"TurnMapNode", +"language": &"GDScript", +"path": "res://scripts/Logic/TurnMapNode.gd" +}] +_global_script_class_icons={ +"Cannon": "", +"Game": "", +"MapNode": "", +"Module": "", +"Storage": "", +"StraightMapNode": "", +"Train": "", +"TrainEngine": "", +"TurnMapNode": "" +} + +[application] + +config/name="Semester Game Jam 2022" +run/main_scene="res://menu/main_menu.tscn" +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) +] +} +p1_left={ +"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":65,"unicode":0,"echo":false,"script":null) +] +} +p1_right={ +"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":68,"unicode":0,"echo":false,"script":null) +] +} +p1_up={ +"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":87,"unicode":0,"echo":false,"script":null) +] +} +p1_down={ +"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":83,"unicode":0,"echo":false,"script":null) +] +} +p1_interact={ +"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":71,"unicode":0,"echo":false,"script":null) +] +} +p2_left={ +"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":4194319,"unicode":0,"echo":false,"script":null) +] +} +p2_right={ +"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":4194321,"unicode":0,"echo":false,"script":null) +] +} +p2_up={ +"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":4194320,"unicode":0,"echo":false,"script":null) +] +} +p2_down={ +"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":4194322,"unicode":0,"echo":false,"script":null) +] +} +p2_interact={ +"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":46,"unicode":0,"echo":false,"script":null) +] +} diff --git a/scripts/Logic/Game.gd b/scripts/Logic/Game.gd new file mode 100644 index 0000000..0f68480 --- /dev/null +++ b/scripts/Logic/Game.gd @@ -0,0 +1,69 @@ +extends Node +class_name Game + +const CHILL = 0 +const FIGHTING = 1 + + +#Signals +signal ammo_pickup +signal shoot + +var fight_state = CHILL + +var t = 0.0 + +@onready var p1_train = $Player1 as Train +@onready var p2_train = $Player2 as Train + +@onready var StartNode = $StartNode +var p1_node : MapNode +var p2_node : MapNode + +func _ready(): + p1_node = StartNode + p2_node = StartNode + p2_train.get_node("CharacterBody3D").is_player1 = false + p2_train.is_P1 = false + p1_train.current_speed = 10 + p1_train.hit.connect(_on_hit_player) + p2_train.hit.connect(_on_hit_player) + + +func _on_hit_player(player1,dmg): + if not player1: + p2_train.current_speed -= dmg + else: + p1_train.current_speed -= dmg + +func _process(delta): + p1_train.current_distance += p1_train.current_speed * delta + p2_train.current_distance += p2_train.current_speed * delta + + if(p1_train.current_distance >= p1_node.LENGTH): + var distance_delta = p1_train.current_distance - p1_node.LENGTH + p1_node = p1_node._on_train_exit(p1_train) + p1_train.current_distance = distance_delta + + if(p2_train.current_distance >= p2_node.LENGTH): + var distance_delta = p2_train.current_distance - p2_node.LENGTH + p2_node = p2_node._on_train_exit(p2_train) + p2_train.current_distance = distance_delta + + if(p1_node == p2_node && p1_train.current_distance - p2_train.current_distance < 2): + if(fight_state == CHILL): + var tween = create_tween() + tween.tween_property($Camera3D, "position", Vector3(0,10,0), 1) + fight_state = FIGHTING + else: + fight_state = CHILL + var tween = create_tween() + tween.tween_property($Camera3D, "position", Vector3(0,20,0), 1) + + + if Input.is_action_pressed("test"): + emit_signal("shoot") + + + + diff --git a/scripts/Logic/MapNode.gd b/scripts/Logic/MapNode.gd new file mode 100644 index 0000000..30135d3 --- /dev/null +++ b/scripts/Logic/MapNode.gd @@ -0,0 +1,14 @@ +extends Node +class_name MapNode + +const LENGTH = 10 +const PICKUP = 0 +var previous : MapNode + +var current_trains = [] + +func _on_train_entered(train): + current_trains.append(train) + +func _on_train_exit(train): + current_trains.erase(train) diff --git a/scripts/Logic/StraightMapNode.gd b/scripts/Logic/StraightMapNode.gd new file mode 100644 index 0000000..e970ce6 --- /dev/null +++ b/scripts/Logic/StraightMapNode.gd @@ -0,0 +1,9 @@ +extends MapNode +class_name StraightMapNode + +@export var next : MapNode + +func _on_train_exit(train): + next._on_train_entered(train) + super._on_train_exit(train) + return next diff --git a/scripts/Logic/TurnMapNode.gd b/scripts/Logic/TurnMapNode.gd new file mode 100644 index 0000000..d98f312 --- /dev/null +++ b/scripts/Logic/TurnMapNode.gd @@ -0,0 +1,21 @@ +extends StraightMapNode +class_name TurnMapNode + +signal turnEvent + +var turn = false +@export var is_left_turn = false +@export var turn_node : MapNode + +func _on_train_entered(train): + super._on_train_entered(train) + turnEvent.emit() + +func _on_train_exit(train): + if(turn): + turn_node._on_train_entered(train) + current_trains.erase(train) + return turn_node + else: + super._on_train_exit(train) + return next diff --git a/scripts/Modules/Cannon.gd b/scripts/Modules/Cannon.gd new file mode 100644 index 0000000..8711c12 --- /dev/null +++ b/scripts/Modules/Cannon.gd @@ -0,0 +1,38 @@ +extends Module + +class_name Cannon + +enum STATE {INACTIVE, RELOADING, SHOOTING} + +var CAN_ENGAGE = true +var DAMAGE = 5 +@onready var train = get_parent() as Train + +#------------Methods-------------# +func _ready(): + maxStashValue = 1 + currentStashValue = 1 + currentState = STATE.INACTIVE +#TODO: FINISH +func interact(): + if currentState == STATE.INACTIVE: + #TODO: RELOADING + if currentStashValue < maxStashValue: + currentState = STATE.RELOADING + currentStashValue += 1 + return + + return + +func shoot(): + if not CAN_ENGAGE: + return false + 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 + currentState = STATE.INACTIVE + return true + return false diff --git a/scripts/Modules/Engine.gd b/scripts/Modules/Engine.gd new file mode 100644 index 0000000..58ac3e6 --- /dev/null +++ b/scripts/Modules/Engine.gd @@ -0,0 +1,25 @@ +extends Module +class_name TrainEngine + + +enum STATE {RUNNING, DEAD} + +#------------Methods-------------# +func _ready(): + var root = get_tree().root.get_child(0) + maxStashValue = 100 + currentStashValue = 100 + currentState = STATE.RUNNING +#TODO: FINISH +func interact(): + if currentState == STATE.RUNNING: + if currentStashValue < maxStashValue: + currentStashValue += 10 + if currentStashValue > maxStashValue: + currentStashValue = maxStashValue + return + #TODO: Repair Train + currentState = STATE.RUNNING + + + diff --git a/scripts/Modules/Module.gd b/scripts/Modules/Module.gd new file mode 100644 index 0000000..ca86d7d --- /dev/null +++ b/scripts/Modules/Module.gd @@ -0,0 +1,47 @@ +extends Node + +class_name Module +#-----------Parameters----------------' +var currentStashValue = 0 : set = _set_currentStashValue, get = _get_currentStashValue + +var maxStashValue = 0 : set = _set_maxStashValue, get = _get_maxStashValue + +var currentState = null : set = _set_state, get = _get_state + +var level = 0 : set = _set_level, get = _get_level + + + + +enum MODULE_TYPE {CANNON, STEERING, ENGINE, STORAGE} + + + +#------------Methods-------------# + + +func interact(): + pass + + +func _ready(): + var root = get_tree().root.get_child(0) + + +#-----------Setter and Getter---------------# +func _set_currentStashValue(newValue): + currentStashValue = newValue +func _get_currentStashValue(): + return currentStashValue +func _set_maxStashValue(newValue): + currentStashValue = newValue +func _get_maxStashValue(): + return currentStashValue +func _set_level(newValue): + level = newValue +func _get_level(): + return level +func _set_state(newValue): + currentState = newValue +func _get_state(): + return currentState diff --git a/scripts/Modules/Storage.gd b/scripts/Modules/Storage.gd new file mode 100644 index 0000000..9add654 --- /dev/null +++ b/scripts/Modules/Storage.gd @@ -0,0 +1,25 @@ +extends Module + +class_name Storage + +enum TYPE {AMMO, GUNPOWDER, FUEL} + +@export var currentType: TYPE + +#------------Methods-------------# +func _ready(): + var root = get_tree().root.get_child(0) + root.ammo_pickup.connect(_on_signal_storing) + maxStashValue = 5 + currentStashValue = 0 +func interact(): + if currentStashValue >= 1: + currentStashValue -= 1 + + return + +func _on_signal_storing(): + if currentStashValue < maxStashValue: + currentStashValue += 1 + return + diff --git a/scripts/Player.gd b/scripts/Player.gd new file mode 100644 index 0000000..e542460 --- /dev/null +++ b/scripts/Player.gd @@ -0,0 +1,59 @@ +extends CharacterBody3D + +#-----------Parameters--------------# +var SPEED = 10 +var movement = Vector3(0,0,0) +var collisionLayer = 3 +var inventory = 0 #1 - full, 0 - empty inventory +var resource = 0 + +var is_alive = true +@onready var is_player1 = true + +#---------------Methods--------------# + +func _physics_process(delta): + + movement = Vector3(0,0,0) + + check_interaction() + check_input() + velocity = movement * SPEED + move_and_slide() + +func check_input(): + + if is_player1: + if Input.is_action_pressed("p1_left"): + movement.x -= 1 + if Input.is_action_pressed("p1_right"): + movement.x += 1 + if Input.is_action_pressed("p1_up"): + movement.z -= 1 + if Input.is_action_pressed("p1_down"): + movement.z += 1 + else: + if Input.is_action_pressed("p2_left"): + movement.x -= 1 + if Input.is_action_pressed("p2_right"): + movement.x += 1 + if Input.is_action_pressed("p2_up"): + movement.z -= 1 + if Input.is_action_pressed("p2_down"): + movement.z += 1 + +func check_interaction(): + var action + if is_player1: + action = "p1_interact" + else: + action = "p2_interact" + + if Input.is_action_just_pressed(action): + for body in $HitBox.get_overlapping_bodies(): + if body is Module: + #Storage interaction + if not inventory && body is Storage: + body.interact() + elif inventory && not body is Storage: + body.interact() diff --git a/scripts/Train.gd b/scripts/Train.gd new file mode 100644 index 0000000..97e5ebd --- /dev/null +++ b/scripts/Train.gd @@ -0,0 +1,33 @@ +extends Node +class_name Train + +signal hit(player, dmg) +signal game_over + +var is_P1 = true +var current_distance = 0 +var current_speed = 5 +var CANNONS = [] +var STORAGES = [] +#@onready var ENGINE = $Module/Engine + +@onready var root = get_tree().root.get_child(0) as Game + +func _ready(): + for child in get_children(): + if(child is Cannon): + CANNONS.append(child) + if(child is Storage): + STORAGES.append(child) + root.shoot.connect(_on_signal_shooting) + + +func _on_signal_shooting(): + for cannon in CANNONS: + if cannon.shoot(): + hit.emit(is_P1,cannon.DAMAGE) + +func is_dead(): + if current_speed <= 0: + game_over.emit() +