From 3411c5796de3ae02b6191309971544ae43dfa213 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=BA=D0=B5=D1=81=D0=B5=D0=B9=20=D0=9C=D0=B8?= =?UTF-8?q?=D1=80=D0=BD=D0=B5=D0=BA=D0=BE=D0=B2?= <80163046+gotfishmakesticks@users.noreply.github.com> Date: Sun, 5 Nov 2023 16:23:18 +0300 Subject: [PATCH] Initial commit (1/2) --- modules/npcship.gd | 78 ++++ modules/projectile.gd | 49 +++ modules/weapon.gd | 45 +++ scenes/Bounty.tscn | 24 ++ scenes/MainMenu.gd | 38 ++ scenes/MainMenu.tscn | 84 ++++ scenes/MainMenuButton.gd | 47 +++ scenes/MainShip.tscn | 215 +++++++++++ scenes/Minimap.tscn | 20 + scenes/MinimapMarker.tscn | 31 ++ scenes/Space.tscn | 90 +++++ scenes/SpaceGradient.tres | 5 + scenes/Star.tscn | 50 +++ scenes/StarsController.tscn | 9 + scenes/StarterBase.tscn | 57 +++ scenes/engines/starterengine.tscn | 81 ++++ scenes/hulls/npchullt1.tscn | 12 + scenes/hulls/starterhull.tscn | 12 + scenes/menus/BuyMenuHealth.gd | 12 + scenes/menus/BuyMenuLaser.gd | 29 ++ scenes/menus/BuyMenuRockets.gd | 16 + scenes/menus/BuyMenuTurbo.gd | 9 + scenes/menus/OptionsColors.gd | 4 + scenes/menus/ResetMS.gd | 4 + scenes/menus/StarterBaseMenu.tscn | 364 ++++++++++++++++++ scenes/npcships/NPCShipDefault.tscn | 75 ++++ scenes/projectiles/Laser.tscn | 24 ++ scenes/projectiles/Rocket.tscn | 52 +++ scenes/shields/npcshield.tscn | 17 + scenes/shields/startershield.tscn | 19 + scenes/weapons/DoubleLaser.tscn | 31 ++ scenes/weapons/SingleLaser.tscn | 22 ++ scenes/weapons/presets/DoubleLaserMk1.tscn | 33 ++ scenes/weapons/presets/NPCSingleLaserMk1.tscn | 22 ++ scenes/weapons/presets/SingleLaserMk1.tscn | 24 ++ scenes/weapons/presets/SingleRocketMk1.tscn | 23 ++ scripts/AmmoCounter.gd | 6 + scripts/BaseCollider.gd | 3 + scripts/BaseNPCRotator.gd | 5 + scripts/Bounty.gd | 10 + 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/PlayerPauseController.gd | 11 + scripts/ProjectilesContainer.gd | 8 + scripts/ShieldCounter.gd | 6 + scripts/Space.gd | 67 ++++ scripts/SpeedLine.gd | 8 + scripts/Star.gd | 12 + scripts/StarsGeneration.gd | 12 + scripts/StarterBase.gd | 7 + scripts/StarterBaseMenu.gd | 24 ++ scripts/TurboParticles.gd | 7 + scripts/projectiles/Rocket.gd | 12 + scripts/saveload.gd | 62 +++ 66 files changed, 2261 insertions(+) create mode 100644 modules/npcship.gd create mode 100644 modules/projectile.gd create mode 100644 modules/weapon.gd create mode 100644 scenes/Bounty.tscn create mode 100644 scenes/MainMenu.gd create mode 100644 scenes/MainMenu.tscn create mode 100644 scenes/MainMenuButton.gd create mode 100644 scenes/MainShip.tscn create mode 100644 scenes/Minimap.tscn create mode 100644 scenes/MinimapMarker.tscn create mode 100644 scenes/Space.tscn create mode 100644 scenes/SpaceGradient.tres create mode 100644 scenes/Star.tscn create mode 100644 scenes/StarsController.tscn create mode 100644 scenes/StarterBase.tscn create mode 100644 scenes/engines/starterengine.tscn create mode 100644 scenes/hulls/npchullt1.tscn create mode 100644 scenes/hulls/starterhull.tscn create mode 100644 scenes/menus/BuyMenuHealth.gd create mode 100644 scenes/menus/BuyMenuLaser.gd create mode 100644 scenes/menus/BuyMenuRockets.gd create mode 100644 scenes/menus/BuyMenuTurbo.gd create mode 100644 scenes/menus/OptionsColors.gd create mode 100644 scenes/menus/ResetMS.gd create mode 100644 scenes/menus/StarterBaseMenu.tscn create mode 100644 scenes/npcships/NPCShipDefault.tscn create mode 100644 scenes/projectiles/Laser.tscn create mode 100644 scenes/projectiles/Rocket.tscn create mode 100644 scenes/shields/npcshield.tscn create mode 100644 scenes/shields/startershield.tscn create mode 100644 scenes/weapons/DoubleLaser.tscn create mode 100644 scenes/weapons/SingleLaser.tscn create mode 100644 scenes/weapons/presets/DoubleLaserMk1.tscn create mode 100644 scenes/weapons/presets/NPCSingleLaserMk1.tscn create mode 100644 scenes/weapons/presets/SingleLaserMk1.tscn create mode 100644 scenes/weapons/presets/SingleRocketMk1.tscn create mode 100644 scripts/AmmoCounter.gd create mode 100644 scripts/BaseCollider.gd create mode 100644 scripts/BaseNPCRotator.gd create mode 100644 scripts/Bounty.gd create mode 100644 scripts/BuyMenuButton.gd create mode 100644 scripts/CameraTweaks.gd create mode 100644 scripts/FactionRecoloring.gd create mode 100644 scripts/FuelCounter.gd create mode 100644 scripts/HPCounter.gd create mode 100644 scripts/MSEngine.gd create mode 100644 scripts/MSEngineParticles.gd create mode 100644 scripts/MSHull.gd create mode 100644 scripts/MSShield.gd create mode 100644 scripts/MainShipScript.gd create mode 100644 scripts/MenuButton.gd create mode 100644 scripts/Minimap.gd create mode 100644 scripts/MinimapMarker.gd create mode 100644 scripts/MoneyCounter.gd create mode 100644 scripts/PlayerPauseController.gd create mode 100644 scripts/ProjectilesContainer.gd create mode 100644 scripts/ShieldCounter.gd create mode 100644 scripts/Space.gd create mode 100644 scripts/SpeedLine.gd create mode 100644 scripts/Star.gd create mode 100644 scripts/StarsGeneration.gd create mode 100644 scripts/StarterBase.gd create mode 100644 scripts/StarterBaseMenu.gd create mode 100644 scripts/TurboParticles.gd create mode 100644 scripts/projectiles/Rocket.gd create mode 100644 scripts/saveload.gd diff --git a/modules/npcship.gd b/modules/npcship.gd new file mode 100644 index 0000000..5c95a30 --- /dev/null +++ b/modules/npcship.gd @@ -0,0 +1,78 @@ +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 new file mode 100644 index 0000000..01e366a --- /dev/null +++ b/modules/projectile.gd @@ -0,0 +1,49 @@ +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 new file mode 100644 index 0000000..79caec6 --- /dev/null +++ b/modules/weapon.gd @@ -0,0 +1,45 @@ +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 new file mode 100644 index 0000000..89b7258 --- /dev/null +++ b/scenes/Bounty.tscn @@ -0,0 +1,24 @@ +[gd_scene load_steps=3 format=3 uid="uid://d1bhrxmr0oo0n"] + +[ext_resource type="Script" path="res://scripts/Bounty.gd" id="1_450ye"] + +[sub_resource type="CircleShape2D" id="CircleShape2D_xkl60"] +radius = 32.0 + +[node name="Bounty" type="Area2D"] +collision_layer = 4 +script = ExtResource("1_450ye") + +[node name="Label" type="Label" parent="."] +offset_left = -27.0 +offset_top = -13.0 +offset_right = 28.0 +offset_bottom = 13.0 +text = "7-8 MU" +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource("CircleShape2D_xkl60") + +[connection signal="body_entered" from="." to="." method="_on_body_entered"] diff --git a/scenes/MainMenu.gd b/scenes/MainMenu.gd new file mode 100644 index 0000000..7faaab0 --- /dev/null +++ b/scenes/MainMenu.gd @@ -0,0 +1,38 @@ +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 new file mode 100644 index 0000000..253411a --- /dev/null +++ b/scenes/MainMenu.tscn @@ -0,0 +1,84 @@ +[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="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"] + +[sub_resource type="FastNoiseLite" id="FastNoiseLite_rtgkw"] +frequency = 0.001 + +[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_vkqxf"] +width = 1280 +height = 720 +color_ramp = ExtResource("2_7racd") +noise = SubResource("FastNoiseLite_rtgkw") + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_dawi1"] +shader = ExtResource("1_on8wy") +shader_parameter/penis = SubResource("NoiseTexture2D_vkqxf") + +[node name="MainMenu" type="Node2D"] +script = ExtResource("1_3gb4s") + +[node name="ColorRect" type="ColorRect" parent="."] +z_index = -20 +material = SubResource("ShaderMaterial_dawi1") +offset_right = 1280.0 +offset_bottom = 720.0 + +[node name="Stars" parent="." instance=ExtResource("4_g7254")] +position = Vector2(640, 360) +StarsAmount = 100 + +[node name="Control" type="Control" parent="."] +layout_mode = 3 +anchors_preset = 0 +offset_right = 1280.0 +offset_bottom = 720.0 + +[node name="MenuButton1" type="Button" parent="Control"] +layout_mode = 0 +offset_left = 9.0 +offset_top = 209.0 +offset_right = 382.0 +offset_bottom = 262.0 +script = ExtResource("5_io856") +ID = "NewGame" + +[node name="MenuButton2" type="Button" parent="Control"] +layout_mode = 0 +offset_left = 9.0 +offset_top = 276.0 +offset_right = 382.0 +offset_bottom = 329.0 +script = ExtResource("5_io856") +ID = "CreateProfile" + +[node name="MenuButton3" type="Button" parent="Control"] +layout_mode = 0 +offset_left = 9.0 +offset_top = 345.0 +offset_right = 382.0 +offset_bottom = 398.0 +script = ExtResource("5_io856") +ID = "LoadProfile" + +[node name="MenuButton4" type="Button" parent="Control"] +layout_mode = 0 +offset_left = 9.0 +offset_top = 417.0 +offset_right = 382.0 +offset_bottom = 470.0 +script = ExtResource("5_io856") +ID = "Settings" + +[node name="MenuButton5" type="Button" parent="Control"] +layout_mode = 0 +offset_left = 8.0 +offset_top = 488.0 +offset_right = 381.0 +offset_bottom = 541.0 +script = ExtResource("5_io856") +ID = "ExitGame" diff --git a/scenes/MainMenuButton.gd b/scenes/MainMenuButton.gd new file mode 100644 index 0000000..11bd39a --- /dev/null +++ b/scenes/MainMenuButton.gd @@ -0,0 +1,47 @@ +extends Button + +@export var ID = "" + +@onready var Controller = $"../.." + +func _ready(): + button_up.connect(_on_button_up) + change_name() + +func _on_button_up(): + match ID: + "NewGame": + get_tree().change_scene_to_file("res://scenes/Space.tscn") + "CreateProfile": + Game.profile_create("1") + "LoadProfile": + Game.profile_load("1") + "ExitGame": + get_tree().quit() + +func change_name(): + visible = true + match ID: + "NewGame": + text = "New Game" + "CreateProfile": + text = "Create Profile" + "LoadProfile": + text = "Load Profile" + "DeleteProfile": + text = "Delete Profile" + "ExitGame": + text = "Exit Game" + "Settings": + text = "Settings (WIP)" + "AudioSettings": + text = "Audio (WIP)" + "VideoSettings": + text = "Video (WIP)" + "Profiles": + text = "Profiles (WIP)" + "Back": + text = "Back" + "Null": + text = Game.gameversion + visible = false diff --git a/scenes/MainShip.tscn b/scenes/MainShip.tscn new file mode 100644 index 0000000..0181489 --- /dev/null +++ b/scenes/MainShip.tscn @@ -0,0 +1,215 @@ +[gd_scene load_steps=16 format=3 uid="uid://ccrs28h3b2tfy"] + +[ext_resource type="Script" path="res://scripts/MainShipScript.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="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="PackedScene" uid="uid://dsmwg1rxedi3x" path="res://scenes/Minimap.tscn" id="14_o544g"] + +[sub_resource type="LabelSettings" id="LabelSettings_hkik3"] +font_size = 48 + +[node name="MainShip" type="CharacterBody2D"] +process_mode = 1 +collision_mask = 3 +script = ExtResource("1_h7kne") +metadata/_edit_horizontal_guides_ = [] + +[node name="Hull" parent="." instance=ExtResource("2_r634y")] + +[node name="Engine" parent="." instance=ExtResource("3_upe7o")] + +[node name="PrimaryWeapon" type="Node2D" parent="."] + +[node name="SingleLaser" parent="PrimaryWeapon" instance=ExtResource("4_s724s")] +position = Vector2(8, 0) + +[node name="SecondaryWeapon" type="Node2D" parent="."] + +[node name="Shield" parent="." instance=ExtResource("6_nihas")] + +[node name="Camera" type="Camera2D" parent="."] +limit_left = -4096 +limit_top = -4096 +limit_right = 4096 +limit_bottom = 4096 +position_smoothing_speed = 200.0 +script = ExtResource("7_5jx81") + +[node name="Collision" type="CollisionPolygon2D" parent="."] +polygon = PackedVector2Array(0, -16, 32, 0, 0, 16, 0, 4, -4, 4, -8, 8, -8, -8, -4, -4, 0, -4) + +[node name="GUI" type="CanvasLayer" parent="."] + +[node name="Interface" type="Control" parent="GUI"] +z_index = 78 +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +mouse_filter = 2 + +[node name="MainRectangle" type="Polygon2D" parent="GUI/Interface"] +position = Vector2(34, 651) +polygon = PackedVector2Array(0, 0, 175, 0, 175, 50, 0, 50) + +[node name="InnerRectangle" type="Polygon2D" parent="GUI/Interface/MainRectangle"] +color = Color(0, 0, 0, 1) +polygon = PackedVector2Array(1, 1, 174, 1, 174, 49, 1, 49) + +[node name="ZeroLine" type="Line2D" parent="GUI/Interface/MainRectangle"] +position = Vector2(-34, -651) +points = PackedVector2Array(59, 651, 59, 701) +width = 1.0 + +[node name="TurboLine" type="Line2D" parent="GUI/Interface/MainRectangle"] +position = Vector2(66, -651) +points = PackedVector2Array(59, 651, 59, 701) +width = 1.0 + +[node name="SpeedLine" type="Line2D" parent="GUI/Interface"] +position = Vector2(59, 676) +points = PackedVector2Array(0, 0, 0, 0) +width = 48.0 +script = ExtResource("6_ckx3n") + +[node name="FuelCounter" type="Label" parent="GUI/Interface"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_left = 34.0 +offset_top = 625.0 +offset_right = -1071.0 +offset_bottom = -69.0 +grow_horizontal = 2 +grow_vertical = 2 +text = "Fuel: 1000/1000 units" +script = ExtResource("10_0lke7") + +[node name="AmmoCounter" type="Label" parent="GUI/Interface"] +layout_mode = 1 +anchors_preset = 3 +anchor_left = 1.0 +anchor_top = 1.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_left = -63.0 +offset_top = -42.0 +offset_right = -13.0 +offset_bottom = -16.0 +grow_horizontal = 0 +grow_vertical = 0 +text = "ammo" +horizontal_alignment = 2 +vertical_alignment = 2 +script = ExtResource("9_h1i5f") + +[node name="ShieldCounter" type="Label" parent="GUI/Interface"] +layout_mode = 0 +offset_left = 34.0 +offset_top = 580.0 +offset_right = 239.0 +offset_bottom = 606.0 +text = "Shield Capacity: 8 / 8 units" +script = ExtResource("10_2l5pr") + +[node name="HPCounter" type="Label" parent="GUI/Interface"] +layout_mode = 0 +offset_left = 34.0 +offset_top = 602.0 +offset_right = 209.0 +offset_bottom = 625.0 +text = "Hull Strength: 30 / 30 units" +script = ExtResource("11_ouonv") + +[node name="MoneyCounter" type="Label" parent="GUI/Interface"] +layout_mode = 0 +offset_left = 34.0 +offset_top = 558.0 +offset_right = 250.0 +offset_bottom = 584.0 +text = "Available Money: 1000 units" +script = ExtResource("11_8f548") + +[node name="PauseController" type="Control" parent="GUI/Interface"] +process_mode = 2 +visible = false +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("13_8y0ow") + +[node name="UnpauseButton" type="Button" parent="GUI/Interface/PauseController"] +layout_mode = 0 +offset_left = 311.0 +offset_top = 253.0 +offset_right = 982.0 +offset_bottom = 365.0 +mouse_filter = 1 +text = "Resume" + +[node name="ExitButton" type="Button" parent="GUI/Interface/PauseController"] +layout_mode = 0 +offset_left = 312.0 +offset_top = 378.0 +offset_right = 983.0 +offset_bottom = 492.0 +text = "Quit to main menu" + +[node name="Label" type="Label" parent="GUI/Interface/PauseController"] +layout_mode = 0 +offset_left = 413.0 +offset_top = 108.0 +offset_right = 881.0 +offset_bottom = 178.0 +text = "The game is paused." +label_settings = SubResource("LabelSettings_hkik3") + +[node name="VersionLabel" type="Label" parent="GUI/Interface"] +layout_mode = 1 +anchors_preset = 1 +anchor_left = 1.0 +anchor_right = 1.0 +offset_left = -153.0 +offset_bottom = 26.0 +grow_horizontal = 0 +text = "GammaCosmicRays version Ictar 1.1 unbuilt +This is a debug version for internal usage." +horizontal_alignment = 2 + +[node name="CanvasLayer" type="CanvasLayer" parent="."] +layer = 2 + +[node name="Control" type="Control" parent="CanvasLayer"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +mouse_filter = 2 + +[node name="Minimap" parent="CanvasLayer/Control" instance=ExtResource("14_o544g")] +layout_mode = 1 +offset_left = 543.0 +offset_top = 528.0 +offset_right = 543.0 +offset_bottom = 527.76 + +[connection signal="button_up" from="GUI/Interface/PauseController/UnpauseButton" to="GUI/Interface/PauseController" method="_on_unpause_button_button_up"] +[connection signal="button_up" from="GUI/Interface/PauseController/ExitButton" to="GUI/Interface/PauseController" method="_on_exit_button_button_up"] diff --git a/scenes/Minimap.tscn b/scenes/Minimap.tscn new file mode 100644 index 0000000..91f1051 --- /dev/null +++ b/scenes/Minimap.tscn @@ -0,0 +1,20 @@ +[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="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"] + +[node name="Minimap" type="Control"] +layout_mode = 3 +anchor_right = 0.15 +anchor_bottom = 0.267 +offset_bottom = -0.240021 +grow_horizontal = 2 +grow_vertical = 2 +mouse_filter = 2 +script = ExtResource("1_8abec") +MarkerPack = ExtResource("2_u2t3y") + +[node name="Sprite" type="Sprite2D" parent="."] +position = Vector2(96, 96) +texture = ExtResource("1_705ro") diff --git a/scenes/MinimapMarker.tscn b/scenes/MinimapMarker.tscn new file mode 100644 index 0000000..f8abfce --- /dev/null +++ b/scenes/MinimapMarker.tscn @@ -0,0 +1,31 @@ +[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="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"] + +[sub_resource type="SpriteFrames" id="SpriteFrames_7tbqy"] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": ExtResource("2_pfl45") +}, { +"duration": 1.0, +"texture": ExtResource("3_sgrhe") +}, { +"duration": 1.0, +"texture": ExtResource("4_4lyow") +}], +"loop": true, +"name": &"default", +"speed": 0.0 +}] + +[node name="MinimapMarker" type="Node2D"] +script = ExtResource("1_j37jj") + +[node name="MarkerSprite" type="AnimatedSprite2D" parent="."] +position = Vector2(82, 0) +sprite_frames = SubResource("SpriteFrames_7tbqy") +speed_scale = 0.0 diff --git a/scenes/Space.tscn b/scenes/Space.tscn new file mode 100644 index 0000000..3ed39b0 --- /dev/null +++ b/scenes/Space.tscn @@ -0,0 +1,90 @@ +[gd_scene load_steps=13 format=3 uid="uid://14k35mkjwi5i"] + +[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="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="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"] + +[sub_resource type="FastNoiseLite" id="FastNoiseLite_tgq2a"] +noise_type = 3 +frequency = 0.001 + +[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_43qve"] +width = 4096 +height = 4096 +seamless = true +color_ramp = ExtResource("10_ijadn") +noise = SubResource("FastNoiseLite_tgq2a") + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_s2aaw"] +shader = ExtResource("9_h8ucp") +shader_parameter/penis = SubResource("NoiseTexture2D_43qve") + +[node name="Space" type="Node2D"] +process_mode = 3 +script = ExtResource("1_ppaw3") + +[node name="MainShip" parent="." instance=ExtResource("1_6fvpc")] + +[node name="Stars" parent="." instance=ExtResource("3_jbyyq")] + +[node name="Projectiles" type="Node2D" parent="."] +process_mode = 1 +script = ExtResource("4_dtv2c") + +[node name="StarterBase" parent="." instance=ExtResource("5_bjt5p")] +position = Vector2(208, 5) +rotation = -3.14159 + +[node name="EnemyFaction" type="Node2D" parent="."] +process_mode = 1 +script = ExtResource("7_w8i61") + +[node name="DefaultShip" parent="EnemyFaction" instance=ExtResource("6_67746")] +position = Vector2(-600, 930) + +[node name="DefaultShip2" parent="EnemyFaction" instance=ExtResource("6_67746")] +position = Vector2(595, 956) + +[node name="DefaultShip3" parent="EnemyFaction" instance=ExtResource("6_67746")] +position = Vector2(-28, 1361) + +[node name="DefaultShip4" parent="EnemyFaction" instance=ExtResource("6_67746")] +position = Vector2(-588, -1151) + +[node name="DefaultShip5" parent="EnemyFaction" instance=ExtResource("6_67746")] +position = Vector2(46, -1625) + +[node name="DefaultShip6" parent="EnemyFaction" instance=ExtResource("6_67746")] +position = Vector2(639, -1166) + +[node name="DefaultShip7" parent="EnemyFaction" instance=ExtResource("6_67746")] +position = Vector2(-1195, -764) + +[node name="DefaultShip8" parent="EnemyFaction" instance=ExtResource("6_67746")] +position = Vector2(-1786, -202) + +[node name="DefaultShip9" parent="EnemyFaction" instance=ExtResource("6_67746")] +position = Vector2(-1254, 416) + +[node name="DefaultShip10" parent="EnemyFaction" instance=ExtResource("6_67746")] +position = Vector2(1201, -766) + +[node name="DefaultShip11" parent="EnemyFaction" instance=ExtResource("6_67746")] +position = Vector2(1877, -168) + +[node name="DefaultShip12" parent="EnemyFaction" instance=ExtResource("6_67746")] +position = Vector2(1212, 518) + +[node name="ColorRect" type="ColorRect" parent="."] +z_index = -20 +material = SubResource("ShaderMaterial_s2aaw") +offset_left = -4096.0 +offset_top = -4096.0 +offset_right = 4096.0 +offset_bottom = 4096.0 diff --git a/scenes/SpaceGradient.tres b/scenes/SpaceGradient.tres new file mode 100644 index 0000000..e27c724 --- /dev/null +++ b/scenes/SpaceGradient.tres @@ -0,0 +1,5 @@ +[gd_resource type="Gradient" format=3 uid="uid://c6bcjydbwm5id"] + +[resource] +offsets = PackedFloat32Array(0, 0.357724, 0.878049, 1) +colors = PackedColorArray(0.129412, 0, 0.129412, 1, 0, 0, 0, 1, 0, 0, 0.129412, 1, 0.0235294, 0.0784314, 0, 1) diff --git a/scenes/Star.tscn b/scenes/Star.tscn new file mode 100644 index 0000000..d8d2bfc --- /dev/null +++ b/scenes/Star.tscn @@ -0,0 +1,50 @@ +[gd_scene load_steps=11 format=3 uid="uid://kyuhwil8vq7n"] + +[ext_resource type="Texture2D" uid="uid://bf8treonq7va1" path="res://sprites/star/star1.png" id="1_g74du"] +[ext_resource type="Texture2D" uid="uid://dbl6rw04dnuho" path="res://sprites/star/star2.png" id="2_pxcya"] +[ext_resource type="Texture2D" uid="uid://vndhtc8ymg2k" path="res://sprites/star/star3.png" id="3_plj80"] +[ext_resource type="Texture2D" uid="uid://cays6dmt6ucv7" path="res://sprites/star/star4.png" id="4_21ld8"] +[ext_resource type="Texture2D" uid="uid://du274dr3lf2es" path="res://sprites/star/star5.png" id="5_pyjfw"] +[ext_resource type="Texture2D" uid="uid://bm8tx4w1irp7s" path="res://sprites/star/star6.png" id="6_uxgjf"] +[ext_resource type="Texture2D" uid="uid://jbcvgid8o5f6" path="res://sprites/star/star7.png" id="7_3kjtu"] +[ext_resource type="Texture2D" uid="uid://dgp48jj1knk1y" path="res://sprites/star/star8.png" id="8_5xmav"] +[ext_resource type="Script" path="res://scripts/Star.gd" id="9_dvpaw"] + +[sub_resource type="SpriteFrames" id="SpriteFrames_oggfj"] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": ExtResource("1_g74du") +}, { +"duration": 1.0, +"texture": ExtResource("2_pxcya") +}, { +"duration": 1.0, +"texture": ExtResource("3_plj80") +}, { +"duration": 1.0, +"texture": ExtResource("4_21ld8") +}, { +"duration": 1.0, +"texture": ExtResource("5_pyjfw") +}, { +"duration": 1.0, +"texture": ExtResource("6_uxgjf") +}, { +"duration": 1.0, +"texture": ExtResource("7_3kjtu") +}, { +"duration": 1.0, +"texture": ExtResource("8_5xmav") +}], +"loop": true, +"name": &"default", +"speed": 8.0 +}] + +[node name="Star" type="AnimatedSprite2D"] +self_modulate = Color(1, 1, 1, 0.501961) +z_index = -19 +sprite_frames = SubResource("SpriteFrames_oggfj") +autoplay = "default" +script = ExtResource("9_dvpaw") diff --git a/scenes/StarsController.tscn b/scenes/StarsController.tscn new file mode 100644 index 0000000..f40f39c --- /dev/null +++ b/scenes/StarsController.tscn @@ -0,0 +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="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") diff --git a/scenes/StarterBase.tscn b/scenes/StarterBase.tscn new file mode 100644 index 0000000..f193b29 --- /dev/null +++ b/scenes/StarterBase.tscn @@ -0,0 +1,57 @@ +[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="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"] + +[node name="StarterBase" type="Node2D"] +process_mode = 1 +script = ExtResource("1_5xhqy") + +[node name="Sprite" type="Sprite2D" parent="."] +rotation = -1.5708 +texture = ExtResource("1_3ssyj") + +[node name="BaseCollider" type="StaticBody2D" parent="."] +collision_layer = 2 +collision_mask = 5 +script = ExtResource("2_18w83") + +[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="BaseCollider"] +polygon = PackedVector2Array(129, -32, 129, 32, 256, 63, 225, 192, 192, 225, 67, 256, -67, 256, -192, 225, -225, 192, -256, 67, -256, -67, -225, -192, -192, -225, -67, -256, 67, -256, 192, -225, 225, -192, 256, -67, 256, -63) + +[node name="BaseColliderDetector" type="Area2D" parent="BaseCollider"] +collision_layer = 2 + +[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="BaseCollider/BaseColliderDetector"] +polygon = PackedVector2Array(129, -32, 129, 32, 256, 63, 256, 61, 131, 30, 131, -30, 256, -61, 256, -63) + +[node name="MenuCollider" type="Area2D" parent="."] +collision_layer = 8 +script = ExtResource("2_53766") +Menu = ExtResource("4_jlcsy") + +[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="MenuCollider"] +polygon = PackedVector2Array(129, 32, 256, 63, 256, -63, 129, -32) + +[node name="NPCBlocker" type="StaticBody2D" parent="."] +collision_layer = 16 + +[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="NPCBlocker"] +polygon = PackedVector2Array(129, 32, 256, 63, 256, -63, 129, -32) + +[node name="NPCRotator" type="Area2D" parent="."] +collision_layer = 16 +monitorable = false +script = ExtResource("5_kecih") + +[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="NPCRotator"] +polygon = PackedVector2Array(129, -32, 129, 32, 257, 63, 226, 193, 192, 226, 67, 257, -67, 257, -193, 226, -226, 193, -257, 67, -257, -67, -226, -193, -193, -226, -67, -257, 67, -257, 193, -226, 226, -193, 257, -67, 257, -63) + +[connection signal="body_entered" from="BaseCollider/BaseColliderDetector" to="MenuCollider" method="onbcbodyentered"] +[connection signal="body_entered" from="MenuCollider" to="MenuCollider" method="_on_body_entered"] +[connection signal="body_exited" from="MenuCollider" to="MenuCollider" method="_on_body_exited"] +[connection signal="body_entered" from="NPCRotator" to="NPCRotator" method="_on_body_entered"] diff --git a/scenes/engines/starterengine.tscn b/scenes/engines/starterengine.tscn new file mode 100644 index 0000000..701f4de --- /dev/null +++ b/scenes/engines/starterengine.tscn @@ -0,0 +1,81 @@ +[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="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"] + +[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] +point_count = 2 + +[sub_resource type="CurveTexture" id="CurveTexture_wagku"] +curve = SubResource("Curve_grs2w") + +[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_al11x"] +lifetime_randomness = 0.5 +emission_shape = 3 +emission_box_extents = Vector3(8, 1, 1) +particle_flag_disable_z = true +direction = Vector3(0, 1, 0) +spread = 15.0 +gravity = Vector3(0, 0, 0) +initial_velocity_min = 50.0 +initial_velocity_max = 100.0 +orbit_velocity_min = 0.0 +orbit_velocity_max = 0.0 +scale_min = 0.5 +scale_max = 2.0 +scale_curve = SubResource("CurveTexture_wagku") + +[sub_resource type="Curve" id="Curve_r1iqm"] +_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(1, 0), -1.7156, 0.0, 0, 0] +point_count = 2 + +[sub_resource type="CurveTexture" id="CurveTexture_ot3qw"] +curve = SubResource("Curve_r1iqm") + +[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_gd3um"] +lifetime_randomness = 0.5 +emission_shape = 1 +emission_sphere_radius = 1102.0 +particle_flag_disable_z = true +direction = Vector3(0, 1, 0) +spread = 0.0 +gravity = Vector3(0, 0, 0) +initial_velocity_min = 500.0 +initial_velocity_max = 600.0 +orbit_velocity_min = 0.0 +orbit_velocity_max = 0.0 +scale_min = 1.5 +scale_max = 1.5 +scale_curve = SubResource("CurveTexture_ot3qw") + +[node name="Engine" type="Node2D"] +script = ExtResource("1_jvcps") +SpeedAcceleration = 100.0 +RotationSpeed = 120 + +[node name="EngineSprite" type="Sprite2D" parent="."] +position = Vector2(-4, 0) +texture = ExtResource("2_mll00") + +[node name="EngineParticles" type="GPUParticles2D" parent="."] +position = Vector2(-8, 0) +rotation = 1.5708 +emitting = false +amount = 16 +process_material = SubResource("ParticleProcessMaterial_al11x") +fixed_fps = 50 +script = ExtResource("3_fxngd") + +[node name="TurboParticles" type="GPUParticles2D" parent="."] +rotation = 1.5708 +emitting = false +amount = 64 +process_material = SubResource("ParticleProcessMaterial_gd3um") +randomness = 0.5 +fixed_fps = 50 +local_coords = true +trail_enabled = true +script = ExtResource("4_f11x7") diff --git a/scenes/hulls/npchullt1.tscn b/scenes/hulls/npchullt1.tscn new file mode 100644 index 0000000..75ff1a8 --- /dev/null +++ b/scenes/hulls/npchullt1.tscn @@ -0,0 +1,12 @@ +[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="Texture2D" uid="uid://dbwvej0c5bl52" path="res://sprites/ship mk1.png" id="2_wlkiy"] + +[node name="Hull" type="Node2D"] +script = ExtResource("1_x0f7x") +MaxHP = 15 + +[node name="HullSprite" type="Sprite2D" parent="."] +position = Vector2(16, 0) +texture = ExtResource("2_wlkiy") diff --git a/scenes/hulls/starterhull.tscn b/scenes/hulls/starterhull.tscn new file mode 100644 index 0000000..ec1e461 --- /dev/null +++ b/scenes/hulls/starterhull.tscn @@ -0,0 +1,12 @@ +[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="Texture2D" uid="uid://dbwvej0c5bl52" path="res://sprites/ship mk1.png" id="2_tvpkh"] + +[node name="Hull" type="Node2D"] +script = ExtResource("1_em4j0") +MaxFuel = 6000 + +[node name="HullSprite" type="Sprite2D" parent="."] +position = Vector2(16, 0) +texture = ExtResource("2_tvpkh") diff --git a/scenes/menus/BuyMenuHealth.gd b/scenes/menus/BuyMenuHealth.gd new file mode 100644 index 0000000..09420af --- /dev/null +++ b/scenes/menus/BuyMenuHealth.gd @@ -0,0 +1,12 @@ +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 new file mode 100644 index 0000000..87aca89 --- /dev/null +++ b/scenes/menus/BuyMenuLaser.gd @@ -0,0 +1,29 @@ +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 new file mode 100644 index 0000000..919dcb1 --- /dev/null +++ b/scenes/menus/BuyMenuRockets.gd @@ -0,0 +1,16 @@ +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 new file mode 100644 index 0000000..40cd173 --- /dev/null +++ b/scenes/menus/BuyMenuTurbo.gd @@ -0,0 +1,9 @@ +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/OptionsColors.gd b/scenes/menus/OptionsColors.gd new file mode 100644 index 0000000..7f24d6c --- /dev/null +++ b/scenes/menus/OptionsColors.gd @@ -0,0 +1,4 @@ +extends MenuDefaultButton + +func action(): + get_tree().current_scene.recolor() diff --git a/scenes/menus/ResetMS.gd b/scenes/menus/ResetMS.gd new file mode 100644 index 0000000..c9aba46 --- /dev/null +++ b/scenes/menus/ResetMS.gd @@ -0,0 +1,4 @@ +extends MenuDefaultButton + +func action(): + PlayerShip.destroy() diff --git a/scenes/menus/StarterBaseMenu.tscn b/scenes/menus/StarterBaseMenu.tscn new file mode 100644 index 0000000..d855176 --- /dev/null +++ b/scenes/menus/StarterBaseMenu.tscn @@ -0,0 +1,364 @@ +[gd_scene load_steps=9 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"] + +[sub_resource type="LabelSettings" id="LabelSettings_7bj0u"] +font_size = 14 + +[node name="StarterBaseMenu" type="Control"] +process_mode = 1 +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +mouse_filter = 2 + +[node name="BuyMenu" type="NinePatchRect" parent="."] +layout_mode = 1 +anchors_preset = -1 +offset_left = 295.0 +offset_top = 92.0 +offset_right = 551.0 +offset_bottom = 348.0 +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 + +[node name="Option1" type="NinePatchRect" parent="BuyMenu" 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 = -0.0480001 +offset_right = 0.0479889 +offset_bottom = -0.0160027 +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("2_0mgmw") +Price = 50.0 +Clickable = NodePath("TextureButton") + +[node name="TextureButton" type="TextureButton" parent="BuyMenu/Option1"] +layout_mode = 1 +anchors_preset = -1 +anchor_right = 1.0 +anchor_bottom = 1.0 + +[node name="Label" type="Label" parent="BuyMenu/Option1"] +layout_mode = 0 +offset_right = 251.0 +offset_bottom = 52.0 +text = "50 Money Units >> 1k Fuel Units +No refund" +label_settings = SubResource("LabelSettings_7bj0u") +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="Option2" type="NinePatchRect" parent="BuyMenu" 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 = 69.952 +offset_right = 0.0480042 +offset_bottom = 69.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("3_ciur0") +Price = 2.0 +Clickable = NodePath("TextureButton") + +[node name="TextureButton" type="TextureButton" parent="BuyMenu/Option2"] +layout_mode = 1 +anchors_preset = -1 +anchor_right = 1.0 +anchor_bottom = 1.0 + +[node name="Label" type="Label" parent="BuyMenu/Option2"] +layout_mode = 0 +offset_right = 251.0 +offset_bottom = 52.0 +text = "2 Money Units >> 1 Hull Strength +Up to a maximum" +label_settings = SubResource("LabelSettings_7bj0u") +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="Option3" type="NinePatchRect" parent="BuyMenu" 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 = 137.952 +offset_right = 0.0480042 +offset_bottom = 137.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("4_aae7g") +Price = 20.0 +Clickable = NodePath("TextureButton") + +[node name="TextureButton" type="TextureButton" parent="BuyMenu/Option3"] +layout_mode = 1 +anchors_preset = -1 +anchor_right = 1.0 +anchor_bottom = 1.0 + +[node name="Label" type="Label" parent="BuyMenu/Option3"] +layout_mode = 0 +offset_right = 251.0 +offset_bottom = 52.0 +text = "20 Money Units >> 5 Rockets +Refund if too many" +label_settings = SubResource("LabelSettings_7bj0u") +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="Option4" type="NinePatchRect" parent="BuyMenu" 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 = 199.952 +offset_right = -155.952 +offset_bottom = 199.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("5_45gom") +AddedWeapon = "SingleRocketMk1" +Slot = "secondary" +Position = Vector2(16, 0) +Price = 200.0 +Clickable = NodePath("TextureButton") + +[node name="TextureButton" type="TextureButton" parent="BuyMenu/Option4"] +layout_mode = 1 +anchors_preset = -1 +anchor_right = 1.0 +anchor_bottom = 1.0 + +[node name="Label" type="Label" parent="BuyMenu/Option4"] +layout_mode = 0 +offset_right = 96.0 +offset_bottom = 52.0 +text = "200 MU >> Sin +gleRocketMk1" +label_settings = SubResource("LabelSettings_7bj0u") +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="Option5" type="NinePatchRect" parent="BuyMenu" 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 = 96.952 +offset_top = 199.952 +offset_right = -59.952 +offset_bottom = 199.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("5_45gom") +AddedWeapon = "DoubleLaserMk1" +Position = Vector2(8, 0) +Price = 300.0 +Clickable = NodePath("TextureButton") + +[node name="TextureButton" type="TextureButton" parent="BuyMenu/Option5"] +layout_mode = 1 +anchors_preset = -1 +anchor_right = 1.0 +anchor_bottom = 1.0 + +[node name="Label" type="Label" parent="BuyMenu/Option5"] +layout_mode = 0 +offset_right = 95.0 +offset_bottom = 52.0 +text = "300 MU >> Do +ubleLaserMk1" +label_settings = SubResource("LabelSettings_7bj0u") +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="Option6" type="NinePatchRect" parent="BuyMenu" 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 = 193.952 +offset_top = 199.952 +offset_right = 0.0480042 +offset_bottom = 199.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("5_45gom") +AddedWeapon = "SingleLaserMk1" +Position = Vector2(8, 0) +Clickable = NodePath("TextureButton") + +[node name="TextureButton" type="TextureButton" parent="BuyMenu/Option6"] +layout_mode = 1 +anchors_preset = -1 +anchor_right = 1.0 +anchor_bottom = 1.0 + +[node name="Label" type="Label" parent="BuyMenu/Option6"] +layout_mode = 0 +offset_right = 58.0 +offset_bottom = 52.0 +text = "SingleLa +serMk1" +label_settings = SubResource("LabelSettings_7bj0u") +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="OptionsMenu" type="NinePatchRect" parent="."] +layout_mode = 1 +anchors_preset = -1 +offset_left = 695.0 +offset_top = 91.0 +offset_right = 951.0 +offset_bottom = 347.0 +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 + +[node name="Colors" 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 = -0.0480001 +offset_right = 0.0479889 +offset_bottom = -0.0160027 +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("7_m7aa1") +Clickable = NodePath("TextureButton") + +[node name="TextureButton" type="TextureButton" parent="OptionsMenu/Colors"] +layout_mode = 1 +anchors_preset = -1 +anchor_right = 1.0 +anchor_bottom = 1.0 + +[node name="Label" type="Label" parent="OptionsMenu/Colors"] +layout_mode = 0 +offset_right = 251.0 +offset_bottom = 52.0 +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 new file mode 100644 index 0000000..679b910 --- /dev/null +++ b/scenes/npcships/NPCShipDefault.tscn @@ -0,0 +1,75 @@ +[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="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"] +[ext_resource type="PackedScene" uid="uid://20171x3gmn1j" path="res://scenes/engines/starterengine.tscn" id="4_tguk3"] +[ext_resource type="PackedScene" uid="uid://dse2xxx501xuj" path="res://scenes/weapons/presets/NPCSingleLaserMk1.tscn" id="6_wnekw"] + +[sub_resource type="CircleShape2D" id="CircleShape2D_k2lwx"] +radius = 64.0 + +[sub_resource type="LabelSettings" id="LabelSettings_21pok"] +font_size = 12 + +[node name="DefaultShip" type="CharacterBody2D" node_paths=PackedStringArray("DestinationTimer")] +process_mode = 1 +collision_mask = 19 +input_pickable = true +script = ExtResource("1_s20nu") +DestinationTimer = NodePath("DestinationTimer") +Bounty = ExtResource("2_6fdps") + +[node name="Shield" parent="." instance=ExtResource("3_47apr")] + +[node name="Hull" parent="." instance=ExtResource("4_1ne0s")] + +[node name="Engine" parent="." instance=ExtResource("4_tguk3")] + +[node name="Collision" type="CollisionPolygon2D" parent="."] +polygon = PackedVector2Array(0, -16, 32, 0, 0, 16, 0, 4, -4, 4, -8, 8, -8, -8, -4, -4, 0, -4) + +[node name="WeaponSlot" type="Node2D" parent="."] + +[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 +autostart = true + +[node name="TargetSnap" type="Area2D" parent="."] + +[node name="CollisionShape2D" type="CollisionShape2D" parent="TargetSnap"] +position = Vector2(16, 0) +shape = SubResource("CircleShape2D_k2lwx") + +[node name="RemoteTransform2D" type="RemoteTransform2D" parent="."] +remote_path = NodePath("../Zalupa/ZalupaTwo") +update_rotation = false +update_scale = false + +[node name="Zalupa" type="Node" parent="."] + +[node name="ZalupaTwo" type="Node2D" parent="Zalupa"] + +[node name="Health" type="Label" parent="Zalupa/ZalupaTwo"] +layout_direction = 1 +offset_left = -43.0 +offset_top = -45.0 +offset_right = 43.0 +offset_bottom = -25.0 +size_flags_horizontal = 4 +text = "7-8 HP + 7-8 SC" +label_settings = SubResource("LabelSettings_21pok") +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="DebugLabel" type="Label" parent="."] +visible = false +offset_left = -11.0 +offset_top = -38.0 +offset_right = 29.0 +offset_bottom = -15.0 diff --git a/scenes/projectiles/Laser.tscn b/scenes/projectiles/Laser.tscn new file mode 100644 index 0000000..30aeb3a --- /dev/null +++ b/scenes/projectiles/Laser.tscn @@ -0,0 +1,24 @@ +[gd_scene load_steps=3 format=3 uid="uid://djmoij5kuou3j"] + +[ext_resource type="Script" path="res://modules/projectile.gd" id="1_plpqo"] + +[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="LaserBody" type="Line2D" parent="."] +points = PackedVector2Array(0, 0, 8, 0) +width = 1.0 + +[node name="Collision" type="Area2D" parent="."] +collision_layer = 4 +collision_mask = 3 + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Collision"] +position = Vector2(4, 0) +rotation = -1.5708 +shape = SubResource("RectangleShape2D_mo2if") diff --git a/scenes/projectiles/Rocket.tscn b/scenes/projectiles/Rocket.tscn new file mode 100644 index 0000000..a9c103a --- /dev/null +++ b/scenes/projectiles/Rocket.tscn @@ -0,0 +1,52 @@ +[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="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"] +[ext_resource type="Texture2D" uid="uid://3nxmmp826b1s" path="res://sprites/rocket mk1 4.png" id="5_xas58"] + +[sub_resource type="SpriteFrames" id="SpriteFrames_pnkh5"] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": ExtResource("2_g3qcb") +}, { +"duration": 1.0, +"texture": ExtResource("3_q1u7q") +}, { +"duration": 1.0, +"texture": ExtResource("4_f2hwy") +}, { +"duration": 1.0, +"texture": ExtResource("5_xas58") +}], +"loop": true, +"name": &"default", +"speed": 16.0 +}] + +[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_65eo7"] +radius = 2.0 +height = 12.0 + +[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") + +[node name="RocketSprite" type="AnimatedSprite2D" parent="."] +position = Vector2(8, 0) +sprite_frames = SubResource("SpriteFrames_pnkh5") +frame_progress = 0.740876 + +[node name="Collision" type="Area2D" parent="."] +collision_layer = 4 +collision_mask = 3 + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Collision"] +position = Vector2(10, 0) +rotation = -1.5708 +shape = SubResource("CapsuleShape2D_65eo7") diff --git a/scenes/shields/npcshield.tscn b/scenes/shields/npcshield.tscn new file mode 100644 index 0000000..1aa4f86 --- /dev/null +++ b/scenes/shields/npcshield.tscn @@ -0,0 +1,17 @@ +[gd_scene load_steps=2 format=3 uid="uid://cyskycafymwx"] + +[ext_resource type="Script" path="res://scripts/MSShield.gd" id="1_3t0v2"] + +[node name="Shield" type="Node2D" node_paths=PackedStringArray("RechargeTimer", "LaserTimer")] +script = ExtResource("1_3t0v2") +MaxShieldCapacity = 5 +RechargeTimer = NodePath("Timer") +LaserTimer = NodePath("Timer2") + +[node name="Timer2" type="Timer" parent="."] +wait_time = 5.0 +one_shot = true + +[node name="Timer" type="Timer" parent="."] +wait_time = 5.0 +one_shot = true diff --git a/scenes/shields/startershield.tscn b/scenes/shields/startershield.tscn new file mode 100644 index 0000000..77c4798 --- /dev/null +++ b/scenes/shields/startershield.tscn @@ -0,0 +1,19 @@ +[gd_scene load_steps=2 format=3 uid="uid://66m5gj2ufsop"] + +[ext_resource type="Script" path="res://scripts/MSShield.gd" id="1_6qr86"] + +[node name="Shield" type="Node2D" node_paths=PackedStringArray("RechargeTimer", "LaserTimer")] +script = ExtResource("1_6qr86") +MaxShieldCapacity = 10 +ShieldChargeRate = 2.0 +RechargeTimer = NodePath("Timer") +LaserTimer = NodePath("Timer2") +LaserChargeRate = 40.0 + +[node name="Timer2" type="Timer" parent="."] +wait_time = 5.0 +one_shot = true + +[node name="Timer" type="Timer" parent="."] +wait_time = 5.0 +one_shot = true diff --git a/scenes/weapons/DoubleLaser.tscn b/scenes/weapons/DoubleLaser.tscn new file mode 100644 index 0000000..6ce90bc --- /dev/null +++ b/scenes/weapons/DoubleLaser.tscn @@ -0,0 +1,31 @@ +[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="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")] +script = ExtResource("1_u8yjv") +ShootingProjectile = ExtResource("2_cewjf") +ShootingTimer = NodePath("ShootingTimer") +SpawnerPoints = [NodePath("SpawnerSprite1/Spawner1"), NodePath("SpawnerSprite2/Spawner2")] + +[node name="SpawnerSprite1" type="Sprite2D" parent="."] +position = Vector2(4, -12) +rotation = 0.0174533 +texture = ExtResource("3_14fq6") + +[node name="Spawner1" type="Node2D" parent="SpawnerSprite1"] +position = Vector2(4, 0) + +[node name="SpawnerSprite2" type="Sprite2D" parent="."] +position = Vector2(4, 12) +rotation = -0.0174533 +texture = ExtResource("3_14fq6") + +[node name="Spawner2" type="Node2D" parent="SpawnerSprite2"] +position = Vector2(4, 0) + +[node name="ShootingTimer" type="Timer" parent="."] +wait_time = 0.2 +one_shot = true diff --git a/scenes/weapons/SingleLaser.tscn b/scenes/weapons/SingleLaser.tscn new file mode 100644 index 0000000..acbef6a --- /dev/null +++ b/scenes/weapons/SingleLaser.tscn @@ -0,0 +1,22 @@ +[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="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")] +script = ExtResource("1_4ig05") +ShootingProjectile = ExtResource("2_w1ina") +Spread = 5.0 +ShootingTimer = NodePath("ShootingTimer") +SpawnerPoints = [NodePath("Spawner")] + +[node name="ShootingTimer" type="Timer" parent="."] +wait_time = 0.25 +one_shot = true + +[node name="SpawnerSprite" type="Sprite2D" parent="."] +texture = ExtResource("2_7vlpw") + +[node name="Spawner" type="Node2D" parent="."] +position = Vector2(4, 0) diff --git a/scenes/weapons/presets/DoubleLaserMk1.tscn b/scenes/weapons/presets/DoubleLaserMk1.tscn new file mode 100644 index 0000000..b475c63 --- /dev/null +++ b/scenes/weapons/presets/DoubleLaserMk1.tscn @@ -0,0 +1,33 @@ +[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="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")] +script = ExtResource("1_ugbl6") +ShootingProjectile = ExtResource("2_b52h8") +AmmoType = "Laser Energy" +AmmoConsumption = 2.0 +ShootingTimer = NodePath("ShootingTimer") +SpawnerPoints = [NodePath("SpawnerSprite1/Spawner1"), NodePath("SpawnerSprite2/Spawner2")] + +[node name="SpawnerSprite1" type="Sprite2D" parent="."] +position = Vector2(4, -12) +rotation = 0.0174533 +texture = ExtResource("3_ahhl5") + +[node name="Spawner1" type="Node2D" parent="SpawnerSprite1"] +position = Vector2(4, 0) + +[node name="SpawnerSprite2" type="Sprite2D" parent="."] +position = Vector2(4, 12) +rotation = -0.0174533 +texture = ExtResource("3_ahhl5") + +[node name="Spawner2" type="Node2D" parent="SpawnerSprite2"] +position = Vector2(4, 0) + +[node name="ShootingTimer" type="Timer" parent="."] +wait_time = 0.15 +one_shot = true diff --git a/scenes/weapons/presets/NPCSingleLaserMk1.tscn b/scenes/weapons/presets/NPCSingleLaserMk1.tscn new file mode 100644 index 0000000..2fe4a95 --- /dev/null +++ b/scenes/weapons/presets/NPCSingleLaserMk1.tscn @@ -0,0 +1,22 @@ +[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="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")] +script = ExtResource("1_6r7e6") +ShootingProjectile = ExtResource("2_8akh2") +Spread = 3.0 +ShootingTimer = NodePath("ShootingTimer") +SpawnerPoints = [NodePath("Spawner")] + +[node name="ShootingTimer" type="Timer" parent="."] +wait_time = 0.25 +one_shot = true + +[node name="SpawnerSprite" type="Sprite2D" parent="."] +texture = ExtResource("3_ncnas") + +[node name="Spawner" type="Node2D" parent="."] +position = Vector2(4, 0) diff --git a/scenes/weapons/presets/SingleLaserMk1.tscn b/scenes/weapons/presets/SingleLaserMk1.tscn new file mode 100644 index 0000000..532d13a --- /dev/null +++ b/scenes/weapons/presets/SingleLaserMk1.tscn @@ -0,0 +1,24 @@ +[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="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="ShootingTimer" type="Timer" parent="."] +wait_time = 0.25 +one_shot = true + +[node name="SpawnerSprite" type="Sprite2D" parent="."] +texture = ExtResource("3_n1sx7") + +[node name="Spawner" type="Node2D" parent="."] +position = Vector2(4, 0) diff --git a/scenes/weapons/presets/SingleRocketMk1.tscn b/scenes/weapons/presets/SingleRocketMk1.tscn new file mode 100644 index 0000000..b3c6cc0 --- /dev/null +++ b/scenes/weapons/presets/SingleRocketMk1.tscn @@ -0,0 +1,23 @@ +[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="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")] +script = ExtResource("1_wdpx2") +ShootingProjectile = ExtResource("2_fypwx") +AmmoType = "Rockets" +AmmoConsumption = 1.0 +ShootingTimer = NodePath("ShootingTimer") +SpawnerPoints = [NodePath("Spawner")] + +[node name="ShootingTimer" type="Timer" parent="."] +wait_time = 0.5 +one_shot = true + +[node name="SpawnerSprite" type="Sprite2D" parent="."] +texture = ExtResource("3_7gexv") + +[node name="Spawner" type="Node2D" parent="."] +position = Vector2(4, 0) diff --git a/scripts/AmmoCounter.gd b/scripts/AmmoCounter.gd new file mode 100644 index 0000000..2dee31b --- /dev/null +++ b/scripts/AmmoCounter.gd @@ -0,0 +1,6 @@ +extends Label + +@onready var Hull = $"../../../Hull" + +func _process(_delta): + text = str(Hull.Ammunition) diff --git a/scripts/BaseCollider.gd b/scripts/BaseCollider.gd new file mode 100644 index 0000000..2c99065 --- /dev/null +++ b/scripts/BaseCollider.gd @@ -0,0 +1,3 @@ +extends StaticBody2D + +var Fraction = "none" diff --git a/scripts/BaseNPCRotator.gd b/scripts/BaseNPCRotator.gd new file mode 100644 index 0000000..08496a0 --- /dev/null +++ b/scripts/BaseNPCRotator.gd @@ -0,0 +1,5 @@ +extends Area2D + +func _on_body_entered(body): + if body is NPCShip: + body.switchdestination() diff --git a/scripts/Bounty.gd b/scripts/Bounty.gd new file mode 100644 index 0000000..566b8b7 --- /dev/null +++ b/scripts/Bounty.gd @@ -0,0 +1,10 @@ +extends Area2D + +@export var Amount: float = 20 + +@onready var Text = $Label + +func _on_body_entered(body): + if body is MainShip: + body.Money += Amount + queue_free() diff --git a/scripts/BuyMenuButton.gd b/scripts/BuyMenuButton.gd new file mode 100644 index 0000000..5d52cab --- /dev/null +++ b/scripts/BuyMenuButton.gd @@ -0,0 +1,20 @@ +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 new file mode 100644 index 0000000..2470794 --- /dev/null +++ b/scripts/CameraTweaks.gd @@ -0,0 +1,12 @@ +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 new file mode 100644 index 0000000..8960a24 --- /dev/null +++ b/scripts/FactionRecoloring.gd @@ -0,0 +1,8 @@ +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 new file mode 100644 index 0000000..9ec35bf --- /dev/null +++ b/scripts/FuelCounter.gd @@ -0,0 +1,6 @@ +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 new file mode 100644 index 0000000..f7dbe01 --- /dev/null +++ b/scripts/HPCounter.gd @@ -0,0 +1,6 @@ +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 new file mode 100644 index 0000000..7fad4aa --- /dev/null +++ b/scripts/MSEngine.gd @@ -0,0 +1,60 @@ +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 new file mode 100644 index 0000000..a23be6e --- /dev/null +++ b/scripts/MSEngineParticles.gd @@ -0,0 +1,8 @@ +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 new file mode 100644 index 0000000..c617247 --- /dev/null +++ b/scripts/MSHull.gd @@ -0,0 +1,21 @@ +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 new file mode 100644 index 0000000..4ccbc43 --- /dev/null +++ b/scripts/MSShield.gd @@ -0,0 +1,44 @@ +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 new file mode 100644 index 0000000..df345c6 --- /dev/null +++ b/scripts/MainShipScript.gd @@ -0,0 +1,28 @@ +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 new file mode 100644 index 0000000..e28564f --- /dev/null +++ b/scripts/MenuButton.gd @@ -0,0 +1,16 @@ +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 new file mode 100644 index 0000000..5de94b8 --- /dev/null +++ b/scripts/Minimap.gd @@ -0,0 +1,18 @@ +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 new file mode 100644 index 0000000..51970b2 --- /dev/null +++ b/scripts/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 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 new file mode 100644 index 0000000..793ec74 --- /dev/null +++ b/scripts/MoneyCounter.gd @@ -0,0 +1,6 @@ +extends Label + +@onready var MS = $"../../.." + +func _process(_delta): + text = "Available Money: {money} units".format({"money":MS.Money}) diff --git a/scripts/PlayerPauseController.gd b/scripts/PlayerPauseController.gd new file mode 100644 index 0000000..081a80d --- /dev/null +++ b/scripts/PlayerPauseController.gd @@ -0,0 +1,11 @@ +extends Control + +@onready var MainShip = $"../../.." + +func _on_unpause_button_button_up(): + get_tree().current_scene.unpause() + + +func _on_exit_button_button_up(): + get_tree().current_scene.unpause() + get_tree().change_scene_to_file("res://scenes/MainMenu.tscn") diff --git a/scripts/ProjectilesContainer.gd b/scripts/ProjectilesContainer.gd new file mode 100644 index 0000000..a599f3d --- /dev/null +++ b/scripts/ProjectilesContainer.gd @@ -0,0 +1,8 @@ +extends Node2D + +class_name ProjectileContainer + +static var Instance : ProjectileContainer + +func _ready(): + Instance = self diff --git a/scripts/ShieldCounter.gd b/scripts/ShieldCounter.gd new file mode 100644 index 0000000..f45b6d4 --- /dev/null +++ b/scripts/ShieldCounter.gd @@ -0,0 +1,6 @@ +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 new file mode 100644 index 0000000..d037943 --- /dev/null +++ b/scripts/Space.gd @@ -0,0 +1,67 @@ +extends Node2D + +var CanTarget = [] + +var WeaponDict = { + "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 + +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 + +func addtargetlist(body : Node2D): + if !CanTarget.has(body): + CanTarget.append(body) + +func removetargetlist(body : Node2D): + if CanTarget.has(body): + CanTarget.erase(body) + +func _process(_delta): + if Input.is_action_just_released("pause"): + if get_tree().paused: + unpause() + else: + pause() + +func pause(): + get_tree().paused = true + Player.PauseController.visible = true + +func unpause(): + get_tree().paused = false + Player.PauseController.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 diff --git a/scripts/SpeedLine.gd b/scripts/SpeedLine.gd new file mode 100644 index 0000000..0b708f3 --- /dev/null +++ b/scripts/SpeedLine.gd @@ -0,0 +1,8 @@ +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/Star.gd b/scripts/Star.gd new file mode 100644 index 0000000..bae04fe --- /dev/null +++ b/scripts/Star.gd @@ -0,0 +1,12 @@ +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) + frame = randi_range(0, 7) + scale = Vector2(Size, Size) + speed_scale = randf_range(0, 2) + var Colors = [Color.LIGHT_BLUE, Color.WHITE, Color.LIGHT_GOLDENROD, Color.YELLOW, Color.ORANGE, Color.ORANGE_RED, Color.RED] + modulate = Colors[randi_range(0, 6)] diff --git a/scripts/StarsGeneration.gd b/scripts/StarsGeneration.gd new file mode 100644 index 0000000..ba8192a --- /dev/null +++ b/scripts/StarsGeneration.gd @@ -0,0 +1,12 @@ +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 new file mode 100644 index 0000000..8296a63 --- /dev/null +++ b/scripts/StarterBase.gd @@ -0,0 +1,7 @@ +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 new file mode 100644 index 0000000..6d13b94 --- /dev/null +++ b/scripts/StarterBaseMenu.gd @@ -0,0 +1,24 @@ +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 new file mode 100644 index 0000000..14304c7 --- /dev/null +++ b/scripts/TurboParticles.gd @@ -0,0 +1,7 @@ +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/projectiles/Rocket.gd b/scripts/projectiles/Rocket.gd new file mode 100644 index 0000000..231be04 --- /dev/null +++ b/scripts/projectiles/Rocket.gd @@ -0,0 +1,12 @@ +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() + diff --git a/scripts/saveload.gd b/scripts/saveload.gd new file mode 100644 index 0000000..1aa6a08 --- /dev/null +++ b/scripts/saveload.gd @@ -0,0 +1,62 @@ +extends Node + +class_name Game + +static var gameversion = "Ictar 1.1" + +static func profile_create(profile_name): + var path = "user://"+profile_name+".cosmic" + if not FileAccess.file_exists(path): + var profile_meta = { + 'hash' : {}, + 'meta' : { + 'created_in_version' : gameversion, + 'creation_date' : Time.get_datetime_string_from_system(), + 'last_version' : gameversion, + 'last_updated' : Time.get_datetime_string_from_system(), + 'profile_name' : profile_name, + 'legit' : true + } + } + var profile_meta_keys = profile_meta['meta'].keys() + for i in range(len(profile_meta_keys)): + if profile_meta_keys[i][0] == "_": + profile_meta_keys.remove_at(i) + for i in range(len(profile_meta_keys)): + profile_meta['hash'][i] = str(profile_meta['meta'][profile_meta_keys[i]]).sha256_buffer().hex_encode() + var file = FileAccess.open(path, FileAccess.WRITE) + var json_string = JSON.stringify(profile_meta, "\t") + file.store_string(json_string) + else: + profile_save(profile_name, "menu") + +static func profile_save(profile_name, _gamestate): + var path = "user://"+profile_name+".cosmic" + if not FileAccess.file_exists(path): + profile_create(profile_name) + return + var profile_meta = profile_load(profile_name) + profile_meta['meta']['lastversion'] = gameversion + profile_meta['meta']['lastupdated'] = Time.get_datetime_string_from_system() + var profile_meta_keys = profile_meta['meta'].keys() + for i in range(len(profile_meta_keys)): + if profile_meta_keys[i][0] == "_": + profile_meta_keys.remove_at(i) + for i in range(len(profile_meta_keys)): + profile_meta['hash'][i] = str(profile_meta['meta'][profile_meta_keys[i]]).sha256_buffer().hex_encode() + var file = FileAccess.open(path, FileAccess.WRITE) + var json_string = JSON.stringify(profile_meta, "\t") + file.store_string(json_string) + + +static func profile_load(profile_name): + var path = "user://"+profile_name+".cosmic" + if not FileAccess.file_exists(path): + return + var file = FileAccess.open(path, FileAccess.READ) + var string = file.get_as_text() + var profile_meta = JSON.parse_string(string) + for meta in profile_meta: + print(meta, ": ", profile_meta[meta]) + print(profile_meta[meta].keys()) + return profile_meta