From 2176e9d798e96b004df8141d604fc842a9d23f8c Mon Sep 17 00:00:00 2001 From: 2ndbeam Date: Sun, 5 Nov 2023 21:51:47 +0300 Subject: [PATCH] Done refactoring --- .gitattributes | 2 + .gitignore | 2 + modules/npcship.gd | 78 ---------- modules/projectile.gd | 49 ------- modules/weapon.gd | 45 ------ scenes/Bounty.tscn | 2 +- scenes/MainMenu.gd | 38 ----- scenes/MainMenu.tscn | 23 ++- scenes/MainShip.tscn | 31 ++-- scenes/Minimap.tscn | 4 +- scenes/MinimapMarker.tscn | 2 +- scenes/Space.tscn | 4 +- scenes/StarsController.tscn | 4 +- scenes/StarterBase.tscn | 10 +- scenes/engines/starterengine.tscn | 9 +- scenes/hulls/npchullt1.tscn | 4 +- scenes/hulls/starterhull.tscn | 4 +- scenes/menus/BuyMenuHealth.gd | 12 -- scenes/menus/BuyMenuLaser.gd | 29 ---- scenes/menus/BuyMenuRockets.gd | 16 --- scenes/menus/BuyMenuTurbo.gd | 9 -- scenes/menus/StarterBaseMenu.tscn | 133 ++++++++---------- scenes/npcships/NPCShipDefault.tscn | 11 +- scenes/projectiles/Laser.tscn | 10 +- scenes/projectiles/Rocket.tscn | 12 +- scenes/shields/npcshield.tscn | 10 +- scenes/shields/startershield.tscn | 12 +- scenes/weapons/DoubleLaser.tscn | 10 +- scenes/weapons/SingleLaser.tscn | 11 +- scenes/weapons/presets/DoubleLaserMk1.tscn | 14 +- scenes/weapons/presets/NPCSingleLaserMk1.tscn | 11 +- scenes/weapons/presets/SingleLaserMk1.tscn | 17 ++- scenes/weapons/presets/SingleRocketMk1.tscn | 14 +- scripts/AmmoCounter.gd | 6 - scripts/BuyMenuButton.gd | 20 --- scripts/CameraTweaks.gd | 12 -- scripts/FactionRecoloring.gd | 8 -- scripts/FuelCounter.gd | 6 - scripts/HPCounter.gd | 6 - scripts/MSEngine.gd | 60 -------- scripts/MSEngineParticles.gd | 8 -- scripts/MSHull.gd | 21 --- scripts/MSShield.gd | 44 ------ scripts/MainShipScript.gd | 28 ---- scripts/MenuButton.gd | 16 --- scripts/Minimap.gd | 18 --- scripts/MinimapMarker.gd | 21 --- scripts/MoneyCounter.gd | 6 - scripts/ShieldCounter.gd | 6 - scripts/Space.gd | 73 +++++----- scripts/SpeedLine.gd | 8 -- scripts/StarsGeneration.gd | 12 -- scripts/StarterBase.gd | 7 - scripts/StarterBaseMenu.gd | 24 ---- scripts/TurboParticles.gd | 7 - scripts/{saveload.gd => game.gd} | 0 scripts/menu/BuyMenuButton.gd | 67 +++++++++ scripts/menu/MainMenu.gd | 38 +++++ {scenes => scripts/menu}/MainMenuButton.gd | 8 +- scripts/menu/MenuButton.gd | 16 +++ .../menus => scripts/menu}/OptionsColors.gd | 0 .../menu/ResetMainShip.gd | 2 +- scripts/{ => misc}/BaseCollider.gd | 2 +- scripts/{ => misc}/BaseNPCRotator.gd | 0 scripts/misc/CameraTweaks.gd | 17 +++ scripts/misc/Counter.gd | 19 +++ scripts/misc/EngineParticles.gd | 8 ++ scripts/misc/FactionRecoloring.gd | 8 ++ scripts/{ => misc}/PlayerPauseController.gd | 2 +- scripts/{ => misc}/ProjectilesContainer.gd | 4 +- scripts/misc/SpeedLine.gd | 8 ++ scripts/misc/StarsGeneration.gd | 14 ++ scripts/misc/StarterBase.gd | 7 + scripts/misc/StarterBaseMenu.gd | 22 +++ scripts/misc/TurboParticles.gd | 7 + scripts/{ => objects}/Bounty.gd | 6 +- scripts/objects/Hull.gd | 21 +++ scripts/objects/MainShip.gd | 27 ++++ scripts/objects/Minimap.gd | 18 +++ scripts/objects/MinimapMarker.gd | 21 +++ scripts/objects/Rocket.gd | 10 ++ scripts/objects/Shield.gd | 44 ++++++ scripts/objects/ShipEngine.gd | 57 ++++++++ scripts/{ => objects}/Star.gd | 2 - scripts/objects/npcship.gd | 82 +++++++++++ scripts/objects/projectile.gd | 48 +++++++ scripts/objects/weapon.gd | 45 ++++++ scripts/projectiles/Rocket.gd | 12 -- 88 files changed, 821 insertions(+), 880 deletions(-) create mode 100644 .gitattributes create mode 100644 .gitignore delete mode 100644 modules/npcship.gd delete mode 100644 modules/projectile.gd delete mode 100644 modules/weapon.gd delete mode 100644 scenes/MainMenu.gd delete mode 100644 scenes/menus/BuyMenuHealth.gd delete mode 100644 scenes/menus/BuyMenuLaser.gd delete mode 100644 scenes/menus/BuyMenuRockets.gd delete mode 100644 scenes/menus/BuyMenuTurbo.gd delete mode 100644 scripts/AmmoCounter.gd delete mode 100644 scripts/BuyMenuButton.gd delete mode 100644 scripts/CameraTweaks.gd delete mode 100644 scripts/FactionRecoloring.gd delete mode 100644 scripts/FuelCounter.gd delete mode 100644 scripts/HPCounter.gd delete mode 100644 scripts/MSEngine.gd delete mode 100644 scripts/MSEngineParticles.gd delete mode 100644 scripts/MSHull.gd delete mode 100644 scripts/MSShield.gd delete mode 100644 scripts/MainShipScript.gd delete mode 100644 scripts/MenuButton.gd delete mode 100644 scripts/Minimap.gd delete mode 100644 scripts/MinimapMarker.gd delete mode 100644 scripts/MoneyCounter.gd delete mode 100644 scripts/ShieldCounter.gd delete mode 100644 scripts/SpeedLine.gd delete mode 100644 scripts/StarsGeneration.gd delete mode 100644 scripts/StarterBase.gd delete mode 100644 scripts/StarterBaseMenu.gd delete mode 100644 scripts/TurboParticles.gd rename scripts/{saveload.gd => game.gd} (100%) create mode 100644 scripts/menu/BuyMenuButton.gd create mode 100644 scripts/menu/MainMenu.gd rename {scenes => scripts/menu}/MainMenuButton.gd (90%) create mode 100644 scripts/menu/MenuButton.gd rename {scenes/menus => scripts/menu}/OptionsColors.gd (100%) rename scenes/menus/ResetMS.gd => scripts/menu/ResetMainShip.gd (65%) rename scripts/{ => misc}/BaseCollider.gd (50%) rename scripts/{ => misc}/BaseNPCRotator.gd (100%) create mode 100644 scripts/misc/CameraTweaks.gd create mode 100644 scripts/misc/Counter.gd create mode 100644 scripts/misc/EngineParticles.gd create mode 100644 scripts/misc/FactionRecoloring.gd rename scripts/{ => misc}/PlayerPauseController.gd (86%) rename scripts/{ => misc}/ProjectilesContainer.gd (52%) create mode 100644 scripts/misc/SpeedLine.gd create mode 100644 scripts/misc/StarsGeneration.gd create mode 100644 scripts/misc/StarterBase.gd create mode 100644 scripts/misc/StarterBaseMenu.gd create mode 100644 scripts/misc/TurboParticles.gd rename scripts/{ => objects}/Bounty.gd (50%) create mode 100644 scripts/objects/Hull.gd create mode 100644 scripts/objects/MainShip.gd create mode 100644 scripts/objects/Minimap.gd create mode 100644 scripts/objects/MinimapMarker.gd create mode 100644 scripts/objects/Rocket.gd create mode 100644 scripts/objects/Shield.gd create mode 100644 scripts/objects/ShipEngine.gd rename scripts/{ => objects}/Star.gd (84%) create mode 100644 scripts/objects/npcship.gd create mode 100644 scripts/objects/projectile.gd create mode 100644 scripts/objects/weapon.gd delete mode 100644 scripts/projectiles/Rocket.gd diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..8ad74f7 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Normalize EOL for all files that Git considers text files. +* text=auto eol=lf diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4709183 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# Godot 4+ specific ignores +.godot/ diff --git a/modules/npcship.gd b/modules/npcship.gd deleted file mode 100644 index 5c95a30..0000000 --- a/modules/npcship.gd +++ /dev/null @@ -1,78 +0,0 @@ -extends CharacterBody2D - -class_name NPCShip - -@export var DestinationTimer : Timer -@export var Fraction = "Enemy" -@export var BountyMin : int = 20 -@export var BountyMax : int = 30 -@export var Bounty : PackedScene - -var State = "idle" -var Shooting = false -var AllowShooting = true - -@onready var PlayerShip = get_tree().current_scene.get_node("MainShip") -@onready var NPCEngine = $"Engine" -@onready var Hull = $"Hull" -@onready var DebugLabel = $DebugLabel -@onready var TargetSnap = $TargetSnap -@onready var Healthbar = $Zalupa/ZalupaTwo/Health -@onready var Shield = $Shield - -func _ready(): - DestinationTimer.timeout.connect(switchdestination) - TargetSnap.mouse_entered.connect(get_tree().current_scene.addtargetlist.bind(self)) - TargetSnap.mouse_exited.connect(get_tree().current_scene.removetargetlist.bind(self)) - -func _physics_process(_delta): - match State: - "idle": - idlestate() - "chase": - chasestate() - "maintaindistance": - maintaindistancestate() - "runaway": - runawaystate() - Healthbar.text = "{HP} HS + {SC} SC".format({"HP" : "%0.2f" % Hull.HP, "SC" : "%0.2f" % Shield.Capacity}) - if Vector2.ZERO.distance_to(global_position) > 5800 or Hull.HP <= 0: - destroy() - -func switchdestination(): - NPCEngine.DestinationAngle = randi_range(0, 360) - -func idlestate(): - Shooting = false - if global_position.distance_to(PlayerShip.global_position) <= 512 and PlayerShip.AllowShooting: State = "chase" - if Vector2.ZERO.distance_to(global_position) > 5800: NPCEngine.DestinationAngle = rad_to_deg(global_position.angle_to(Vector2.ZERO)) - -func chasestate(): - NPCEngine.DestinationAngle = rad_to_deg(global_position.angle_to_point(PlayerShip.global_position)) - Shooting = true if NPCEngine.DestinationDifference == clamp(NPCEngine.DestinationDifference, -5, 5) else false - if global_position.distance_to(PlayerShip.global_position) > 512 or !PlayerShip.AllowShooting: State = "idle" - if Hull.HP < Hull.MaxHP * 0.2: State = "runaway" - if global_position.distance_to(PlayerShip.global_position) <= 128: State = "maintaindistance" - -func maintaindistancestate(): - NPCEngine.DestinationAngle += 1 - Shooting = true if NPCEngine.DestinationDifference == clamp(NPCEngine.DestinationDifference, -5, 5) else false - if global_position.distance_to(PlayerShip.global_position) > 128: State = "chase" - if !PlayerShip.AllowShooting: State = "idle" - -func runawaystate(): - Shooting = false - NPCEngine.DestinationAngle = rad_to_deg(global_position.angle_to_point(PlayerShip.global_position)) - 180 - if global_position.distance_to(PlayerShip.global_position) > 1024 or !PlayerShip.AllowShooting: State = "idle" - -func destroy(): - Hull.HP = Hull.MaxHP - Hull.Fuel = Hull.MaxFuel - Shield.Capacity = Shield.MaxShieldCapacity - State = "idle" - var BountyInst = Bounty.instantiate() - get_tree().current_scene.add_child(BountyInst) - BountyInst.global_position = global_position - BountyInst.Amount = randi_range(BountyMin, BountyMax) - BountyInst.Text.text = str(BountyInst.Amount) + " MU" - global_position = Vector2(randi_range(-4096, 4096), randi_range(-4096, 4096)) diff --git a/modules/projectile.gd b/modules/projectile.gd deleted file mode 100644 index 01e366a..0000000 --- a/modules/projectile.gd +++ /dev/null @@ -1,49 +0,0 @@ -extends Node2D - -class_name Projectile - -@export var Speed : float = 300 -@export var RotationSpeed : float = 0 -@export var Damage : float = 1 -@export var Collider : Area2D -@export var Lifetime : float = 10 - -var Fraction = "none" -var DestinationAngle : float -var Target : Node2D = self - -func _ready(): - get_tree().create_timer(Lifetime).timeout.connect(queue_free) - Collider.body_entered.connect(_on_collision) - areyouready() - -func _physics_process(delta): - if RotationSpeed == 0: DestinationAngle = global_rotation_degrees - else: DestinationAngle = rad_to_deg(global_position.angle_to_point(Target.global_position)) - global_position += Speed * delta * global_transform.x - var DestinationDifference : float - if DestinationAngle - global_rotation_degrees == clamp(DestinationAngle - global_rotation_degrees, -180, 180): - DestinationDifference = DestinationAngle - global_rotation_degrees - else: - DestinationDifference = global_rotation_degrees - DestinationAngle - if DestinationDifference != clamp(DestinationDifference, -1, 1): - global_rotation_degrees += sign(DestinationDifference) * RotationSpeed * delta - else: - global_rotation_degrees = DestinationAngle - -func _on_collision(body): - match body.collision_layer: - 1: - if body.Fraction != Fraction: - if Target != self: - Target.queue_free() - body.Shield.deal_damage(Damage) - queue_free() - 2: - if Target != self: - Target.queue_free() - queue_free() - - -func areyouready(): - pass diff --git a/modules/weapon.gd b/modules/weapon.gd deleted file mode 100644 index 79caec6..0000000 --- a/modules/weapon.gd +++ /dev/null @@ -1,45 +0,0 @@ -extends Node2D - -class_name Weapon - -@export var ShootingProjectile : PackedScene -@export var Spread : float = 0 -@export var AmmoType : String = "n/a" -@export var AmmoConsumption : float = 0 -@export var ShootingTimer : Timer -@export var ShootingAction : String = "" -@export var SpawnerPoints : Array[Node2D] - -@onready var Ship = $"../.." -@onready var Slot = $".." - -var Deviation : float = deg_to_rad(Spread) - -func _ready(): - randomize() - if Ship is MainShip: - match Slot.name: - "PrimaryWeapon": - ShootingAction = "shootprimary" - "SecondaryWeapon": - ShootingAction = "shootsecondary" - elif Ship is NPCShip: - ShootingAction = "npc" - -func _process(_delta): - var CanShoot = Ship.Hull.Ammunition[AmmoType] >= AmmoConsumption and ShootingTimer.is_stopped() and Ship.AllowShooting - if CanShoot and (Input.get_action_strength(ShootingAction) and ShootingAction != "npc" or ShootingAction == "npc" and Ship.Shooting): - shoot() - Ship.Hull.Ammunition[AmmoType] -= AmmoConsumption - ShootingTimer.start() - if AmmoType == "Laser Energy": - Ship.Shield.LaserTimer.start() - -func shoot(): - for Spawner in SpawnerPoints: - var ShootedProjectile = ShootingProjectile.instantiate() - ProjectileContainer.Instance.add_child(ShootedProjectile) - ShootedProjectile.global_position = Spawner.global_position - ShootedProjectile.global_rotation = Spawner.global_rotation + randf_range(-Deviation/2, Deviation/2) - ShootedProjectile.Fraction = Ship.Fraction - ShootedProjectile.modulate = Ship.modulate diff --git a/scenes/Bounty.tscn b/scenes/Bounty.tscn index 89b7258..f94de57 100644 --- a/scenes/Bounty.tscn +++ b/scenes/Bounty.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=3 format=3 uid="uid://d1bhrxmr0oo0n"] -[ext_resource type="Script" path="res://scripts/Bounty.gd" id="1_450ye"] +[ext_resource type="Script" path="res://scripts/objects/Bounty.gd" id="1_450ye"] [sub_resource type="CircleShape2D" id="CircleShape2D_xkl60"] radius = 32.0 diff --git a/scenes/MainMenu.gd b/scenes/MainMenu.gd deleted file mode 100644 index 7faaab0..0000000 --- a/scenes/MainMenu.gd +++ /dev/null @@ -1,38 +0,0 @@ -extends Node2D - -var MapWidth = 1280 -var MapHeight = 720 - -var MenuID = 0 - -@onready var b1 = $Control/MenuButton1 -@onready var b2 = $Control/MenuButton2 -@onready var b3 = $Control/MenuButton3 -@onready var b4 = $Control/MenuButton4 -@onready var b5 = $Control/MenuButton5 - -func change_menu(id): - match id: - 0: - b1.ID = "NewGame" - b2.ID = "Profiles" - b3.ID = "Settings" - b4.ID = "Credits" - b5.ID = "ExitGame" - 1: - b1.ID = "CreateProfile" - b2.ID = "LoadProfile" - b3.ID = "DeleteProfile" - b4.ID = "Back" - b5.ID = "Null" - 2: - b1.ID = "" - b2.ID = "" - b3.ID = "" - b4.ID = "" - b5.ID = "" - b1.change_name() - b2.change_name() - b3.change_name() - b4.change_name() - b5.change_name() diff --git a/scenes/MainMenu.tscn b/scenes/MainMenu.tscn index 253411a..168abb2 100644 --- a/scenes/MainMenu.tscn +++ b/scenes/MainMenu.tscn @@ -1,10 +1,10 @@ [gd_scene load_steps=9 format=3 uid="uid://s14kegpsyost"] -[ext_resource type="Script" path="res://scenes/MainMenu.gd" id="1_3gb4s"] +[ext_resource type="Script" path="res://scripts/menu/MainMenu.gd" id="1_2wax0"] [ext_resource type="Shader" uid="uid://f6lhks6rp5jw" path="res://testicles.tres" id="1_on8wy"] [ext_resource type="Gradient" uid="uid://c6bcjydbwm5id" path="res://scenes/SpaceGradient.tres" id="2_7racd"] [ext_resource type="PackedScene" uid="uid://dpggye27ln436" path="res://scenes/StarsController.tscn" id="4_g7254"] -[ext_resource type="Script" path="res://scenes/MainMenuButton.gd" id="5_io856"] +[ext_resource type="Script" path="res://scripts/menu/MainMenuButton.gd" id="5_q6x10"] [sub_resource type="FastNoiseLite" id="FastNoiseLite_rtgkw"] frequency = 0.001 @@ -20,7 +20,7 @@ shader = ExtResource("1_on8wy") shader_parameter/penis = SubResource("NoiseTexture2D_vkqxf") [node name="MainMenu" type="Node2D"] -script = ExtResource("1_3gb4s") +script = ExtResource("1_2wax0") [node name="ColorRect" type="ColorRect" parent="."] z_index = -20 @@ -30,7 +30,7 @@ offset_bottom = 720.0 [node name="Stars" parent="." instance=ExtResource("4_g7254")] position = Vector2(640, 360) -StarsAmount = 100 +stars_amount = 100 [node name="Control" type="Control" parent="."] layout_mode = 3 @@ -44,8 +44,7 @@ offset_left = 9.0 offset_top = 209.0 offset_right = 382.0 offset_bottom = 262.0 -script = ExtResource("5_io856") -ID = "NewGame" +script = ExtResource("5_q6x10") [node name="MenuButton2" type="Button" parent="Control"] layout_mode = 0 @@ -53,8 +52,7 @@ offset_left = 9.0 offset_top = 276.0 offset_right = 382.0 offset_bottom = 329.0 -script = ExtResource("5_io856") -ID = "CreateProfile" +script = ExtResource("5_q6x10") [node name="MenuButton3" type="Button" parent="Control"] layout_mode = 0 @@ -62,8 +60,7 @@ offset_left = 9.0 offset_top = 345.0 offset_right = 382.0 offset_bottom = 398.0 -script = ExtResource("5_io856") -ID = "LoadProfile" +script = ExtResource("5_q6x10") [node name="MenuButton4" type="Button" parent="Control"] layout_mode = 0 @@ -71,8 +68,7 @@ offset_left = 9.0 offset_top = 417.0 offset_right = 382.0 offset_bottom = 470.0 -script = ExtResource("5_io856") -ID = "Settings" +script = ExtResource("5_q6x10") [node name="MenuButton5" type="Button" parent="Control"] layout_mode = 0 @@ -80,5 +76,4 @@ offset_left = 8.0 offset_top = 488.0 offset_right = 381.0 offset_bottom = 541.0 -script = ExtResource("5_io856") -ID = "ExitGame" +script = ExtResource("5_q6x10") diff --git a/scenes/MainShip.tscn b/scenes/MainShip.tscn index 0181489..25e2762 100644 --- a/scenes/MainShip.tscn +++ b/scenes/MainShip.tscn @@ -1,18 +1,14 @@ -[gd_scene load_steps=16 format=3 uid="uid://ccrs28h3b2tfy"] +[gd_scene load_steps=12 format=3 uid="uid://ccrs28h3b2tfy"] -[ext_resource type="Script" path="res://scripts/MainShipScript.gd" id="1_h7kne"] +[ext_resource type="Script" path="res://scripts/objects/MainShip.gd" id="1_h7kne"] [ext_resource type="PackedScene" uid="uid://bbho4h6tg4jca" path="res://scenes/hulls/starterhull.tscn" id="2_r634y"] [ext_resource type="PackedScene" uid="uid://20171x3gmn1j" path="res://scenes/engines/starterengine.tscn" id="3_upe7o"] [ext_resource type="PackedScene" uid="uid://cf11711uqb42j" path="res://scenes/weapons/presets/SingleLaserMk1.tscn" id="4_s724s"] -[ext_resource type="Script" path="res://scripts/SpeedLine.gd" id="6_ckx3n"] +[ext_resource type="Script" path="res://scripts/misc/SpeedLine.gd" id="6_ckx3n"] [ext_resource type="PackedScene" uid="uid://66m5gj2ufsop" path="res://scenes/shields/startershield.tscn" id="6_nihas"] -[ext_resource type="Script" path="res://scripts/CameraTweaks.gd" id="7_5jx81"] -[ext_resource type="Script" path="res://scripts/AmmoCounter.gd" id="9_h1i5f"] -[ext_resource type="Script" path="res://scripts/FuelCounter.gd" id="10_0lke7"] -[ext_resource type="Script" path="res://scripts/ShieldCounter.gd" id="10_2l5pr"] -[ext_resource type="Script" path="res://scripts/MoneyCounter.gd" id="11_8f548"] -[ext_resource type="Script" path="res://scripts/HPCounter.gd" id="11_ouonv"] -[ext_resource type="Script" path="res://scripts/PlayerPauseController.gd" id="13_8y0ow"] +[ext_resource type="Script" path="res://scripts/misc/CameraTweaks.gd" id="7_5jx81"] +[ext_resource type="Script" path="res://scripts/misc/Counter.gd" id="8_udmcu"] +[ext_resource type="Script" path="res://scripts/misc/PlayerPauseController.gd" id="13_8y0ow"] [ext_resource type="PackedScene" uid="uid://dsmwg1rxedi3x" path="res://scenes/Minimap.tscn" id="14_o544g"] [sub_resource type="LabelSettings" id="LabelSettings_hkik3"] @@ -96,7 +92,8 @@ offset_bottom = -69.0 grow_horizontal = 2 grow_vertical = 2 text = "Fuel: 1000/1000 units" -script = ExtResource("10_0lke7") +script = ExtResource("8_udmcu") +counter_id = "fuel" [node name="AmmoCounter" type="Label" parent="GUI/Interface"] layout_mode = 1 @@ -114,7 +111,8 @@ grow_vertical = 0 text = "ammo" horizontal_alignment = 2 vertical_alignment = 2 -script = ExtResource("9_h1i5f") +script = ExtResource("8_udmcu") +counter_id = "ammo" [node name="ShieldCounter" type="Label" parent="GUI/Interface"] layout_mode = 0 @@ -123,7 +121,8 @@ offset_top = 580.0 offset_right = 239.0 offset_bottom = 606.0 text = "Shield Capacity: 8 / 8 units" -script = ExtResource("10_2l5pr") +script = ExtResource("8_udmcu") +counter_id = "shield" [node name="HPCounter" type="Label" parent="GUI/Interface"] layout_mode = 0 @@ -132,7 +131,8 @@ offset_top = 602.0 offset_right = 209.0 offset_bottom = 625.0 text = "Hull Strength: 30 / 30 units" -script = ExtResource("11_ouonv") +script = ExtResource("8_udmcu") +counter_id = "hp" [node name="MoneyCounter" type="Label" parent="GUI/Interface"] layout_mode = 0 @@ -141,7 +141,8 @@ offset_top = 558.0 offset_right = 250.0 offset_bottom = 584.0 text = "Available Money: 1000 units" -script = ExtResource("11_8f548") +script = ExtResource("8_udmcu") +counter_id = "money" [node name="PauseController" type="Control" parent="GUI/Interface"] process_mode = 2 diff --git a/scenes/Minimap.tscn b/scenes/Minimap.tscn index 91f1051..97f2e5b 100644 --- a/scenes/Minimap.tscn +++ b/scenes/Minimap.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=4 format=3 uid="uid://dsmwg1rxedi3x"] -[ext_resource type="Script" path="res://scripts/Minimap.gd" id="1_8abec"] +[ext_resource type="Script" path="res://scripts/objects/Minimap.gd" id="1_8abec"] [ext_resource type="Texture2D" uid="uid://dmvfwcq7wewxt" path="res://sprites/minimapoverlay.png" id="1_705ro"] [ext_resource type="PackedScene" uid="uid://c7iafvpoopwc0" path="res://scenes/MinimapMarker.tscn" id="2_u2t3y"] @@ -13,7 +13,7 @@ grow_horizontal = 2 grow_vertical = 2 mouse_filter = 2 script = ExtResource("1_8abec") -MarkerPack = ExtResource("2_u2t3y") +marker = ExtResource("2_u2t3y") [node name="Sprite" type="Sprite2D" parent="."] position = Vector2(96, 96) diff --git a/scenes/MinimapMarker.tscn b/scenes/MinimapMarker.tscn index f8abfce..92577cb 100644 --- a/scenes/MinimapMarker.tscn +++ b/scenes/MinimapMarker.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=6 format=3 uid="uid://c7iafvpoopwc0"] -[ext_resource type="Script" path="res://scripts/MinimapMarker.gd" id="1_j37jj"] +[ext_resource type="Script" path="res://scripts/objects/MinimapMarker.gd" id="1_j37jj"] [ext_resource type="Texture2D" uid="uid://bavanv7ua7qlx" path="res://sprites/minimaphostile.png" id="2_pfl45"] [ext_resource type="Texture2D" uid="uid://bqn08woclyoj0" path="res://sprites/minimapbase.png" id="3_sgrhe"] [ext_resource type="Texture2D" uid="uid://b1kf1jbsnw2m3" path="res://sprites/minimapbounty.png" id="4_4lyow"] diff --git a/scenes/Space.tscn b/scenes/Space.tscn index 3ed39b0..c9785e8 100644 --- a/scenes/Space.tscn +++ b/scenes/Space.tscn @@ -3,10 +3,10 @@ [ext_resource type="PackedScene" uid="uid://ccrs28h3b2tfy" path="res://scenes/MainShip.tscn" id="1_6fvpc"] [ext_resource type="Script" path="res://scripts/Space.gd" id="1_ppaw3"] [ext_resource type="PackedScene" uid="uid://dpggye27ln436" path="res://scenes/StarsController.tscn" id="3_jbyyq"] -[ext_resource type="Script" path="res://scripts/ProjectilesContainer.gd" id="4_dtv2c"] +[ext_resource type="Script" path="res://scripts/misc/ProjectilesContainer.gd" id="4_dtv2c"] [ext_resource type="PackedScene" uid="uid://dbtrc26016xov" path="res://scenes/StarterBase.tscn" id="5_bjt5p"] [ext_resource type="PackedScene" uid="uid://523dme3h6d6c" path="res://scenes/npcships/NPCShipDefault.tscn" id="6_67746"] -[ext_resource type="Script" path="res://scripts/FactionRecoloring.gd" id="7_w8i61"] +[ext_resource type="Script" path="res://scripts/misc/FactionRecoloring.gd" id="7_w8i61"] [ext_resource type="Shader" uid="uid://f6lhks6rp5jw" path="res://testicles.tres" id="9_h8ucp"] [ext_resource type="Gradient" uid="uid://c6bcjydbwm5id" path="res://scenes/SpaceGradient.tres" id="10_ijadn"] diff --git a/scenes/StarsController.tscn b/scenes/StarsController.tscn index f40f39c..e6267d1 100644 --- a/scenes/StarsController.tscn +++ b/scenes/StarsController.tscn @@ -1,9 +1,9 @@ [gd_scene load_steps=3 format=3 uid="uid://dpggye27ln436"] -[ext_resource type="Script" path="res://scripts/StarsGeneration.gd" id="1_rcdwc"] +[ext_resource type="Script" path="res://scripts/misc/StarsGeneration.gd" id="1_rcdwc"] [ext_resource type="PackedScene" uid="uid://kyuhwil8vq7n" path="res://scenes/Star.tscn" id="2_ypr5c"] [node name="Stars" type="Node2D"] process_mode = 1 script = ExtResource("1_rcdwc") -Star = ExtResource("2_ypr5c") +star = ExtResource("2_ypr5c") diff --git a/scenes/StarterBase.tscn b/scenes/StarterBase.tscn index f193b29..aa4c4ec 100644 --- a/scenes/StarterBase.tscn +++ b/scenes/StarterBase.tscn @@ -1,11 +1,11 @@ [gd_scene load_steps=7 format=3 uid="uid://dbtrc26016xov"] [ext_resource type="Texture2D" uid="uid://deabc107bimdb" path="res://sprites/space station 1.png" id="1_3ssyj"] -[ext_resource type="Script" path="res://scripts/StarterBase.gd" id="1_5xhqy"] -[ext_resource type="Script" path="res://scripts/BaseCollider.gd" id="2_18w83"] -[ext_resource type="Script" path="res://scripts/StarterBaseMenu.gd" id="2_53766"] +[ext_resource type="Script" path="res://scripts/misc/StarterBase.gd" id="1_5xhqy"] +[ext_resource type="Script" path="res://scripts/misc/BaseCollider.gd" id="2_18w83"] +[ext_resource type="Script" path="res://scripts/misc/StarterBaseMenu.gd" id="2_53766"] [ext_resource type="PackedScene" uid="uid://dj8iw5305ujrc" path="res://scenes/menus/StarterBaseMenu.tscn" id="4_jlcsy"] -[ext_resource type="Script" path="res://scripts/BaseNPCRotator.gd" id="5_kecih"] +[ext_resource type="Script" path="res://scripts/misc/BaseNPCRotator.gd" id="5_kecih"] [node name="StarterBase" type="Node2D"] process_mode = 1 @@ -32,7 +32,7 @@ polygon = PackedVector2Array(129, -32, 129, 32, 256, 63, 256, 61, 131, 30, 131, [node name="MenuCollider" type="Area2D" parent="."] collision_layer = 8 script = ExtResource("2_53766") -Menu = ExtResource("4_jlcsy") +menu = ExtResource("4_jlcsy") [node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="MenuCollider"] polygon = PackedVector2Array(129, 32, 256, 63, 256, -63, 129, -32) diff --git a/scenes/engines/starterengine.tscn b/scenes/engines/starterengine.tscn index 701f4de..11ba7b4 100644 --- a/scenes/engines/starterengine.tscn +++ b/scenes/engines/starterengine.tscn @@ -1,9 +1,9 @@ [gd_scene load_steps=11 format=3 uid="uid://20171x3gmn1j"] -[ext_resource type="Script" path="res://scripts/MSEngine.gd" id="1_jvcps"] +[ext_resource type="Script" path="res://scripts/objects/ShipEngine.gd" id="1_jvcps"] [ext_resource type="Texture2D" uid="uid://hpcn75jlrbr3" path="res://sprites/ship engine mk1.png" id="2_mll00"] -[ext_resource type="Script" path="res://scripts/MSEngineParticles.gd" id="3_fxngd"] -[ext_resource type="Script" path="res://scripts/TurboParticles.gd" id="4_f11x7"] +[ext_resource type="Script" path="res://scripts/misc/EngineParticles.gd" id="3_fxngd"] +[ext_resource type="Script" path="res://scripts/misc/TurboParticles.gd" id="4_f11x7"] [sub_resource type="Curve" id="Curve_grs2w"] _data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(1, 0), -1.30258, 0.0, 0, 0] @@ -53,8 +53,7 @@ scale_curve = SubResource("CurveTexture_ot3qw") [node name="Engine" type="Node2D"] script = ExtResource("1_jvcps") -SpeedAcceleration = 100.0 -RotationSpeed = 120 +rotation_speed = 120 [node name="EngineSprite" type="Sprite2D" parent="."] position = Vector2(-4, 0) diff --git a/scenes/hulls/npchullt1.tscn b/scenes/hulls/npchullt1.tscn index 75ff1a8..13c4e1a 100644 --- a/scenes/hulls/npchullt1.tscn +++ b/scenes/hulls/npchullt1.tscn @@ -1,11 +1,11 @@ [gd_scene load_steps=3 format=3 uid="uid://dtshhww5culu4"] -[ext_resource type="Script" path="res://scripts/MSHull.gd" id="1_x0f7x"] +[ext_resource type="Script" path="res://scripts/objects/Hull.gd" id="1_x0f7x"] [ext_resource type="Texture2D" uid="uid://dbwvej0c5bl52" path="res://sprites/ship mk1.png" id="2_wlkiy"] [node name="Hull" type="Node2D"] script = ExtResource("1_x0f7x") -MaxHP = 15 +max_hp = 15 [node name="HullSprite" type="Sprite2D" parent="."] position = Vector2(16, 0) diff --git a/scenes/hulls/starterhull.tscn b/scenes/hulls/starterhull.tscn index ec1e461..b215c7c 100644 --- a/scenes/hulls/starterhull.tscn +++ b/scenes/hulls/starterhull.tscn @@ -1,11 +1,11 @@ [gd_scene load_steps=3 format=3 uid="uid://bbho4h6tg4jca"] -[ext_resource type="Script" path="res://scripts/MSHull.gd" id="1_em4j0"] +[ext_resource type="Script" path="res://scripts/objects/Hull.gd" id="1_em4j0"] [ext_resource type="Texture2D" uid="uid://dbwvej0c5bl52" path="res://sprites/ship mk1.png" id="2_tvpkh"] [node name="Hull" type="Node2D"] script = ExtResource("1_em4j0") -MaxFuel = 6000 +max_fuel = 6000 [node name="HullSprite" type="Sprite2D" parent="."] position = Vector2(16, 0) diff --git a/scenes/menus/BuyMenuHealth.gd b/scenes/menus/BuyMenuHealth.gd deleted file mode 100644 index 09420af..0000000 --- a/scenes/menus/BuyMenuHealth.gd +++ /dev/null @@ -1,12 +0,0 @@ -extends BuyMenuButton - -func bought_action(): - if PlayerShip.Hull.HP >= PlayerShip.Hull.MaxHP: - PlayerShip.Hull.HP = PlayerShip.Hull.MaxHP - PlayerShip.Money += Price - return - PlayerShip.Hull.HP += 1 - while(PlayerShip.Hull.HP < PlayerShip.Hull.MaxHP and PlayerShip.Money >= Price): - PlayerShip.Hull.HP += 1 - PlayerShip.Money -= Price - if PlayerShip.Hull.HP > PlayerShip.Hull.MaxHP: PlayerShip.Hull.HP = PlayerShip.Hull.MaxHP diff --git a/scenes/menus/BuyMenuLaser.gd b/scenes/menus/BuyMenuLaser.gd deleted file mode 100644 index 87aca89..0000000 --- a/scenes/menus/BuyMenuLaser.gd +++ /dev/null @@ -1,29 +0,0 @@ -extends BuyMenuButton - -class_name BuyWeaponMenuButton - -@export var AddedWeapon : String -@export var Slot : String = "primary" -@export var Position : Vector2 = Vector2.ZERO - -@onready var PrimarySlot = get_tree().current_scene.get_node("MainShip/PrimaryWeapon") -@onready var SecondarySlot = get_tree().current_scene.get_node("MainShip/SecondaryWeapon") -@onready var BoughtWeapon = get_tree().current_scene.BoughtWeapon -@onready var WeaponDict = get_tree().current_scene.WeaponDict - -func bought_action(): - var SlotInst = PrimarySlot if Slot == "primary" else SecondarySlot - if !BoughtWeapon[AddedWeapon]: - BoughtWeapon[AddedWeapon] = true - else: - PlayerShip.Money += Price - if SlotInst.get_child_count() == 0: - var AddingWeapon = load(WeaponDict[AddedWeapon]).instantiate() - SlotInst.add_child(AddingWeapon) - SlotInst.position = Position - else: - for node in SlotInst.get_children(): - node.queue_free() - var AddingWeapon = load(WeaponDict[AddedWeapon]).instantiate() - SlotInst.add_child(AddingWeapon) - SlotInst.position = Position diff --git a/scenes/menus/BuyMenuRockets.gd b/scenes/menus/BuyMenuRockets.gd deleted file mode 100644 index 919dcb1..0000000 --- a/scenes/menus/BuyMenuRockets.gd +++ /dev/null @@ -1,16 +0,0 @@ -extends BuyMenuButton - -@export var RocketsAmount : float = 5 - -@onready var RocketPrice : float = Price / RocketsAmount - -func bought_action(): - if PlayerShip.Hull.Ammunition["Rockets"] == PlayerShip.Hull.MaxAmmunition["Rockets"]: PlayerShip.Money += Price - else: - if PlayerShip.Hull.Ammunition["Rockets"] + RocketsAmount > PlayerShip.Hull.MaxAmmunition["Rockets"]: - var RocketsLeft = PlayerShip.Hull.MaxAmmunition["Rockets"] - PlayerShip.Hull.Ammunition["Rockets"] - for i in range(RocketsLeft + 1): - PlayerShip.Money += RocketPrice - PlayerShip.Hull.Ammunition["Rockets"] = PlayerShip.Hull.MaxAmmunition["Rockets"] - else: - PlayerShip.Hull.Ammunition["Rockets"] += RocketsAmount diff --git a/scenes/menus/BuyMenuTurbo.gd b/scenes/menus/BuyMenuTurbo.gd deleted file mode 100644 index 40cd173..0000000 --- a/scenes/menus/BuyMenuTurbo.gd +++ /dev/null @@ -1,9 +0,0 @@ -extends BuyMenuButton - -@export var TurboAmount : float = 1000 - -func bought_action(): - if PlayerShip.Hull.Fuel == PlayerShip.Hull.MaxFuel: PlayerShip.Money += Price - else: - if PlayerShip.Hull.Fuel + TurboAmount > PlayerShip.Hull.MaxFuel: PlayerShip.Hull.Fuel = PlayerShip.Hull.MaxFuel - else: PlayerShip.Hull.Fuel += TurboAmount diff --git a/scenes/menus/StarterBaseMenu.tscn b/scenes/menus/StarterBaseMenu.tscn index d855176..e36793b 100644 --- a/scenes/menus/StarterBaseMenu.tscn +++ b/scenes/menus/StarterBaseMenu.tscn @@ -1,12 +1,8 @@ -[gd_scene load_steps=9 format=3 uid="uid://dj8iw5305ujrc"] +[gd_scene load_steps=5 format=3 uid="uid://dj8iw5305ujrc"] [ext_resource type="Texture2D" uid="uid://db4euprxhape0" path="res://sprites/9s.png" id="1_osomq"] -[ext_resource type="Script" path="res://scenes/menus/BuyMenuTurbo.gd" id="2_0mgmw"] -[ext_resource type="Script" path="res://scenes/menus/BuyMenuHealth.gd" id="3_ciur0"] -[ext_resource type="Script" path="res://scenes/menus/BuyMenuRockets.gd" id="4_aae7g"] -[ext_resource type="Script" path="res://scenes/menus/BuyMenuLaser.gd" id="5_45gom"] -[ext_resource type="Script" path="res://scenes/menus/OptionsColors.gd" id="7_m7aa1"] -[ext_resource type="Script" path="res://scenes/menus/ResetMS.gd" id="8_uifkj"] +[ext_resource type="Script" path="res://scripts/menu/BuyMenuButton.gd" id="2_rfxij"] +[ext_resource type="Script" path="res://scripts/menu/OptionsColors.gd" id="7_m7aa1"] [sub_resource type="LabelSettings" id="LabelSettings_7bj0u"] font_size = 14 @@ -35,7 +31,7 @@ patch_margin_top = 2 patch_margin_right = 2 patch_margin_bottom = 2 -[node name="Option1" type="NinePatchRect" parent="BuyMenu" node_paths=PackedStringArray("Clickable")] +[node name="Option1" type="NinePatchRect" parent="BuyMenu" node_paths=PackedStringArray("clickable")] layout_mode = 1 anchors_preset = -1 anchor_left = 0.008 @@ -54,9 +50,13 @@ patch_margin_left = 2 patch_margin_top = 2 patch_margin_right = 2 patch_margin_bottom = 2 -script = ExtResource("2_0mgmw") -Price = 50.0 -Clickable = NodePath("TextureButton") +script = ExtResource("2_rfxij") +data = { +"amount": 1000.0, +"id": "fuel" +} +price = 50.0 +clickable = NodePath("TextureButton") [node name="TextureButton" type="TextureButton" parent="BuyMenu/Option1"] layout_mode = 1 @@ -74,7 +74,7 @@ label_settings = SubResource("LabelSettings_7bj0u") horizontal_alignment = 1 vertical_alignment = 1 -[node name="Option2" type="NinePatchRect" parent="BuyMenu" node_paths=PackedStringArray("Clickable")] +[node name="Option2" type="NinePatchRect" parent="BuyMenu" node_paths=PackedStringArray("clickable")] layout_mode = 1 anchors_preset = -1 anchor_left = 0.008 @@ -93,9 +93,12 @@ patch_margin_left = 2 patch_margin_top = 2 patch_margin_right = 2 patch_margin_bottom = 2 -script = ExtResource("3_ciur0") -Price = 2.0 -Clickable = NodePath("TextureButton") +script = ExtResource("2_rfxij") +data = { +"id": "hp" +} +price = 2.0 +clickable = NodePath("TextureButton") [node name="TextureButton" type="TextureButton" parent="BuyMenu/Option2"] layout_mode = 1 @@ -113,7 +116,7 @@ label_settings = SubResource("LabelSettings_7bj0u") horizontal_alignment = 1 vertical_alignment = 1 -[node name="Option3" type="NinePatchRect" parent="BuyMenu" node_paths=PackedStringArray("Clickable")] +[node name="Option3" type="NinePatchRect" parent="BuyMenu" node_paths=PackedStringArray("clickable")] layout_mode = 1 anchors_preset = -1 anchor_left = 0.008 @@ -132,9 +135,13 @@ patch_margin_left = 2 patch_margin_top = 2 patch_margin_right = 2 patch_margin_bottom = 2 -script = ExtResource("4_aae7g") -Price = 20.0 -Clickable = NodePath("TextureButton") +script = ExtResource("2_rfxij") +data = { +"amount": 5, +"id": "rockets" +} +price = 20.0 +clickable = NodePath("TextureButton") [node name="TextureButton" type="TextureButton" parent="BuyMenu/Option3"] layout_mode = 1 @@ -152,7 +159,7 @@ label_settings = SubResource("LabelSettings_7bj0u") horizontal_alignment = 1 vertical_alignment = 1 -[node name="Option4" type="NinePatchRect" parent="BuyMenu" node_paths=PackedStringArray("Clickable")] +[node name="Option4" type="NinePatchRect" parent="BuyMenu" node_paths=PackedStringArray("clickable")] layout_mode = 1 anchors_preset = -1 anchor_left = 0.008 @@ -171,12 +178,15 @@ patch_margin_left = 2 patch_margin_top = 2 patch_margin_right = 2 patch_margin_bottom = 2 -script = ExtResource("5_45gom") -AddedWeapon = "SingleRocketMk1" -Slot = "secondary" -Position = Vector2(16, 0) -Price = 200.0 -Clickable = NodePath("TextureButton") +script = ExtResource("2_rfxij") +data = { +"id": "weapon", +"position": Vector2(8, 0), +"slot": "secondary", +"weapon": "SingleRocketMk1" +} +price = 200.0 +clickable = NodePath("TextureButton") [node name="TextureButton" type="TextureButton" parent="BuyMenu/Option4"] layout_mode = 1 @@ -194,7 +204,7 @@ label_settings = SubResource("LabelSettings_7bj0u") horizontal_alignment = 1 vertical_alignment = 1 -[node name="Option5" type="NinePatchRect" parent="BuyMenu" node_paths=PackedStringArray("Clickable")] +[node name="Option5" type="NinePatchRect" parent="BuyMenu" node_paths=PackedStringArray("clickable")] layout_mode = 1 anchors_preset = -1 anchor_left = 0.008 @@ -213,11 +223,15 @@ patch_margin_left = 2 patch_margin_top = 2 patch_margin_right = 2 patch_margin_bottom = 2 -script = ExtResource("5_45gom") -AddedWeapon = "DoubleLaserMk1" -Position = Vector2(8, 0) -Price = 300.0 -Clickable = NodePath("TextureButton") +script = ExtResource("2_rfxij") +data = { +"id": "weapon", +"position": Vector2(8, 0), +"slot": "primary", +"weapon": "DoubleLaserMk1" +} +price = 300.0 +clickable = NodePath("TextureButton") [node name="TextureButton" type="TextureButton" parent="BuyMenu/Option5"] layout_mode = 1 @@ -235,7 +249,7 @@ label_settings = SubResource("LabelSettings_7bj0u") horizontal_alignment = 1 vertical_alignment = 1 -[node name="Option6" type="NinePatchRect" parent="BuyMenu" node_paths=PackedStringArray("Clickable")] +[node name="Option6" type="NinePatchRect" parent="BuyMenu" node_paths=PackedStringArray("clickable")] layout_mode = 1 anchors_preset = -1 anchor_left = 0.008 @@ -254,10 +268,14 @@ patch_margin_left = 2 patch_margin_top = 2 patch_margin_right = 2 patch_margin_bottom = 2 -script = ExtResource("5_45gom") -AddedWeapon = "SingleLaserMk1" -Position = Vector2(8, 0) -Clickable = NodePath("TextureButton") +script = ExtResource("2_rfxij") +data = { +"id": "weapon", +"position": Vector2(16, 0), +"slot": "primary", +"weapon": "SingleLaserMk1" +} +clickable = NodePath("TextureButton") [node name="TextureButton" type="TextureButton" parent="BuyMenu/Option6"] layout_mode = 1 @@ -289,7 +307,7 @@ patch_margin_top = 2 patch_margin_right = 2 patch_margin_bottom = 2 -[node name="Colors" type="NinePatchRect" parent="OptionsMenu" node_paths=PackedStringArray("Clickable")] +[node name="Colors" type="NinePatchRect" parent="OptionsMenu" node_paths=PackedStringArray("clickable")] layout_mode = 1 anchors_preset = -1 anchor_left = 0.008 @@ -309,7 +327,7 @@ patch_margin_top = 2 patch_margin_right = 2 patch_margin_bottom = 2 script = ExtResource("7_m7aa1") -Clickable = NodePath("TextureButton") +clickable = NodePath("TextureButton") [node name="TextureButton" type="TextureButton" parent="OptionsMenu/Colors"] layout_mode = 1 @@ -325,40 +343,3 @@ text = "Randomize colors" label_settings = SubResource("LabelSettings_7bj0u") horizontal_alignment = 1 vertical_alignment = 1 - -[node name="ResetMS" type="NinePatchRect" parent="OptionsMenu" node_paths=PackedStringArray("Clickable")] -layout_mode = 1 -anchors_preset = -1 -anchor_left = 0.008 -anchor_top = 0.008 -anchor_right = 0.992 -anchor_bottom = 0.211 -offset_left = -0.0480001 -offset_top = 72.952 -offset_right = 0.0479889 -offset_bottom = 72.984 -grow_horizontal = 2 -grow_vertical = 2 -texture = ExtResource("1_osomq") -region_rect = Rect2(0, 0, 5, 5) -patch_margin_left = 2 -patch_margin_top = 2 -patch_margin_right = 2 -patch_margin_bottom = 2 -script = ExtResource("8_uifkj") -Clickable = NodePath("TextureButton") - -[node name="TextureButton" type="TextureButton" parent="OptionsMenu/ResetMS"] -layout_mode = 1 -anchors_preset = -1 -anchor_right = 1.0 -anchor_bottom = 1.0 - -[node name="Label" type="Label" parent="OptionsMenu/ResetMS"] -layout_mode = 0 -offset_right = 251.0 -offset_bottom = 52.0 -text = "Reset Main Ship" -label_settings = SubResource("LabelSettings_7bj0u") -horizontal_alignment = 1 -vertical_alignment = 1 diff --git a/scenes/npcships/NPCShipDefault.tscn b/scenes/npcships/NPCShipDefault.tscn index 679b910..7d834db 100644 --- a/scenes/npcships/NPCShipDefault.tscn +++ b/scenes/npcships/NPCShipDefault.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=9 format=3 uid="uid://523dme3h6d6c"] -[ext_resource type="Script" path="res://modules/npcship.gd" id="1_s20nu"] +[ext_resource type="Script" path="res://scripts/objects/npcship.gd" id="1_wioir"] [ext_resource type="PackedScene" uid="uid://d1bhrxmr0oo0n" path="res://scenes/Bounty.tscn" id="2_6fdps"] [ext_resource type="PackedScene" uid="uid://cyskycafymwx" path="res://scenes/shields/npcshield.tscn" id="3_47apr"] [ext_resource type="PackedScene" uid="uid://dtshhww5culu4" path="res://scenes/hulls/npchullt1.tscn" id="4_1ne0s"] @@ -13,13 +13,13 @@ radius = 64.0 [sub_resource type="LabelSettings" id="LabelSettings_21pok"] font_size = 12 -[node name="DefaultShip" type="CharacterBody2D" node_paths=PackedStringArray("DestinationTimer")] +[node name="DefaultShip" type="CharacterBody2D" node_paths=PackedStringArray("destination_timer")] process_mode = 1 collision_mask = 19 input_pickable = true -script = ExtResource("1_s20nu") -DestinationTimer = NodePath("DestinationTimer") -Bounty = ExtResource("2_6fdps") +script = ExtResource("1_wioir") +destination_timer = NodePath("DestinationTimer") +bounty = ExtResource("2_6fdps") [node name="Shield" parent="." instance=ExtResource("3_47apr")] @@ -34,7 +34,6 @@ polygon = PackedVector2Array(0, -16, 32, 0, 0, 16, 0, 4, -4, 4, -8, 8, -8, -8, - [node name="SingleLaser" parent="WeaponSlot" instance=ExtResource("6_wnekw")] position = Vector2(8, 0) -ShootingAction = "npc" [node name="DestinationTimer" type="Timer" parent="."] wait_time = 5.0 diff --git a/scenes/projectiles/Laser.tscn b/scenes/projectiles/Laser.tscn index 30aeb3a..728f41a 100644 --- a/scenes/projectiles/Laser.tscn +++ b/scenes/projectiles/Laser.tscn @@ -1,14 +1,14 @@ [gd_scene load_steps=3 format=3 uid="uid://djmoij5kuou3j"] -[ext_resource type="Script" path="res://modules/projectile.gd" id="1_plpqo"] +[ext_resource type="Script" path="res://scripts/objects/projectile.gd" id="1_6nacn"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_mo2if"] size = Vector2(1, 8) -[node name="Laser" type="Node2D" node_paths=PackedStringArray("Collider")] -script = ExtResource("1_plpqo") -Speed = 600.0 -Collider = NodePath("Collision") +[node name="Laser" type="Node2D" node_paths=PackedStringArray("collider")] +script = ExtResource("1_6nacn") +speed = 600.0 +collider = NodePath("Collision") [node name="LaserBody" type="Line2D" parent="."] points = PackedVector2Array(0, 0, 8, 0) diff --git a/scenes/projectiles/Rocket.tscn b/scenes/projectiles/Rocket.tscn index a9c103a..f742db4 100644 --- a/scenes/projectiles/Rocket.tscn +++ b/scenes/projectiles/Rocket.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=8 format=3 uid="uid://qr1h87np4sn1"] -[ext_resource type="Script" path="res://scripts/projectiles/Rocket.gd" id="1_h8tie"] +[ext_resource type="Script" path="res://scripts/objects/Rocket.gd" id="1_h8tie"] [ext_resource type="Texture2D" uid="uid://dvnqx6habw8uc" path="res://sprites/rocket mk1 1.png" id="2_g3qcb"] [ext_resource type="Texture2D" uid="uid://dgxlnp520q1tp" path="res://sprites/rocket mk1 2.png" id="3_q1u7q"] [ext_resource type="Texture2D" uid="uid://fqcylid4oa6b" path="res://sprites/rocket mk1 3.png" id="4_f2hwy"] @@ -30,12 +30,12 @@ animations = [{ radius = 2.0 height = 12.0 -[node name="Rocket" type="Node2D" node_paths=PackedStringArray("Collider")] +[node name="Rocket" type="Node2D" node_paths=PackedStringArray("collider")] script = ExtResource("1_h8tie") -Speed = 400.0 -RotationSpeed = 180.0 -Damage = 10.0 -Collider = NodePath("Collision") +speed = 400.0 +rotation_speed = 180.0 +damage = 5.0 +collider = NodePath("Collision") [node name="RocketSprite" type="AnimatedSprite2D" parent="."] position = Vector2(8, 0) diff --git a/scenes/shields/npcshield.tscn b/scenes/shields/npcshield.tscn index 1aa4f86..4c96733 100644 --- a/scenes/shields/npcshield.tscn +++ b/scenes/shields/npcshield.tscn @@ -1,12 +1,12 @@ [gd_scene load_steps=2 format=3 uid="uid://cyskycafymwx"] -[ext_resource type="Script" path="res://scripts/MSShield.gd" id="1_3t0v2"] +[ext_resource type="Script" path="res://scripts/objects/Shield.gd" id="1_3t0v2"] -[node name="Shield" type="Node2D" node_paths=PackedStringArray("RechargeTimer", "LaserTimer")] +[node name="Shield" type="Node2D" node_paths=PackedStringArray("recharge_timer", "laser_timer")] script = ExtResource("1_3t0v2") -MaxShieldCapacity = 5 -RechargeTimer = NodePath("Timer") -LaserTimer = NodePath("Timer2") +max_capacity = 5 +recharge_timer = NodePath("Timer") +laser_timer = NodePath("Timer2") [node name="Timer2" type="Timer" parent="."] wait_time = 5.0 diff --git a/scenes/shields/startershield.tscn b/scenes/shields/startershield.tscn index 77c4798..7896090 100644 --- a/scenes/shields/startershield.tscn +++ b/scenes/shields/startershield.tscn @@ -1,14 +1,12 @@ [gd_scene load_steps=2 format=3 uid="uid://66m5gj2ufsop"] -[ext_resource type="Script" path="res://scripts/MSShield.gd" id="1_6qr86"] +[ext_resource type="Script" path="res://scripts/objects/Shield.gd" id="1_6qr86"] -[node name="Shield" type="Node2D" node_paths=PackedStringArray("RechargeTimer", "LaserTimer")] +[node name="Shield" type="Node2D" node_paths=PackedStringArray("recharge_timer", "laser_timer")] script = ExtResource("1_6qr86") -MaxShieldCapacity = 10 -ShieldChargeRate = 2.0 -RechargeTimer = NodePath("Timer") -LaserTimer = NodePath("Timer2") -LaserChargeRate = 40.0 +max_capacity = 10 +recharge_timer = NodePath("Timer") +laser_timer = NodePath("Timer2") [node name="Timer2" type="Timer" parent="."] wait_time = 5.0 diff --git a/scenes/weapons/DoubleLaser.tscn b/scenes/weapons/DoubleLaser.tscn index 6ce90bc..0d4c3f8 100644 --- a/scenes/weapons/DoubleLaser.tscn +++ b/scenes/weapons/DoubleLaser.tscn @@ -1,14 +1,14 @@ [gd_scene load_steps=4 format=3 uid="uid://cb1dnh014jmpb"] -[ext_resource type="Script" path="res://modules/weapon.gd" id="1_u8yjv"] +[ext_resource type="Script" path="res://scripts/objects/weapon.gd" id="1_u8yjv"] [ext_resource type="PackedScene" uid="uid://djmoij5kuou3j" path="res://scenes/projectiles/Laser.tscn" id="2_cewjf"] [ext_resource type="Texture2D" uid="uid://c3gei46k8muk3" path="res://sprites/laserbox.png" id="3_14fq6"] -[node name="DoubleLaser" type="Node2D" node_paths=PackedStringArray("ShootingTimer", "SpawnerPoints")] +[node name="DoubleLaser" type="Node2D" node_paths=PackedStringArray("shoot_timer", "spawner_points")] script = ExtResource("1_u8yjv") -ShootingProjectile = ExtResource("2_cewjf") -ShootingTimer = NodePath("ShootingTimer") -SpawnerPoints = [NodePath("SpawnerSprite1/Spawner1"), NodePath("SpawnerSprite2/Spawner2")] +projectile = ExtResource("2_cewjf") +shoot_timer = NodePath("ShootingTimer") +spawner_points = [NodePath("SpawnerSprite1/Spawner1"), NodePath("SpawnerSprite2/Spawner2")] [node name="SpawnerSprite1" type="Sprite2D" parent="."] position = Vector2(4, -12) diff --git a/scenes/weapons/SingleLaser.tscn b/scenes/weapons/SingleLaser.tscn index acbef6a..247cbd1 100644 --- a/scenes/weapons/SingleLaser.tscn +++ b/scenes/weapons/SingleLaser.tscn @@ -1,15 +1,14 @@ [gd_scene load_steps=4 format=3 uid="uid://do1soxs2phq3v"] -[ext_resource type="Script" path="res://modules/weapon.gd" id="1_4ig05"] +[ext_resource type="Script" path="res://scripts/objects/weapon.gd" id="1_4ig05"] [ext_resource type="Texture2D" uid="uid://c3gei46k8muk3" path="res://sprites/laserbox.png" id="2_7vlpw"] [ext_resource type="PackedScene" uid="uid://djmoij5kuou3j" path="res://scenes/projectiles/Laser.tscn" id="2_w1ina"] -[node name="SingleLaser" type="Node2D" node_paths=PackedStringArray("ShootingTimer", "SpawnerPoints")] +[node name="SingleLaser" type="Node2D" node_paths=PackedStringArray("shoot_timer", "spawner_points")] script = ExtResource("1_4ig05") -ShootingProjectile = ExtResource("2_w1ina") -Spread = 5.0 -ShootingTimer = NodePath("ShootingTimer") -SpawnerPoints = [NodePath("Spawner")] +projectile = ExtResource("2_w1ina") +shoot_timer = NodePath("ShootingTimer") +spawner_points = [NodePath("Spawner")] [node name="ShootingTimer" type="Timer" parent="."] wait_time = 0.25 diff --git a/scenes/weapons/presets/DoubleLaserMk1.tscn b/scenes/weapons/presets/DoubleLaserMk1.tscn index b475c63..74f5e08 100644 --- a/scenes/weapons/presets/DoubleLaserMk1.tscn +++ b/scenes/weapons/presets/DoubleLaserMk1.tscn @@ -1,16 +1,16 @@ [gd_scene load_steps=4 format=3 uid="uid://b5ejm8antxfsm"] -[ext_resource type="Script" path="res://modules/weapon.gd" id="1_ugbl6"] +[ext_resource type="Script" path="res://scripts/objects/weapon.gd" id="1_ugbl6"] [ext_resource type="PackedScene" uid="uid://djmoij5kuou3j" path="res://scenes/projectiles/Laser.tscn" id="2_b52h8"] [ext_resource type="Texture2D" uid="uid://c3gei46k8muk3" path="res://sprites/laserbox.png" id="3_ahhl5"] -[node name="DoubleLaserMk1" type="Node2D" node_paths=PackedStringArray("ShootingTimer", "SpawnerPoints")] +[node name="DoubleLaserMk1" type="Node2D" node_paths=PackedStringArray("shoot_timer", "spawner_points")] script = ExtResource("1_ugbl6") -ShootingProjectile = ExtResource("2_b52h8") -AmmoType = "Laser Energy" -AmmoConsumption = 2.0 -ShootingTimer = NodePath("ShootingTimer") -SpawnerPoints = [NodePath("SpawnerSprite1/Spawner1"), NodePath("SpawnerSprite2/Spawner2")] +projectile = ExtResource("2_b52h8") +ammo_type = "Laser Energy" +ammo_consumption = 2.0 +shoot_timer = NodePath("ShootingTimer") +spawner_points = [NodePath("SpawnerSprite1/Spawner1"), NodePath("SpawnerSprite2/Spawner2")] [node name="SpawnerSprite1" type="Sprite2D" parent="."] position = Vector2(4, -12) diff --git a/scenes/weapons/presets/NPCSingleLaserMk1.tscn b/scenes/weapons/presets/NPCSingleLaserMk1.tscn index 2fe4a95..badec3c 100644 --- a/scenes/weapons/presets/NPCSingleLaserMk1.tscn +++ b/scenes/weapons/presets/NPCSingleLaserMk1.tscn @@ -1,15 +1,14 @@ [gd_scene load_steps=4 format=3 uid="uid://dse2xxx501xuj"] -[ext_resource type="Script" path="res://modules/weapon.gd" id="1_6r7e6"] +[ext_resource type="Script" path="res://scripts/objects/weapon.gd" id="1_6r7e6"] [ext_resource type="PackedScene" uid="uid://djmoij5kuou3j" path="res://scenes/projectiles/Laser.tscn" id="2_8akh2"] [ext_resource type="Texture2D" uid="uid://c3gei46k8muk3" path="res://sprites/laserbox.png" id="3_ncnas"] -[node name="SingleLaser" type="Node2D" node_paths=PackedStringArray("ShootingTimer", "SpawnerPoints")] +[node name="SingleLaser" type="Node2D" node_paths=PackedStringArray("shoot_timer", "spawner_points")] script = ExtResource("1_6r7e6") -ShootingProjectile = ExtResource("2_8akh2") -Spread = 3.0 -ShootingTimer = NodePath("ShootingTimer") -SpawnerPoints = [NodePath("Spawner")] +projectile = ExtResource("2_8akh2") +shoot_timer = NodePath("ShootingTimer") +spawner_points = [NodePath("Spawner")] [node name="ShootingTimer" type="Timer" parent="."] wait_time = 0.25 diff --git a/scenes/weapons/presets/SingleLaserMk1.tscn b/scenes/weapons/presets/SingleLaserMk1.tscn index 532d13a..b087959 100644 --- a/scenes/weapons/presets/SingleLaserMk1.tscn +++ b/scenes/weapons/presets/SingleLaserMk1.tscn @@ -1,17 +1,16 @@ [gd_scene load_steps=4 format=3 uid="uid://cf11711uqb42j"] -[ext_resource type="Script" path="res://modules/weapon.gd" id="1_smgrb"] +[ext_resource type="Script" path="res://scripts/objects/weapon.gd" id="1_dwcuc"] [ext_resource type="PackedScene" uid="uid://djmoij5kuou3j" path="res://scenes/projectiles/Laser.tscn" id="2_eiesu"] [ext_resource type="Texture2D" uid="uid://c3gei46k8muk3" path="res://sprites/laserbox.png" id="3_n1sx7"] -[node name="SingleLaser" type="Node2D" node_paths=PackedStringArray("ShootingTimer", "SpawnerPoints")] -script = ExtResource("1_smgrb") -ShootingProjectile = ExtResource("2_eiesu") -Spread = 5.0 -AmmoType = "Laser Energy" -AmmoConsumption = 1.0 -ShootingTimer = NodePath("ShootingTimer") -SpawnerPoints = [NodePath("Spawner")] +[node name="SingleLaser" type="Node2D" node_paths=PackedStringArray("shoot_timer", "spawner_points")] +script = ExtResource("1_dwcuc") +projectile = ExtResource("2_eiesu") +ammo_type = "Laser Energy" +ammo_consumption = 1.0 +shoot_timer = NodePath("ShootingTimer") +spawner_points = [NodePath("Spawner")] [node name="ShootingTimer" type="Timer" parent="."] wait_time = 0.25 diff --git a/scenes/weapons/presets/SingleRocketMk1.tscn b/scenes/weapons/presets/SingleRocketMk1.tscn index b3c6cc0..c7d3467 100644 --- a/scenes/weapons/presets/SingleRocketMk1.tscn +++ b/scenes/weapons/presets/SingleRocketMk1.tscn @@ -1,16 +1,16 @@ [gd_scene load_steps=4 format=3 uid="uid://bhkuvj884yyan"] -[ext_resource type="Script" path="res://modules/weapon.gd" id="1_wdpx2"] +[ext_resource type="Script" path="res://scripts/objects/weapon.gd" id="1_wdpx2"] [ext_resource type="PackedScene" uid="uid://qr1h87np4sn1" path="res://scenes/projectiles/Rocket.tscn" id="2_fypwx"] [ext_resource type="Texture2D" uid="uid://c3gei46k8muk3" path="res://sprites/laserbox.png" id="3_7gexv"] -[node name="SingleRocketMk1" type="Node2D" node_paths=PackedStringArray("ShootingTimer", "SpawnerPoints")] +[node name="SingleRocketMk1" type="Node2D" node_paths=PackedStringArray("shoot_timer", "spawner_points")] script = ExtResource("1_wdpx2") -ShootingProjectile = ExtResource("2_fypwx") -AmmoType = "Rockets" -AmmoConsumption = 1.0 -ShootingTimer = NodePath("ShootingTimer") -SpawnerPoints = [NodePath("Spawner")] +projectile = ExtResource("2_fypwx") +ammo_type = "Rockets" +ammo_consumption = 1.0 +shoot_timer = NodePath("ShootingTimer") +spawner_points = [NodePath("Spawner")] [node name="ShootingTimer" type="Timer" parent="."] wait_time = 0.5 diff --git a/scripts/AmmoCounter.gd b/scripts/AmmoCounter.gd deleted file mode 100644 index 2dee31b..0000000 --- a/scripts/AmmoCounter.gd +++ /dev/null @@ -1,6 +0,0 @@ -extends Label - -@onready var Hull = $"../../../Hull" - -func _process(_delta): - text = str(Hull.Ammunition) diff --git a/scripts/BuyMenuButton.gd b/scripts/BuyMenuButton.gd deleted file mode 100644 index 5d52cab..0000000 --- a/scripts/BuyMenuButton.gd +++ /dev/null @@ -1,20 +0,0 @@ -extends NinePatchRect - -class_name BuyMenuButton - -@export var Price : float -@export var Clickable : BaseButton - -@onready var BuyMenuObj = $".." -@onready var PlayerShip = get_tree().current_scene.get_node("MainShip") - -func _ready(): - Clickable.button_up.connect(_button_up) - -func _button_up(): - if PlayerShip.Money >= Price: - PlayerShip.Money -= Price - bought_action() - -func bought_action(): - pass diff --git a/scripts/CameraTweaks.gd b/scripts/CameraTweaks.gd deleted file mode 100644 index 2470794..0000000 --- a/scripts/CameraTweaks.gd +++ /dev/null @@ -1,12 +0,0 @@ -extends Camera2D - -@onready var MSEngine = $"../Engine" - -var Scale : float = 1 -var MinScale = Scale / 1.5 -var MaxScale = Scale * 2 - -func _process(_delta): - var SpeedPercentage = MSEngine.MaxSpeed / MSEngine.Speed - SpeedPercentage = (clamp(SpeedPercentage, MinScale, MaxScale) if MSEngine.Speed >= 0 else MaxScale) if get_parent().AllowShooting else 1 - zoom = Vector2(SpeedPercentage, SpeedPercentage) diff --git a/scripts/FactionRecoloring.gd b/scripts/FactionRecoloring.gd deleted file mode 100644 index 8960a24..0000000 --- a/scripts/FactionRecoloring.gd +++ /dev/null @@ -1,8 +0,0 @@ -extends Node2D - -func changeitemscolor(): - var Items = get_children() - var Player = get_tree().current_scene.get_node("MainShip") - for Item in Items: - Item.modulate = modulate - Player.Minimap.add_marker(Item, "hostile") diff --git a/scripts/FuelCounter.gd b/scripts/FuelCounter.gd deleted file mode 100644 index 9ec35bf..0000000 --- a/scripts/FuelCounter.gd +++ /dev/null @@ -1,6 +0,0 @@ -extends Label - -@onready var Hull = $"../../../Hull" - -func _process(_delta): - text = "Fuel: {fuel} / {max} units".format({"fuel":Hull.Fuel, "max":Hull.MaxFuel}) diff --git a/scripts/HPCounter.gd b/scripts/HPCounter.gd deleted file mode 100644 index f7dbe01..0000000 --- a/scripts/HPCounter.gd +++ /dev/null @@ -1,6 +0,0 @@ -extends Label - -@onready var Hull = $"../../../Hull" - -func _process(_delta): - text = "Hull Strength: {hp} / {max} units".format({"hp":"%0.2f" % Hull.HP, "max":Hull.MaxHP}) diff --git a/scripts/MSEngine.gd b/scripts/MSEngine.gd deleted file mode 100644 index 7fad4aa..0000000 --- a/scripts/MSEngine.gd +++ /dev/null @@ -1,60 +0,0 @@ -extends Node2D - -class_name ShipEngine - -@export var MaxSpeed : float = 200 #максимальная скорость без турбо режима -@export var MaxTurboSpeed : float = 300 #максимальная скорость в турбо режиме -@export var SpeedAcceleration : float = 50 #ускорение -@export var TurboFuelConsumption : float = 100 #потребление топлива в турбо режиме за секунду -@export var RotationSpeed : int = 90 #максимальная скорость поворота - -@onready var Ship = get_parent() - -var Speed = 0 #текущая скорость -var MinSpeed = MaxSpeed / -4 #минимальная скорость -var TurboEnabled = false -var AlternativeMovement = false -var DestinationAngle : float -var DestinationDifference : float - -@onready var Hull = $"../Hull" - -func _physics_process(delta): - - - if DestinationAngle - Ship.rotation_degrees == clamp(DestinationAngle - Ship.rotation_degrees, -180, 180): - DestinationDifference = DestinationAngle - Ship.rotation_degrees - else: - DestinationDifference = Ship.rotation_degrees - DestinationAngle - if DestinationDifference != clamp(DestinationDifference, -1, 1): - Ship.rotation_degrees += sign(DestinationDifference) * RotationSpeed * delta - else: - Ship.rotation_degrees = DestinationAngle - if !AlternativeMovement: - if Ship is MainShip: DestinationAngle = rad_to_deg(Ship.global_position.angle_to_point(get_global_mouse_position())) - else: - var RotationInput = Input.get_axis("rotateleft","rotateright") - DestinationAngle += RotationInput * RotationSpeed * delta - if DestinationAngle > 180: DestinationAngle = -180 - if DestinationAngle < -180: DestinationAngle = 180 - if Vector2.ZERO.distance_to(global_position) >= 5800: DestinationAngle = rad_to_deg(global_position.angle_to_point(Vector2.ZERO)) - - TurboEnabled = clamp(Input.get_action_raw_strength("turbo") * Hull.Fuel, 0, 1) if Ship is MainShip else (Ship.State == "runaway" and Hull.Fuel > 0) - var AccelerationInput = Input.get_axis("deccelerate", "accelerate") if Ship is MainShip else 1.0 - if !TurboEnabled: - Speed = clamp(Speed + AccelerationInput * SpeedAcceleration * delta, MinSpeed, max(MaxSpeed, Speed)) - if Speed > MaxSpeed: - Speed -= SpeedAcceleration * delta if AccelerationInput != -1 else 0 - else: - if Hull.Fuel > 0: - Speed = clamp(Speed + SpeedAcceleration * delta, MinSpeed, MaxTurboSpeed) - if Speed > MaxSpeed: - Hull.Fuel -= TurboFuelConsumption * delta - if Hull.Fuel < 0: - Hull.Fuel = 0 - - Ship.velocity = Vector2.from_angle(Ship.rotation) * Speed - Ship.move_and_slide() - - if Input.is_action_just_released("alternatemovement") and Ship is MainShip: - AlternativeMovement = !AlternativeMovement diff --git a/scripts/MSEngineParticles.gd b/scripts/MSEngineParticles.gd deleted file mode 100644 index a23be6e..0000000 --- a/scripts/MSEngineParticles.gd +++ /dev/null @@ -1,8 +0,0 @@ -extends GPUParticles2D - -@onready var MSEngine = $".." - -func _process(_delta): - var SpeedPercentage = clamp(MSEngine.Speed / MSEngine.MaxSpeed, 0.75, 1.5) - speed_scale = SpeedPercentage if MSEngine.Speed > 0 else 1 - emitting = MSEngine.Speed > 0 diff --git a/scripts/MSHull.gd b/scripts/MSHull.gd deleted file mode 100644 index c617247..0000000 --- a/scripts/MSHull.gd +++ /dev/null @@ -1,21 +0,0 @@ -extends Node2D - -class_name Hull - -@export var MaxHP : int = 30 #максимальное здоровье корпуса -@export var MaxFuel : int = 1000 #максимальный запас топлива - -@onready var HP = MaxHP #текущее количество здоровья -@onready var Fuel : float = MaxFuel #текущее количество топлива - -var Ammunition = { - "n/a" : 0, - "Laser Energy" : 100, - "Rockets" : 10 -} - -var MaxAmmunition = { - "n/a" : 0, - "Laser Energy" : 100, - "Rockets" : 20 -} diff --git a/scripts/MSShield.gd b/scripts/MSShield.gd deleted file mode 100644 index 4ccbc43..0000000 --- a/scripts/MSShield.gd +++ /dev/null @@ -1,44 +0,0 @@ -extends Node2D - -class_name Shield - -@export var MaxShieldCapacity : int = 8 #максимальный заряд щита -@export var ShieldChargeRate : float = 1 #скорость зарядки щита -@export var RechargeTimer : Timer -@export var LaserTimer : Timer -@export var LaserChargeRate : float = 20 - -@onready var Capacity : float = MaxShieldCapacity #текущий заряд щита -var CanRecharge : bool = false -var LaserRecharge : bool = true - -func _ready(): - RechargeTimer.timeout.connect(recharging_timer) - LaserTimer.timeout.connect(laser_timer) - -func deal_damage(damage : float): - Capacity -= damage - if Capacity < 0: - get_parent().Hull.HP += Capacity - Capacity = 0 - CanRecharge = false - RechargeTimer.start() - LaserTimer.start() - -func recharging_timer(): - CanRecharge = true - -func _physics_process(delta): - if CanRecharge: - Capacity += ShieldChargeRate * delta - if Capacity > MaxShieldCapacity: - Capacity = MaxShieldCapacity - CanRecharge = false - if LaserRecharge: - get_parent().Hull.Ammunition["Laser Energy"] += LaserChargeRate * delta - if get_parent().Hull.Ammunition["Laser Energy"] > get_parent().Hull.MaxAmmunition["Laser Energy"]: - get_parent().Hull.Ammunition["Laser Energy"] = get_parent().Hull.MaxAmmunition["Laser Energy"] - LaserRecharge = false - -func laser_timer(): - LaserRecharge = true diff --git a/scripts/MainShipScript.gd b/scripts/MainShipScript.gd deleted file mode 100644 index df345c6..0000000 --- a/scripts/MainShipScript.gd +++ /dev/null @@ -1,28 +0,0 @@ -extends CharacterBody2D - -class_name MainShip - -@onready var MSEngine = $Engine -@onready var Hull = $Hull -@onready var Shield = $Shield -@onready var PauseController = $GUI/Interface/PauseController -@onready var Minimap = $CanvasLayer/Control/Minimap -@onready var Camera = $Camera - -var AllowShooting = true -var Fraction = "player" -var Money : float = 1000 - -func _physics_process(_delta): - if Hull.HP < 0: destroy() - -func changeinterfacecolor(): - $GUI/Interface.modulate = modulate - -func destroy(): - Hull.HP = Hull.MaxHP - #Hull.Fuel = Hull.MaxFuel - Shield.Capacity = Shield.MaxShieldCapacity - global_position = Vector2.ZERO - MSEngine.Speed = 0 - MSEngine.TurboEnabled = false diff --git a/scripts/MenuButton.gd b/scripts/MenuButton.gd deleted file mode 100644 index e28564f..0000000 --- a/scripts/MenuButton.gd +++ /dev/null @@ -1,16 +0,0 @@ -extends NinePatchRect - -class_name MenuDefaultButton - -@export var Clickable : BaseButton - -@onready var PlayerShip = get_tree().current_scene.get_node("MainShip") - -func _ready(): - Clickable.button_up.connect(_button_up) - -func _button_up(): - action() - -func action(): - pass diff --git a/scripts/Minimap.gd b/scripts/Minimap.gd deleted file mode 100644 index 5de94b8..0000000 --- a/scripts/Minimap.gd +++ /dev/null @@ -1,18 +0,0 @@ -extends Control - -@export var MarkerPack : PackedScene - -@onready var Player = $"../../.." - -var Markers = [] - -func _process(_delta): - $Sprite.self_modulate = Player.modulate - -func add_marker(Target : Node, Type : String): - var MarkerInst = MarkerPack.instantiate() - Markers.append(MarkerInst) - MarkerInst.Target = Target - MarkerInst.Type = Type - MarkerInst.position = Vector2(96, 96) - add_child(MarkerInst) diff --git a/scripts/MinimapMarker.gd b/scripts/MinimapMarker.gd deleted file mode 100644 index 51970b2..0000000 --- a/scripts/MinimapMarker.gd +++ /dev/null @@ -1,21 +0,0 @@ -extends Node2D - -@onready var Marker = $MarkerSprite -@onready var Ship = $"../../../.." - -var Target : Node2D -var Type = "hostile" -var TMI = { - "hostile": 0, - "base": 1, - "loot": 2 -} - -func _ready(): - Marker.frame = TMI[Type] - -func _process(_delta): - rotation = Ship.global_position.angle_to_point(Target.global_position) - var Scale = 1024 / clamp(Ship.global_position.distance_to(Target.global_position), 512, 2048) - Marker.scale = Vector2(Scale, Scale) - modulate = Target.modulate diff --git a/scripts/MoneyCounter.gd b/scripts/MoneyCounter.gd deleted file mode 100644 index 793ec74..0000000 --- a/scripts/MoneyCounter.gd +++ /dev/null @@ -1,6 +0,0 @@ -extends Label - -@onready var MS = $"../../.." - -func _process(_delta): - text = "Available Money: {money} units".format({"money":MS.Money}) diff --git a/scripts/ShieldCounter.gd b/scripts/ShieldCounter.gd deleted file mode 100644 index f45b6d4..0000000 --- a/scripts/ShieldCounter.gd +++ /dev/null @@ -1,6 +0,0 @@ -extends Label - -@onready var Shield = $"../../../Shield" - -func _process(_delta): - text = "Shield Capacity: {shield} / {max} units".format({"shield":"%0.2f" % Shield.Capacity, "max":Shield.MaxShieldCapacity}) diff --git a/scripts/Space.gd b/scripts/Space.gd index d037943..20c8d9d 100644 --- a/scripts/Space.gd +++ b/scripts/Space.gd @@ -1,42 +1,39 @@ extends Node2D -var CanTarget = [] - -var WeaponDict = { +var can_target = [] +var weapon_dict = { "SingleRocketMk1" : "res://scenes/weapons/presets/SingleRocketMk1.tscn", "DoubleLaserMk1" : "res://scenes/weapons/presets/DoubleLaserMk1.tscn", "SingleLaserMk1" : "res://scenes/weapons/presets/SingleLaserMk1.tscn" } -var BoughtWeapon : Dictionary = WeaponDict.duplicate() -var ColorPlayer -var ColorBaseMenu -var ColorEnemyFaction - -@export var MapWidth = 8192 -@export var MapHeight = 8192 - -@onready var Player = $MainShip -@onready var Base = $StarterBase -@onready var EnemyFaction = $EnemyFaction +var bought_weapon : Dictionary = weapon_dict.duplicate() +var color_player +var color_base +var color_enemy +@export var map_width = 8192 +@export var map_height = 8192 +@onready var ship = $MainShip +@onready var base = $StarterBase +@onready var enemy_faction = $EnemyFaction func _ready(): randomize() recolor() - for key in BoughtWeapon: - BoughtWeapon[key] = false - BoughtWeapon["SingleLaserMk1"] = true - Player.Camera.limit_left = -MapWidth/2.0 - Player.Camera.limit_right = MapWidth/2.0 - Player.Camera.limit_top = -MapHeight/2.0 - Player.Camera.limit_bottom = MapHeight/2.0 + for key in bought_weapon: + bought_weapon[key] = false + bought_weapon["SingleLaserMk1"] = true + ship.camera.limit_left = -map_width/2.0 + ship.camera.limit_right = map_width/2.0 + ship.camera.limit_top = -map_height/2.0 + ship.camera.limit_bottom = map_height/2.0 func addtargetlist(body : Node2D): - if !CanTarget.has(body): - CanTarget.append(body) + if !can_target.has(body): + can_target.append(body) func removetargetlist(body : Node2D): - if CanTarget.has(body): - CanTarget.erase(body) + if can_target.has(body): + can_target.erase(body) func _process(_delta): if Input.is_action_just_released("pause"): @@ -47,21 +44,21 @@ func _process(_delta): func pause(): get_tree().paused = true - Player.PauseController.visible = true + ship.pause_controller.visible = true func unpause(): get_tree().paused = false - Player.PauseController.visible = false + ship.pause_controller.visible = false func recolor(): - ColorPlayer = Color.from_hsv(randf(), randf_range(0.8, 1), randf_range(0.8, 1)) - ColorBaseMenu = Color.from_hsv(randf(), randf_range(0.8, 1), randf_range(0.8, 1)) - ColorEnemyFaction = Color.from_hsv(randf(), randf_range(0.8, 1), randf_range(0.8, 1)) - Player.modulate = ColorPlayer - Base.modulate = ColorBaseMenu - EnemyFaction.modulate = ColorEnemyFaction - EnemyFaction.changeitemscolor() - Player.changeinterfacecolor() - var Menu = get_node_or_null("MainShip/GUI/StarterBaseMenu") - if Menu != null: - Menu.modulate = Base.modulate + color_player = Color.from_hsv(randf(), randf_range(0.8, 1), randf_range(0.8, 1)) + color_base = Color.from_hsv(randf(), randf_range(0.8, 1), randf_range(0.8, 1)) + color_enemy = Color.from_hsv(randf(), randf_range(0.8, 1), randf_range(0.8, 1)) + ship.modulate = color_player + base.modulate = color_base + enemy_faction.modulate = color_enemy + enemy_faction.changeitemscolor() + ship.changeinterfacecolor() + var menu = get_node_or_null("MainShip/GUI/StarterBaseMenu") + if menu != null: + menu.modulate = base.modulate diff --git a/scripts/SpeedLine.gd b/scripts/SpeedLine.gd deleted file mode 100644 index 0b708f3..0000000 --- a/scripts/SpeedLine.gd +++ /dev/null @@ -1,8 +0,0 @@ -extends Line2D - -@onready var MSEngine = $"../../../Engine" - -func _process(_delta): - var SpeedPercentage : float = MSEngine.Speed / MSEngine.MaxSpeed * 100 - var NewPoints = [Vector2.ZERO, Vector2(SpeedPercentage, 0)] - points = PackedVector2Array(NewPoints) diff --git a/scripts/StarsGeneration.gd b/scripts/StarsGeneration.gd deleted file mode 100644 index ba8192a..0000000 --- a/scripts/StarsGeneration.gd +++ /dev/null @@ -1,12 +0,0 @@ -extends Node2D - -@export var Star : PackedScene -@export var StarsAmount = 1000 - -func _ready(): - var MapWidthH = get_tree().current_scene.MapWidth / 2 - var MapHeightH = get_tree().current_scene.MapHeight / 2 - for i in range(StarsAmount): - var StarInstance = Star.instantiate() - add_child(StarInstance) - StarInstance.position = Vector2(randi_range(-MapWidthH, MapWidthH), randi_range(-MapHeightH, MapHeightH)) diff --git a/scripts/StarterBase.gd b/scripts/StarterBase.gd deleted file mode 100644 index 8296a63..0000000 --- a/scripts/StarterBase.gd +++ /dev/null @@ -1,7 +0,0 @@ -extends Node2D - -@onready var Menu = $MenuCollider - -func _ready(): - var Player = get_tree().current_scene.get_node("MainShip") - Player.Minimap.add_marker(self, "base") diff --git a/scripts/StarterBaseMenu.gd b/scripts/StarterBaseMenu.gd deleted file mode 100644 index 6d13b94..0000000 --- a/scripts/StarterBaseMenu.gd +++ /dev/null @@ -1,24 +0,0 @@ -extends Area2D - -@export var Menu : PackedScene -@onready var BaseCollider = $"../BaseCollider/BaseColliderDetector" -var MenuInst - -func onbcbodyentered(body): - if body is MainShip: - body.MSEngine.Speed = 0 - - -func _on_body_entered(body): - if body is MainShip: - body.AllowShooting = false - MenuInst = Menu.instantiate() - #get_tree().current_scene.add_child(MenuInst) - body.find_child("GUI").add_child(MenuInst) - #MenuInst.global_position = body.global_position# - Vector2(640, 360) - MenuInst.modulate = get_parent().modulate - -func _on_body_exited(body): - if body is MainShip: - body.AllowShooting = true - MenuInst.queue_free() diff --git a/scripts/TurboParticles.gd b/scripts/TurboParticles.gd deleted file mode 100644 index 14304c7..0000000 --- a/scripts/TurboParticles.gd +++ /dev/null @@ -1,7 +0,0 @@ -extends GPUParticles2D - -@onready var MSEngine = $".." - -func _process(_delta): - var SpeedPercentage = MSEngine.Speed / MSEngine.MaxSpeed if MSEngine.Ship is MainShip else 0 - emitting = SpeedPercentage > 1 diff --git a/scripts/saveload.gd b/scripts/game.gd similarity index 100% rename from scripts/saveload.gd rename to scripts/game.gd diff --git a/scripts/menu/BuyMenuButton.gd b/scripts/menu/BuyMenuButton.gd new file mode 100644 index 0000000..2a79518 --- /dev/null +++ b/scripts/menu/BuyMenuButton.gd @@ -0,0 +1,67 @@ +extends NinePatchRect + +@export var data : Dictionary = {"id" : ""} ## Contains all buy options. Must have "id" key. +@export var price : float +@export var clickable : BaseButton +@onready var ship = get_tree().current_scene.get_node("MainShip") + +func _ready(): + clickable.button_up.connect(_button_up) + +func _button_up(): + if ship.money >= price: + ship.money -= price + bought_action() + +func bought_action(): + match data["id"]: + "hp": + if ship.hull.hp >= ship.hull.max_hp: + ship.hull.hp = ship.hull.max_hp + ship.money += price + return + ship.hull.hp += 1 + while(ship.hull.hp < ship.hull.max_hp and ship.money >= price): + ship.hull.hp += 1 + ship.money -= price + if ship.hull.hp > ship.hull.max_hp: ship.hull.hp = ship.hull.max_hp + "rockets": + if ship.hull.ammunition["Rockets"] == ship.hull.max_ammunition["Rockets"]: + ship.money += price + return + var rocket_price : float = price / data["amount"] + if ship.hull.ammunition["Rockets"] + data["amount"] > ship.hull.max_ammunition["Rockets"]: + var rockets_left = ship.hull.max_ammunition["Rockets"] - ship.hull.ammunition["Rockets"] + for i in range(rockets_left + 1): + ship.money += rocket_price + ship.hull.ammunition["Rockets"] = ship.hull.max_ammunition["Rockets"] + else: + ship.hull.ammunition["Rockets"] += data["amount"] + "fuel": + if ship.hull.fuel == ship.hull.max_fuel: + ship.money += price + return + if ship.hull.fuel + data["amount"] > ship.hull.max_fuel: + ship.hull.fuel = ship.hull.max_fuel + else: + ship.hull.fuel += data["amount"] + "weapon": + var primary_slot = ship.get_node("PrimaryWeapon") + var secondary_slot = ship.get_node("SecondaryWeapon") + var bought_weapon = get_tree().current_scene.bought_weapon + var weapon_dict = get_tree().current_scene.weapon_dict + var slot = primary_slot if data["slot"] == "primary" else secondary_slot + if !bought_weapon[data["weapon"]]: + bought_weapon[data["weapon"]] = true + else: + ship.money += price + if slot.get_child_count() == 0: + var weapon_inst = load(weapon_dict[data["weapon"]]).instantiate() + slot.add_child(weapon_inst) + slot.position = data["position"] + else: + for node in slot.get_children(): + node.queue_free() + var weapon_inst = load(weapon_dict[data["weapon"]]).instantiate() + slot.add_child(weapon_inst) + slot.position = data["position"] diff --git a/scripts/menu/MainMenu.gd b/scripts/menu/MainMenu.gd new file mode 100644 index 0000000..e200a3d --- /dev/null +++ b/scripts/menu/MainMenu.gd @@ -0,0 +1,38 @@ +extends Node2D + +var map_width = 1280 +var map_height = 720 +@onready var b1 = $Control/MenuButton1 +@onready var b2 = $Control/MenuButton2 +@onready var b3 = $Control/MenuButton3 +@onready var b4 = $Control/MenuButton4 +@onready var b5 = $Control/MenuButton5 + +func _ready(): + change_menu(0) + +func change_menu(id): + match id: + 0: + b1.id = "NewGame" + b2.id = "Profiles" + b3.id = "Settings" + b4.id = "Credits" + b5.id = "ExitGame" + 1: + b1.id = "CreateProfile" + b2.id = "LoadProfile" + b3.id = "DeleteProfile" + b4.id = "Back" + b5.id = "Null" + 2: + b1.id = "" + b2.id = "" + b3.id = "" + b4.id = "" + b5.id = "" + b1.change_name() + b2.change_name() + b3.change_name() + b4.change_name() + b5.change_name() diff --git a/scenes/MainMenuButton.gd b/scripts/menu/MainMenuButton.gd similarity index 90% rename from scenes/MainMenuButton.gd rename to scripts/menu/MainMenuButton.gd index 11bd39a..a520ba5 100644 --- a/scenes/MainMenuButton.gd +++ b/scripts/menu/MainMenuButton.gd @@ -1,15 +1,15 @@ extends Button -@export var ID = "" +@export var id = "Null" -@onready var Controller = $"../.." +@onready var сontroller = $"../.." func _ready(): button_up.connect(_on_button_up) change_name() func _on_button_up(): - match ID: + match id: "NewGame": get_tree().change_scene_to_file("res://scenes/Space.tscn") "CreateProfile": @@ -21,7 +21,7 @@ func _on_button_up(): func change_name(): visible = true - match ID: + match id: "NewGame": text = "New Game" "CreateProfile": diff --git a/scripts/menu/MenuButton.gd b/scripts/menu/MenuButton.gd new file mode 100644 index 0000000..0551c75 --- /dev/null +++ b/scripts/menu/MenuButton.gd @@ -0,0 +1,16 @@ +extends NinePatchRect + +class_name MenuDefaultButton + +@export var clickable : BaseButton + +@onready var ship = get_tree().current_scene.get_node("MainShip") + +func _ready(): + clickable.button_up.connect(_button_up) + +func _button_up(): + action() + +func action(): + pass diff --git a/scenes/menus/OptionsColors.gd b/scripts/menu/OptionsColors.gd similarity index 100% rename from scenes/menus/OptionsColors.gd rename to scripts/menu/OptionsColors.gd diff --git a/scenes/menus/ResetMS.gd b/scripts/menu/ResetMainShip.gd similarity index 65% rename from scenes/menus/ResetMS.gd rename to scripts/menu/ResetMainShip.gd index c9aba46..aa1cfbd 100644 --- a/scenes/menus/ResetMS.gd +++ b/scripts/menu/ResetMainShip.gd @@ -1,4 +1,4 @@ extends MenuDefaultButton func action(): - PlayerShip.destroy() + ship.destroy() diff --git a/scripts/BaseCollider.gd b/scripts/misc/BaseCollider.gd similarity index 50% rename from scripts/BaseCollider.gd rename to scripts/misc/BaseCollider.gd index 2c99065..e9ee53b 100644 --- a/scripts/BaseCollider.gd +++ b/scripts/misc/BaseCollider.gd @@ -1,3 +1,3 @@ extends StaticBody2D -var Fraction = "none" +var faction = "none" diff --git a/scripts/BaseNPCRotator.gd b/scripts/misc/BaseNPCRotator.gd similarity index 100% rename from scripts/BaseNPCRotator.gd rename to scripts/misc/BaseNPCRotator.gd diff --git a/scripts/misc/CameraTweaks.gd b/scripts/misc/CameraTweaks.gd new file mode 100644 index 0000000..4a6f168 --- /dev/null +++ b/scripts/misc/CameraTweaks.gd @@ -0,0 +1,17 @@ +extends Camera2D + +@onready var engine = $"../Engine" +@onready var cur_scale = zoom.x +@onready var min_scale = cur_scale / 1.5 +@onready var max_scale = cur_scale * 2 + +func _process(_delta): + var speed_percentage = engine.max_speed / engine.speed + var factor : float + if get_parent().allow_shooting: + factor = clamp(speed_percentage, min_scale, max_scale) + if engine.speed < 0: + factor = max_scale + else: + factor = 1.0 + zoom = Vector2(factor, factor) diff --git a/scripts/misc/Counter.gd b/scripts/misc/Counter.gd new file mode 100644 index 0000000..e642edd --- /dev/null +++ b/scripts/misc/Counter.gd @@ -0,0 +1,19 @@ +extends Label + +@export var counter_id : String +@onready var ship = $"../../.." +@onready var hull = $"../../../Hull" +@onready var shield = $"../../../Shield" + +func _process(_delta) -> void: + match counter_id: + "ammo": + text = str(hull.ammunition) + "fuel": + text = "Fuel: {fuel} / {max} units".format({"fuel":hull.fuel, "max":hull.max_fuel}) + "hp": + text = "Hull Strength: {hp} / {max} units".format({"hp":"%0.2f" % hull.hp, "max":hull.max_hp}) + "money": + text = "Available Money: {money} units".format({"money":ship.money}) + "shield": + text = "Shield Capacity: {shield} / {max} units".format({"shield":"%0.2f" % shield.capacity, "max":shield.max_capacity}) diff --git a/scripts/misc/EngineParticles.gd b/scripts/misc/EngineParticles.gd new file mode 100644 index 0000000..a993688 --- /dev/null +++ b/scripts/misc/EngineParticles.gd @@ -0,0 +1,8 @@ +extends GPUParticles2D + +@onready var engine = $".." + +func _process(_delta): + var speed_percentage = clamp(engine.speed / engine.max_speed, 0.75, 1.5) + speed_scale = speed_percentage if engine.speed > 0 else 1 + emitting = engine.speed > 0 diff --git a/scripts/misc/FactionRecoloring.gd b/scripts/misc/FactionRecoloring.gd new file mode 100644 index 0000000..5bf286a --- /dev/null +++ b/scripts/misc/FactionRecoloring.gd @@ -0,0 +1,8 @@ +extends Node2D + +func changeitemscolor(): + var items = get_children() + var ship = get_tree().current_scene.get_node("MainShip") + for item in items: + item.modulate = modulate + ship.minimap.add_marker(item, "hostile") diff --git a/scripts/PlayerPauseController.gd b/scripts/misc/PlayerPauseController.gd similarity index 86% rename from scripts/PlayerPauseController.gd rename to scripts/misc/PlayerPauseController.gd index 081a80d..3da1f68 100644 --- a/scripts/PlayerPauseController.gd +++ b/scripts/misc/PlayerPauseController.gd @@ -1,6 +1,6 @@ extends Control -@onready var MainShip = $"../../.." +@onready var ship = $"../../.." func _on_unpause_button_button_up(): get_tree().current_scene.unpause() diff --git a/scripts/ProjectilesContainer.gd b/scripts/misc/ProjectilesContainer.gd similarity index 52% rename from scripts/ProjectilesContainer.gd rename to scripts/misc/ProjectilesContainer.gd index a599f3d..c530b9f 100644 --- a/scripts/ProjectilesContainer.gd +++ b/scripts/misc/ProjectilesContainer.gd @@ -2,7 +2,7 @@ extends Node2D class_name ProjectileContainer -static var Instance : ProjectileContainer +static var instance : ProjectileContainer func _ready(): - Instance = self + instance = self diff --git a/scripts/misc/SpeedLine.gd b/scripts/misc/SpeedLine.gd new file mode 100644 index 0000000..d4e74d7 --- /dev/null +++ b/scripts/misc/SpeedLine.gd @@ -0,0 +1,8 @@ +extends Line2D + +@onready var engine = $"../../../Engine" + +func _process(_delta): + var speed_percentage : float = engine.speed / engine.max_speed * 100 + var new_points = [Vector2.ZERO, Vector2(speed_percentage, 0)] + points = PackedVector2Array(new_points) diff --git a/scripts/misc/StarsGeneration.gd b/scripts/misc/StarsGeneration.gd new file mode 100644 index 0000000..6f2f7fe --- /dev/null +++ b/scripts/misc/StarsGeneration.gd @@ -0,0 +1,14 @@ +extends Node2D + +@export var star : PackedScene +@export var stars_amount = 1000 + +func _ready(): + var map_width_halved = get_tree().current_scene.map_width / 2 + var map_height_halved = get_tree().current_scene.map_height / 2 + for i in range(stars_amount): + var star_inst = star.instantiate() + var x = randi_range(-map_width_halved, map_width_halved) + var y = randi_range(-map_height_halved, map_height_halved) + add_child(star_inst) + star_inst.position = Vector2(x, y) diff --git a/scripts/misc/StarterBase.gd b/scripts/misc/StarterBase.gd new file mode 100644 index 0000000..c7d0987 --- /dev/null +++ b/scripts/misc/StarterBase.gd @@ -0,0 +1,7 @@ +extends Node2D + +@onready var menu = $MenuCollider +@onready var ship = get_tree().current_scene.get_node("MainShip") + +func _ready(): + ship.minimap.add_marker(self, "base") diff --git a/scripts/misc/StarterBaseMenu.gd b/scripts/misc/StarterBaseMenu.gd new file mode 100644 index 0000000..48af881 --- /dev/null +++ b/scripts/misc/StarterBaseMenu.gd @@ -0,0 +1,22 @@ +extends Area2D + +@export var menu : PackedScene +@onready var base_collider = $"../BaseCollider/BaseColliderDetector" +var menu_inst + +func onbcbodyentered(body): + if body is MainShip: + body.engine.speed = 0 + + +func _on_body_entered(body): + if body is MainShip: + body.allow_shooting = false + menu_inst = menu.instantiate() + body.find_child("GUI").add_child(menu_inst) + menu_inst.modulate = get_parent().modulate + +func _on_body_exited(body): + if body is MainShip: + body.allow_shooting = true + menu_inst.queue_free() diff --git a/scripts/misc/TurboParticles.gd b/scripts/misc/TurboParticles.gd new file mode 100644 index 0000000..4d756c9 --- /dev/null +++ b/scripts/misc/TurboParticles.gd @@ -0,0 +1,7 @@ +extends GPUParticles2D + +@onready var engine = $".." + +func _process(_delta): + var speed_percentage = engine.speed / engine.max_speed if engine.ship is MainShip else 0 + emitting = speed_percentage > 1 diff --git a/scripts/Bounty.gd b/scripts/objects/Bounty.gd similarity index 50% rename from scripts/Bounty.gd rename to scripts/objects/Bounty.gd index 566b8b7..7c3bea7 100644 --- a/scripts/Bounty.gd +++ b/scripts/objects/Bounty.gd @@ -1,10 +1,10 @@ extends Area2D -@export var Amount: float = 20 +@export var amount: float = 20 -@onready var Text = $Label +@onready var text = $Label func _on_body_entered(body): if body is MainShip: - body.Money += Amount + body.money += amount queue_free() diff --git a/scripts/objects/Hull.gd b/scripts/objects/Hull.gd new file mode 100644 index 0000000..531d450 --- /dev/null +++ b/scripts/objects/Hull.gd @@ -0,0 +1,21 @@ +extends Node2D + +class_name Hull + +@export var max_hp : int = 30 +@export var max_fuel : int = 1000 + +@onready var hp = max_hp +@onready var fuel : float = max_fuel + +var ammunition = { + "n/a" : 0, + "Laser Energy" : 100, + "Rockets" : 10 +} + +var max_ammunition = { + "n/a" : 0, + "Laser Energy" : 100, + "Rockets" : 20 +} diff --git a/scripts/objects/MainShip.gd b/scripts/objects/MainShip.gd new file mode 100644 index 0000000..1779756 --- /dev/null +++ b/scripts/objects/MainShip.gd @@ -0,0 +1,27 @@ +extends CharacterBody2D + +class_name MainShip + +@onready var engine = $Engine +@onready var hull = $Hull +@onready var shield = $Shield +@onready var pause_controller = $GUI/Interface/PauseController +@onready var minimap = $CanvasLayer/Control/Minimap +@onready var camera = $Camera + +var allow_shooting = true +var faction = "player" +var money : float = 1000 + +func _process(_delta): + if hull.hp < 0: destroy() + +func changeinterfacecolor(): + $GUI/Interface.modulate = modulate + +func destroy(): + hull.hp = hull.max_hp + shield.capacity = shield.max_capacity + global_position = Vector2.ZERO + engine.speed = 0 + engine.turbo_enabled = false diff --git a/scripts/objects/Minimap.gd b/scripts/objects/Minimap.gd new file mode 100644 index 0000000..a39e6b9 --- /dev/null +++ b/scripts/objects/Minimap.gd @@ -0,0 +1,18 @@ +extends Control + +@export var marker : PackedScene + +@onready var ship = $"../../.." + +var markers = [] + +func _process(_delta): + $Sprite.self_modulate = ship.modulate + +func add_marker(target : Node, type : String): + var marker_inst = marker.instantiate() + markers.append(marker_inst) + marker_inst.target = target + marker_inst.type = type + marker_inst.position = Vector2(96, 96) + add_child(marker_inst) diff --git a/scripts/objects/MinimapMarker.gd b/scripts/objects/MinimapMarker.gd new file mode 100644 index 0000000..35ac755 --- /dev/null +++ b/scripts/objects/MinimapMarker.gd @@ -0,0 +1,21 @@ +extends Node2D + +@onready var marker = $MarkerSprite +@onready var ship = $"../../../.." + +var target : Node2D +var type = "hostile" +var tmi = { + "hostile": 0, + "base": 1, + "loot": 2 +} + +func _ready(): + marker.frame = tmi[type] + +func _process(_delta): + rotation = ship.global_position.angle_to_point(target.global_position) + var sp_scale = 1024 / clamp(ship.global_position.distance_to(target.global_position), 512, 2048) + marker.scale = Vector2(sp_scale, sp_scale) + modulate = target.modulate diff --git a/scripts/objects/Rocket.gd b/scripts/objects/Rocket.gd new file mode 100644 index 0000000..6c062b5 --- /dev/null +++ b/scripts/objects/Rocket.gd @@ -0,0 +1,10 @@ +extends Projectile + +func areyouready(): + target = Node2D.new() + if len(get_tree().current_scene.can_target) > 0: + get_tree().current_scene.can_target[0].add_child(target) + else: + get_parent().add_child(target) + target.global_position = get_global_mouse_position() + diff --git a/scripts/objects/Shield.gd b/scripts/objects/Shield.gd new file mode 100644 index 0000000..6ad23cc --- /dev/null +++ b/scripts/objects/Shield.gd @@ -0,0 +1,44 @@ +extends Node2D + +class_name Shield + +@export var max_capacity : int = 8 +@export var shield_charge_rate : float = 1 +@export var recharge_timer : Timer +@export var laser_timer : Timer +@export var laser_charge_rate : float = 20 +@onready var ship = get_parent() +@onready var capacity : float = max_capacity +var can_recharge : bool = false +var laser_recharge : bool = true + +func _ready(): + recharge_timer.timeout.connect(recharging_timer_out) + laser_timer.timeout.connect(laser_timer_out) + +func deal_damage(damage : float): + capacity -= damage + if capacity < 0: + ship.hull.hp += capacity + capacity = 0 + can_recharge = false + recharge_timer.start() + laser_timer.start() + +func recharging_timer_out(): + can_recharge = true + +func _physics_process(delta): + if can_recharge: + capacity += shield_charge_rate * delta + if capacity > max_capacity: + capacity = max_capacity + can_recharge = false + if laser_recharge: + ship.hull.ammunition["Laser Energy"] += laser_charge_rate * delta + if ship.hull.ammunition["Laser Energy"] > ship.hull.max_ammunition["Laser Energy"]: + ship.hull.ammunition["Laser Energy"] = ship.hull.max_ammunition["Laser Energy"] + laser_recharge = false + +func laser_timer_out(): + laser_recharge = true diff --git a/scripts/objects/ShipEngine.gd b/scripts/objects/ShipEngine.gd new file mode 100644 index 0000000..9898280 --- /dev/null +++ b/scripts/objects/ShipEngine.gd @@ -0,0 +1,57 @@ +extends Node2D + +class_name ShipEngine + +@export var max_speed : float = 200 +@export var max_turbo_speed : float = 300 +@export var acceleration : float = 50 +@export var fuel_consumption : float = 100 +@export var rotation_speed : int = 90 +@onready var ship = get_parent() +@onready var hull = $"../Hull" +var speed = 0 +var min_speed = max_speed / -4 +var turbo_enabled = false +var alternative_movement = false +var destination_angle : float +var destination_difference : float + + +func _physics_process(delta): + var turbo_input = Input.get_action_raw_strength("turbo") + var acceleration_input = Input.get_axis("deccelerate", "accelerate") if ship is MainShip else 1.0 + var rotation_input = Input.get_axis("rotateleft","rotateright") + if destination_angle - ship.rotation_degrees == clamp(destination_angle - ship.rotation_degrees, -180, 180): + destination_difference = destination_angle - ship.rotation_degrees + else: + destination_difference = ship.rotation_degrees - destination_angle + if destination_difference != clamp(destination_difference, -1, 1): + ship.rotation_degrees += sign(destination_difference) * rotation_speed * delta + else: + ship.rotation_degrees = destination_angle + if alternative_movement: + destination_angle += rotation_input * rotation_speed * delta + if destination_angle > 180: destination_angle = -180 + if destination_angle < -180: destination_angle = 180 + if Vector2.ZERO.distance_to(global_position) >= 5800: + destination_angle = rad_to_deg(global_position.angle_to_point(Vector2.ZERO)) + elif ship is MainShip: + destination_angle = rad_to_deg(ship.global_position.angle_to_point(get_global_mouse_position())) + turbo_enabled = clamp(turbo_input * hull.fuel, 0, 1) if ship is MainShip else (ship.state == "runaway" and hull.fuel > 0) + if !turbo_enabled: + speed = clamp(speed + acceleration_input * acceleration * delta, min_speed, max(max_speed, speed)) + if speed > max_speed: + speed -= acceleration * delta if acceleration_input != -1 else 0 + else: + if hull.fuel > 0: + speed = clamp(speed + acceleration * delta, min_speed, max_turbo_speed) + if speed > max_speed: + hull.fuel -= fuel_consumption * delta + if hull.fuel < 0: + hull.fuel = 0 + + ship.velocity = Vector2.from_angle(ship.rotation) * speed + ship.move_and_slide() + + if Input.is_action_just_released("alternatemovement") and ship is MainShip: + alternative_movement = !alternative_movement diff --git a/scripts/Star.gd b/scripts/objects/Star.gd similarity index 84% rename from scripts/Star.gd rename to scripts/objects/Star.gd index bae04fe..534e08d 100644 --- a/scripts/Star.gd +++ b/scripts/objects/Star.gd @@ -1,7 +1,5 @@ extends AnimatedSprite2D - -# Called when the node enters the scene tree for the first time. func _ready(): randomize() var Size : float = randf_range(0.5, 2) diff --git a/scripts/objects/npcship.gd b/scripts/objects/npcship.gd new file mode 100644 index 0000000..32b52f3 --- /dev/null +++ b/scripts/objects/npcship.gd @@ -0,0 +1,82 @@ +extends CharacterBody2D + +class_name NPCShip + +@export var destination_timer : Timer +@export var faction = "Enemy" +@export var bounty_min : int = 20 +@export var bounty_max : int = 30 +@export var bounty : PackedScene +@onready var ship = get_tree().current_scene.get_node("MainShip") +@onready var engine = $"Engine" +@onready var hull = $"Hull" +@onready var debug_label = $DebugLabel +@onready var target_snap = $TargetSnap +@onready var healthbar = $Zalupa/ZalupaTwo/Health +@onready var shield = $Shield +var state = "idle" +var shooting = false +var allow_shooting = true + +func _ready(): + destination_timer.timeout.connect(switchdestination) + target_snap.mouse_entered.connect(get_tree().current_scene.addtargetlist.bind(self)) + target_snap.mouse_exited.connect(get_tree().current_scene.removetargetlist.bind(self)) + +func _physics_process(_delta): + match state: + "idle": + idlestate() + "chase": + chasestate() + "maintaindistance": + maintaindistancestate() + "runaway": + runawaystate() + var format = {"HP" : "%0.2f" % hull.hp, "SC" : "%0.2f" % shield.capacity} + healthbar.text = "{HP} HS + {SC} SC".format(format) + if Vector2.ZERO.distance_to(global_position) > 5800 or hull.hp <= 0: + destroy() + +func switchdestination(): + engine.destination_angle = randi_range(0, 360) + +func idlestate(): + shooting = false + if global_position.distance_to(ship.global_position) <= 512 and ship.allow_shooting: + state = "chase" + +func chasestate(): + engine.destination_angle = rad_to_deg(global_position.angle_to_point(ship.global_position)) + shooting = true if abs(engine.destination_difference) <= 5 else false + if global_position.distance_to(ship.global_position) > 512 or !ship.allow_shooting: + state = "idle" + if hull.hp < hull.max_hp * 0.2: state = "runaway" + if global_position.distance_to(ship.global_position) <= 128: + state = "maintaindistance" + +func maintaindistancestate(): + engine.destination_angle += 1 + shooting = true if abs(engine.destination_difference) <= 5 else false + if global_position.distance_to(ship.global_position) > 128: + state = "chase" + if !ship.allow_shooting: + state = "idle" + +func runawaystate(): + shooting = false + engine.destination_angle = rad_to_deg(global_position.angle_to_point(ship.global_position)) - 180 + if global_position.distance_to(ship.global_position) > 1024 or !ship.allow_shooting: + state = "idle" + +func destroy(): + hull.hp = hull.max_hp + hull.fuel = hull.max_fuel + shield.capacity = shield.max_capacity + state = "idle" + var bounty_inst = bounty.instantiate() + get_tree().current_scene.add_child(bounty_inst) + bounty_inst.global_position = global_position + bounty_inst.amount = randi_range(bounty_min, bounty_max) + bounty_inst.text.text = str(bounty_inst.amount) + " MU" + global_position = Vector2(randi_range(-4096, 4096), randi_range(-4096, 4096)) diff --git a/scripts/objects/projectile.gd b/scripts/objects/projectile.gd new file mode 100644 index 0000000..ecdc19e --- /dev/null +++ b/scripts/objects/projectile.gd @@ -0,0 +1,48 @@ +extends Node2D + +class_name Projectile + +@export var speed : float = 300 +@export var rotation_speed : float = 0 +@export var damage : float = 1 +@export var collider : Area2D +@export var lifetime : float = 10 + +var faction = "none" +var destination_angle : float +var target : Node2D = self + +func _ready(): + get_tree().create_timer(lifetime).timeout.connect(queue_free) + collider.body_entered.connect(_on_collision) + areyouready() + +func _physics_process(delta): + if rotation_speed == 0: destination_angle = global_rotation_degrees + else: destination_angle = rad_to_deg(global_position.angle_to_point(target.global_position)) + global_position += speed * delta * global_transform.x + var destination_difference : float + if abs(destination_angle - global_rotation_degrees) <= 180: + destination_difference = destination_angle - global_rotation_degrees + else: + destination_difference = global_rotation_degrees - destination_angle + if destination_difference != clamp(destination_difference, -1, 1): + global_rotation_degrees += sign(destination_difference) * rotation_speed * delta + else: + global_rotation_degrees = destination_angle + +func _on_collision(body): + match body.collision_layer: + 1: + if body.faction != faction: + if target != self: + target.queue_free() + body.shield.deal_damage(damage) + queue_free() + 2: + if target != self: + target.queue_free() + queue_free() + +func areyouready(): + pass diff --git a/scripts/objects/weapon.gd b/scripts/objects/weapon.gd new file mode 100644 index 0000000..1907278 --- /dev/null +++ b/scripts/objects/weapon.gd @@ -0,0 +1,45 @@ +extends Node2D + +class_name Weapon + +@export var projectile : PackedScene +@export var spread : float = 0 +@export var ammo_type : String = "n/a" +@export var ammo_consumption : float = 0 +@export var shoot_timer : Timer +@export var shoot_action : String = "" +@export var spawner_points : Array[Node2D] + +@onready var ship = $"../.." +@onready var slot = $".." + +var deviation : float = deg_to_rad(spread) + +func _ready(): + randomize() + if ship is MainShip: + match slot.name: + "PrimaryWeapon": + shoot_action = "shootprimary" + "SecondaryWeapon": + shoot_action = "shootsecondary" + elif ship is NPCShip: + shoot_action = "npc" + +func _process(_delta): + var can_shoot = ship.hull.ammunition[ammo_type] >= ammo_consumption and shoot_timer.is_stopped() and ship.allow_shooting + if can_shoot and (Input.get_action_strength(shoot_action) and shoot_action != "npc" or shoot_action == "npc" and ship.shooting): + shoot() + ship.hull.ammunition[ammo_type] -= ammo_consumption + shoot_timer.start() + if ammo_type == "Laser Energy": + ship.shield.laser_timer.start() + +func shoot(): + for spawner in spawner_points: + var proj_inst = projectile.instantiate() + ProjectileContainer.instance.add_child(proj_inst) + proj_inst.global_position = spawner.global_position + proj_inst.global_rotation = spawner.global_rotation + randf_range(-deviation/2, deviation/2) + proj_inst.faction = ship.faction + proj_inst.modulate = ship.modulate diff --git a/scripts/projectiles/Rocket.gd b/scripts/projectiles/Rocket.gd deleted file mode 100644 index 231be04..0000000 --- a/scripts/projectiles/Rocket.gd +++ /dev/null @@ -1,12 +0,0 @@ -extends Projectile - - - -func areyouready(): - Target = Node2D.new() - if len(get_tree().current_scene.CanTarget) > 0: - get_tree().current_scene.CanTarget[0].add_child(Target) - else: - get_parent().add_child(Target) - Target.global_position = get_global_mouse_position() -