diff --git a/scenes/Minimap.tscn b/scenes/Minimap.tscn index 97f2e5b..d38cf87 100644 --- a/scenes/Minimap.tscn +++ b/scenes/Minimap.tscn @@ -1,20 +1,21 @@ [gd_scene load_steps=4 format=3 uid="uid://dsmwg1rxedi3x"] -[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="Script" path="res://scripts/Ship/minimap.gd" id="1_l4bpl"] [ext_resource type="PackedScene" uid="uid://c7iafvpoopwc0" path="res://scenes/MinimapMarker.tscn" id="2_u2t3y"] +[ext_resource type="Texture2D" uid="uid://5gkjqkiiiggg" path="res://sprites/Minimap/minimap_back.png" id="3_jpxtx"] [node name="Minimap" type="Control"] layout_mode = 3 -anchor_right = 0.15 -anchor_bottom = 0.267 -offset_bottom = -0.240021 +anchor_right = 0.187 +anchor_bottom = 0.333 +offset_right = 0.639984 +offset_bottom = 0.23999 grow_horizontal = 2 grow_vertical = 2 mouse_filter = 2 -script = ExtResource("1_8abec") +script = ExtResource("1_l4bpl") marker = ExtResource("2_u2t3y") [node name="Sprite" type="Sprite2D" parent="."] -position = Vector2(96, 96) -texture = ExtResource("1_705ro") +position = Vector2(120, 120) +texture = ExtResource("3_jpxtx") diff --git a/scenes/MinimapMarker.tscn b/scenes/MinimapMarker.tscn index 56e70ff..ac64c1d 100644 --- a/scenes/MinimapMarker.tscn +++ b/scenes/MinimapMarker.tscn @@ -1,25 +1,25 @@ [gd_scene load_steps=7 format=3 uid="uid://c7iafvpoopwc0"] -[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"] -[ext_resource type="Texture2D" uid="uid://de34fc1qbeajo" path="res://sprites/minimapquest.png" id="5_tj884"] +[ext_resource type="Script" path="res://scripts/Ship/minimap_marker.gd" id="1_oa2nn"] +[ext_resource type="Texture2D" uid="uid://bchjqn3y7ne64" path="res://sprites/Minimap/ship_marker.png" id="2_s6imu"] +[ext_resource type="Texture2D" uid="uid://ct42eokncdaho" path="res://sprites/Minimap/base_marker.png" id="3_xt68o"] +[ext_resource type="Texture2D" uid="uid://dn2cooyrbr1sh" path="res://sprites/Minimap/spinot_marker.png" id="4_araym"] +[ext_resource type="Texture2D" uid="uid://b8my0ci3s8e5a" path="res://sprites/Minimap/quest_marker.png" id="5_0jfap"] [sub_resource type="SpriteFrames" id="SpriteFrames_7tbqy"] animations = [{ "frames": [{ "duration": 1.0, -"texture": ExtResource("2_pfl45") +"texture": ExtResource("2_s6imu") }, { "duration": 1.0, -"texture": ExtResource("3_sgrhe") +"texture": ExtResource("3_xt68o") }, { "duration": 1.0, -"texture": ExtResource("4_4lyow") +"texture": ExtResource("4_araym") }, { "duration": 1.0, -"texture": ExtResource("5_tj884") +"texture": ExtResource("5_0jfap") }], "loop": true, "name": &"default", @@ -27,9 +27,9 @@ animations = [{ }] [node name="MinimapMarker" type="Node2D"] -script = ExtResource("1_j37jj") +script = ExtResource("1_oa2nn") [node name="MarkerSprite" type="AnimatedSprite2D" parent="."] -position = Vector2(82, 0) +position = Vector2(104, 0) sprite_frames = SubResource("SpriteFrames_7tbqy") speed_scale = 0.0 diff --git a/scenes/Ships/player_ship.tscn b/scenes/Ships/player_ship.tscn index a85cf9c..f431f6f 100644 --- a/scenes/Ships/player_ship.tscn +++ b/scenes/Ships/player_ship.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=15 format=3 uid="uid://dok3i8u5t1ka4"] +[gd_scene load_steps=16 format=3 uid="uid://dok3i8u5t1ka4"] [ext_resource type="Script" path="res://scripts/Ship/player_ship.gd" id="2_oqdd7"] [ext_resource type="Script" path="res://scripts/Ship/player_input_controller.gd" id="3_0e84a"] @@ -9,6 +9,7 @@ [ext_resource type="Script" path="res://scripts/Ship/weapons.gd" id="6_f6fm2"] [ext_resource type="PackedScene" uid="uid://bf10g066l8grd" path="res://scenes/Ships/Modules/Weapons/laser.tscn" id="7_0ss0b"] [ext_resource type="Theme" uid="uid://dmb8bcdghdjd" path="res://main_theme.tres" id="8_8lpnq"] +[ext_resource type="PackedScene" uid="uid://dsmwg1rxedi3x" path="res://scenes/Minimap.tscn" id="9_7swe7"] [sub_resource type="GDScript" id="GDScript_ry4sc"] resource_name = "money_counter" @@ -173,6 +174,12 @@ script = SubResource("GDScript_rrgab") [node name="NonColorableGUI" type="CanvasLayer" parent="."] +[node name="Minimap" parent="NonColorableGUI" instance=ExtResource("9_7swe7")] +offset_left = 520.0 +offset_top = 480.0 +offset_right = 520.0 +offset_bottom = 479.76 + [node name="Camera" type="Camera2D" parent="."] zoom = Vector2(0.5, 0.5) script = ExtResource("5_rclap") diff --git a/scripts/Base/base.gd b/scripts/Base/base.gd index f912ba2..e52f458 100644 --- a/scripts/Base/base.gd +++ b/scripts/Base/base.gd @@ -44,7 +44,7 @@ var touching_dock = false var player_ship = null func _ready(): - get_tree().current_scene.bases.append(self) + star_system.bases.append(self) mouse_entered.connect(star_system.set_targeted_node.bind(self)) mouse_exited.connect(star_system.clear_targeted_node) gate_area.body_entered.connect(gate_area_body_entered) diff --git a/scripts/Ship/minimap.gd b/scripts/Ship/minimap.gd new file mode 100644 index 0000000..a056a0a --- /dev/null +++ b/scripts/Ship/minimap.gd @@ -0,0 +1,27 @@ +extends Control + +@export var marker : PackedScene + +@onready var ship: PlayerShip = $"../.." + +var markers = [] + +#func _process(_delta): +# $Sprite.self_modulate = ship.material.get_shader_parameter('color') + +func _ready(): + get_tree().create_timer(0.05).timeout.connect(init_markers) + +func init_markers(): + for ship in ship.star_system.ships: + add_marker(ship, MinimapMarker.Type.Ship) + for base in ship.star_system.bases: + add_marker(base, MinimapMarker.Type.Base) + +func add_marker(target : Node, type : MinimapMarker.Type): + var marker_inst = marker.instantiate() + markers.append(marker_inst) + marker_inst.target = target + marker_inst.type = type + marker_inst.position = Vector2(120, 120) + add_child(marker_inst) diff --git a/scripts/Ship/minimap_marker.gd b/scripts/Ship/minimap_marker.gd new file mode 100644 index 0000000..b985191 --- /dev/null +++ b/scripts/Ship/minimap_marker.gd @@ -0,0 +1,31 @@ +extends Node2D + +class_name MinimapMarker + +@onready var marker = $MarkerSprite +@onready var ship = $"../../.." + +enum Type { Ship, Base, Loot, Quest } + +var target : Node2D +var type := Type.Ship + +const TYPES_INDEXES = { + Type.Ship: 0, + Type.Base: 1, + Type.Loot: 2, + Type.Quest: 3 +} + +func _ready(): + marker.frame = TYPES_INDEXES[type] + +# Update marker angle and size +func _process(_delta): + if !is_instance_valid(target): + queue_free() + return + rotation = ship.global_position.angle_to_point(target.global_position) + var sp_scale = 2048 / clamp(ship.global_position.distance_to(target.global_position), 2048, 8192) + marker.scale = Vector2(sp_scale, sp_scale) + #modulate = target.material.get_shader_parameter("color") diff --git a/scripts/Ship/player_ship.gd b/scripts/Ship/player_ship.gd index 5104c92..e2350a1 100644 --- a/scripts/Ship/player_ship.gd +++ b/scripts/Ship/player_ship.gd @@ -19,6 +19,10 @@ var cargo = {} ## Current quest var quest: Quest = null +func _ready(): + super._ready() + star_system.ships.pop_back() + func destroy(): super.destroy() if docking_base != null: diff --git a/scripts/Ship/ship.gd b/scripts/Ship/ship.gd index ba3fd27..4f64b64 100644 --- a/scripts/Ship/ship.gd +++ b/scripts/Ship/ship.gd @@ -25,6 +25,7 @@ signal destroyed var faction : Game.Faction func _ready() -> void: + star_system.ships.append(self) hull.global_position = global_position destroyed.connect(destroy_timeout) destroyed.connect(star_system.on_ship_destroyed.bind(self)) diff --git a/scripts/Star System/star_system.gd b/scripts/Star System/star_system.gd index b5568a4..8b47d72 100644 --- a/scripts/Star System/star_system.gd +++ b/scripts/Star System/star_system.gd @@ -24,6 +24,8 @@ var player_ship: PlayerShip var pause_controller: Control ## All bases in the system var bases: Array[Base] +## All ships in the system (excluding player ship) +var ships: Array[Ship] func _ready(): player_ship = get_node_or_null("FactionPlayer/PlayerShip") diff --git a/scripts/objects/Minimap.gd b/scripts/objects/Minimap.gd deleted file mode 100644 index 4a3f93f..0000000 --- a/scripts/objects/Minimap.gd +++ /dev/null @@ -1,18 +0,0 @@ -extends Control - -@export var marker : PackedScene - -@onready var ship = $"../../.." - -var markers = [] - -func _process(_delta): - $Sprite.self_modulate = ship.material.get_shader_parameter('color') - -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 deleted file mode 100644 index 3d92577..0000000 --- a/scripts/objects/MinimapMarker.gd +++ /dev/null @@ -1,25 +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, - "quest": 3 -} - -func _ready(): - marker.frame = tmi[type] - -func _process(_delta): - if !is_instance_valid(target): - queue_free() - return - 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.material.get_shader_parameter("color") diff --git a/sprites/Minimap/base_marker.png b/sprites/Minimap/base_marker.png new file mode 100644 index 0000000..db433d4 Binary files /dev/null and b/sprites/Minimap/base_marker.png differ diff --git a/sprites/minimapquest.png.import b/sprites/Minimap/base_marker.png.import similarity index 67% rename from sprites/minimapquest.png.import rename to sprites/Minimap/base_marker.png.import index 058a11b..88fede3 100644 --- a/sprites/minimapquest.png.import +++ b/sprites/Minimap/base_marker.png.import @@ -2,16 +2,16 @@ importer="texture" type="CompressedTexture2D" -uid="uid://de34fc1qbeajo" -path="res://.godot/imported/minimapquest.png-d076ee9177bcd2600d555f3fc64ee3c9.ctex" +uid="uid://ct42eokncdaho" +path="res://.godot/imported/base_marker.png-b9f8915901ea6ed7a396a405de9b0f0f.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://sprites/minimapquest.png" -dest_files=["res://.godot/imported/minimapquest.png-d076ee9177bcd2600d555f3fc64ee3c9.ctex"] +source_file="res://sprites/Minimap/base_marker.png" +dest_files=["res://.godot/imported/base_marker.png-b9f8915901ea6ed7a396a405de9b0f0f.ctex"] [params] diff --git a/sprites/Minimap/minimap_back.png b/sprites/Minimap/minimap_back.png new file mode 100644 index 0000000..9b79289 Binary files /dev/null and b/sprites/Minimap/minimap_back.png differ diff --git a/sprites/minimaphostile.png.import b/sprites/Minimap/minimap_back.png.import similarity index 67% rename from sprites/minimaphostile.png.import rename to sprites/Minimap/minimap_back.png.import index 5dc7ce5..0cbfeb7 100644 --- a/sprites/minimaphostile.png.import +++ b/sprites/Minimap/minimap_back.png.import @@ -2,16 +2,16 @@ importer="texture" type="CompressedTexture2D" -uid="uid://bavanv7ua7qlx" -path="res://.godot/imported/minimaphostile.png-c29e24bedab8653d6040ce1ce3ac218b.ctex" +uid="uid://5gkjqkiiiggg" +path="res://.godot/imported/minimap_back.png-a12722e124259e8868482f9f3ed38f7b.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://sprites/minimaphostile.png" -dest_files=["res://.godot/imported/minimaphostile.png-c29e24bedab8653d6040ce1ce3ac218b.ctex"] +source_file="res://sprites/Minimap/minimap_back.png" +dest_files=["res://.godot/imported/minimap_back.png-a12722e124259e8868482f9f3ed38f7b.ctex"] [params] diff --git a/sprites/Minimap/quest_marker.png b/sprites/Minimap/quest_marker.png new file mode 100644 index 0000000..f3f6f44 Binary files /dev/null and b/sprites/Minimap/quest_marker.png differ diff --git a/sprites/minimapoverlay.png.import b/sprites/Minimap/quest_marker.png.import similarity index 67% rename from sprites/minimapoverlay.png.import rename to sprites/Minimap/quest_marker.png.import index 23f6352..e17ed2b 100644 --- a/sprites/minimapoverlay.png.import +++ b/sprites/Minimap/quest_marker.png.import @@ -2,16 +2,16 @@ importer="texture" type="CompressedTexture2D" -uid="uid://dmvfwcq7wewxt" -path="res://.godot/imported/minimapoverlay.png-223a6b8f774528a7a3b651febf4be193.ctex" +uid="uid://b8my0ci3s8e5a" +path="res://.godot/imported/quest_marker.png-4e5b39fb8ba076f2175e31f7a3fc4a89.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://sprites/minimapoverlay.png" -dest_files=["res://.godot/imported/minimapoverlay.png-223a6b8f774528a7a3b651febf4be193.ctex"] +source_file="res://sprites/Minimap/quest_marker.png" +dest_files=["res://.godot/imported/quest_marker.png-4e5b39fb8ba076f2175e31f7a3fc4a89.ctex"] [params] diff --git a/sprites/Minimap/ship_marker.png b/sprites/Minimap/ship_marker.png new file mode 100644 index 0000000..5e10c4f Binary files /dev/null and b/sprites/Minimap/ship_marker.png differ diff --git a/sprites/ship mk1.png.import b/sprites/Minimap/ship_marker.png.import similarity index 67% rename from sprites/ship mk1.png.import rename to sprites/Minimap/ship_marker.png.import index a341160..9cd35e9 100644 --- a/sprites/ship mk1.png.import +++ b/sprites/Minimap/ship_marker.png.import @@ -2,16 +2,16 @@ importer="texture" type="CompressedTexture2D" -uid="uid://dbwvej0c5bl52" -path="res://.godot/imported/ship mk1.png-2f9edff754736b801022c1187c117a4d.ctex" +uid="uid://bchjqn3y7ne64" +path="res://.godot/imported/ship_marker.png-58262683245e07f4903e7775c53f4263.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://sprites/ship mk1.png" -dest_files=["res://.godot/imported/ship mk1.png-2f9edff754736b801022c1187c117a4d.ctex"] +source_file="res://sprites/Minimap/ship_marker.png" +dest_files=["res://.godot/imported/ship_marker.png-58262683245e07f4903e7775c53f4263.ctex"] [params] diff --git a/sprites/Minimap/spinot_marker.png b/sprites/Minimap/spinot_marker.png new file mode 100644 index 0000000..88dc9f6 Binary files /dev/null and b/sprites/Minimap/spinot_marker.png differ diff --git a/sprites/minimapbounty.png.import b/sprites/Minimap/spinot_marker.png.import similarity index 67% rename from sprites/minimapbounty.png.import rename to sprites/Minimap/spinot_marker.png.import index 582c704..8fdbbb7 100644 --- a/sprites/minimapbounty.png.import +++ b/sprites/Minimap/spinot_marker.png.import @@ -2,16 +2,16 @@ importer="texture" type="CompressedTexture2D" -uid="uid://b1kf1jbsnw2m3" -path="res://.godot/imported/minimapbounty.png-8bfbc31a5342affc8293fffd1282e38d.ctex" +uid="uid://dn2cooyrbr1sh" +path="res://.godot/imported/spinot_marker.png-146e967ff6038ab8ed47d6c98dd42d26.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://sprites/minimapbounty.png" -dest_files=["res://.godot/imported/minimapbounty.png-8bfbc31a5342affc8293fffd1282e38d.ctex"] +source_file="res://sprites/Minimap/spinot_marker.png" +dest_files=["res://.godot/imported/spinot_marker.png-146e967ff6038ab8ed47d6c98dd42d26.ctex"] [params] diff --git a/sprites/minimapbase.png b/sprites/minimapbase.png deleted file mode 100644 index 891d6bc..0000000 Binary files a/sprites/minimapbase.png and /dev/null differ diff --git a/sprites/minimapbase.png.import b/sprites/minimapbase.png.import deleted file mode 100644 index 18c8048..0000000 --- a/sprites/minimapbase.png.import +++ /dev/null @@ -1,34 +0,0 @@ -[remap] - -importer="texture" -type="CompressedTexture2D" -uid="uid://bqn08woclyoj0" -path="res://.godot/imported/minimapbase.png-ec47bf4cf918b16db42f7bea337e9409.ctex" -metadata={ -"vram_texture": false -} - -[deps] - -source_file="res://sprites/minimapbase.png" -dest_files=["res://.godot/imported/minimapbase.png-ec47bf4cf918b16db42f7bea337e9409.ctex"] - -[params] - -compress/mode=0 -compress/high_quality=false -compress/lossy_quality=0.7 -compress/hdr_compression=1 -compress/normal_map=0 -compress/channel_pack=0 -mipmaps/generate=false -mipmaps/limit=-1 -roughness/mode=0 -roughness/src_normal="" -process/fix_alpha_border=true -process/premult_alpha=false -process/normal_map_invert_y=false -process/hdr_as_srgb=false -process/hdr_clamp_exposure=false -process/size_limit=0 -detect_3d/compress_to=1 diff --git a/sprites/minimapbounty.png b/sprites/minimapbounty.png deleted file mode 100644 index d76309e..0000000 Binary files a/sprites/minimapbounty.png and /dev/null differ diff --git a/sprites/minimaphostile.png b/sprites/minimaphostile.png deleted file mode 100644 index 442d7d4..0000000 Binary files a/sprites/minimaphostile.png and /dev/null differ diff --git a/sprites/minimapoverlay.png b/sprites/minimapoverlay.png deleted file mode 100644 index ccc7736..0000000 Binary files a/sprites/minimapoverlay.png and /dev/null differ diff --git a/sprites/minimapquest.png b/sprites/minimapquest.png deleted file mode 100644 index 364581a..0000000 Binary files a/sprites/minimapquest.png and /dev/null differ diff --git a/sprites/ship engine mk1.png b/sprites/ship engine mk1.png deleted file mode 100644 index 7502d51..0000000 Binary files a/sprites/ship engine mk1.png and /dev/null differ diff --git a/sprites/ship engine mk1.png.import b/sprites/ship engine mk1.png.import deleted file mode 100644 index c06aa3e..0000000 --- a/sprites/ship engine mk1.png.import +++ /dev/null @@ -1,34 +0,0 @@ -[remap] - -importer="texture" -type="CompressedTexture2D" -uid="uid://hpcn75jlrbr3" -path="res://.godot/imported/ship engine mk1.png-2dad18e1970833f73bb764a4a745bd9a.ctex" -metadata={ -"vram_texture": false -} - -[deps] - -source_file="res://sprites/ship engine mk1.png" -dest_files=["res://.godot/imported/ship engine mk1.png-2dad18e1970833f73bb764a4a745bd9a.ctex"] - -[params] - -compress/mode=0 -compress/high_quality=false -compress/lossy_quality=0.7 -compress/hdr_compression=1 -compress/normal_map=0 -compress/channel_pack=0 -mipmaps/generate=false -mipmaps/limit=-1 -roughness/mode=0 -roughness/src_normal="" -process/fix_alpha_border=true -process/premult_alpha=false -process/normal_map_invert_y=false -process/hdr_as_srgb=false -process/hdr_clamp_exposure=false -process/size_limit=0 -detect_3d/compress_to=1 diff --git a/sprites/ship mk1.png b/sprites/ship mk1.png deleted file mode 100644 index 35dec10..0000000 Binary files a/sprites/ship mk1.png and /dev/null differ diff --git a/sprites/space station 1.png b/sprites/space station 1.png deleted file mode 100644 index 0395638..0000000 Binary files a/sprites/space station 1.png and /dev/null differ diff --git a/sprites/space station 1.png.import b/sprites/space station 1.png.import deleted file mode 100644 index 2b7059e..0000000 --- a/sprites/space station 1.png.import +++ /dev/null @@ -1,34 +0,0 @@ -[remap] - -importer="texture" -type="CompressedTexture2D" -uid="uid://deabc107bimdb" -path="res://.godot/imported/space station 1.png-5e5683c36f1bd481737673d5b2afabde.ctex" -metadata={ -"vram_texture": false -} - -[deps] - -source_file="res://sprites/space station 1.png" -dest_files=["res://.godot/imported/space station 1.png-5e5683c36f1bd481737673d5b2afabde.ctex"] - -[params] - -compress/mode=0 -compress/high_quality=false -compress/lossy_quality=0.7 -compress/hdr_compression=1 -compress/normal_map=0 -compress/channel_pack=0 -mipmaps/generate=false -mipmaps/limit=-1 -roughness/mode=0 -roughness/src_normal="" -process/fix_alpha_border=true -process/premult_alpha=false -process/normal_map_invert_y=false -process/hdr_as_srgb=false -process/hdr_clamp_exposure=false -process/size_limit=0 -detect_3d/compress_to=1