This commit is contained in:
2ndbeam 2024-06-09 23:01:14 +03:00
commit 6c5350d47e
32 changed files with 114 additions and 186 deletions

View file

@ -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")

View file

@ -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

View file

@ -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")

View file

@ -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)

27
scripts/Ship/minimap.gd Normal file
View file

@ -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)

View file

@ -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")

View file

@ -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:

View file

@ -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))

View file

@ -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")

View file

@ -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)

View file

@ -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")

Binary file not shown.

After

Width:  |  Height:  |  Size: 688 B

View file

@ -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]

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

View file

@ -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]

Binary file not shown.

After

Width:  |  Height:  |  Size: 856 B

View file

@ -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]

Binary file not shown.

After

Width:  |  Height:  |  Size: 781 B

View file

@ -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]

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View file

@ -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]

Binary file not shown.

Before

Width:  |  Height:  |  Size: 115 B

View file

@ -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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 128 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 131 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 133 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 153 B

View file

@ -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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 234 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

View file

@ -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