Dodana muzyka
Zmieniony guzik galaxy
Dodane Menu
This commit is contained in:
Tomasz Boruc 2025-10-18 18:56:15 +02:00
parent a3dfbc695b
commit 4ad0ca91f8
19 changed files with 349 additions and 41 deletions

View File

@ -12,7 +12,7 @@ var current_sector: int = -1
# Timer aktualizacji # Timer aktualizacji
var update_timer := 0.0 var update_timer := 0.0
const UPDATE_INTERVAL := 2.0 const UPDATE_INTERVAL := 30.0
# Nazwy planet # Nazwy planet
var planet_names = [ var planet_names = [

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 MiB

View File

@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://xuw4ki75j3fy"
path="res://.godot/imported/menubg.png-92f9e681feb23550aacbba0e8eb136bf.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/background/menubg.png"
dest_files=["res://.godot/imported/menubg.png-92f9e681feb23550aacbba0e8eb136bf.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
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/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
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.

After

Width:  |  Height:  |  Size: 1.1 MiB

View File

@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://di7qrtp4lusa3"
path="res://.godot/imported/galaxy_button.png-716cb9349adbdd584102ebef75b89a12.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/icons/galaxy_button.png"
dest_files=["res://.godot/imported/galaxy_button.png-716cb9349adbdd584102ebef75b89a12.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
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/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
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.

After

Width:  |  Height:  |  Size: 1.0 MiB

View File

@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cxanptjcnnwh"
path="res://.godot/imported/galaxy_button_hover.png-ac08154e2e01a081f61dea3ef99a0b33.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/icons/galaxy_button_hover.png"
dest_files=["res://.godot/imported/galaxy_button_hover.png-ac08154e2e01a081f61dea3ef99a0b33.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
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/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
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.

View File

@ -0,0 +1,19 @@
[remap]
importer="mp3"
type="AudioStreamMP3"
uid="uid://cqetkh2cefibd"
path="res://.godot/imported/game_music.mp3-20c889bd0c692c83f686e0a0181665f3.mp3str"
[deps]
source_file="res://assets/sounds/music/game_music.mp3"
dest_files=["res://.godot/imported/game_music.mp3-20c889bd0c692c83f686e0a0181665f3.mp3str"]
[params]
loop=false
loop_offset=0
bpm=0
beat_count=0
bar_beats=4

Binary file not shown.

View File

@ -0,0 +1,19 @@
[remap]
importer="mp3"
type="AudioStreamMP3"
uid="uid://ditln0kq3u3dm"
path="res://.godot/imported/menu_music.mp3-aa66988442ee0305322e3502470ef258.mp3str"
[deps]
source_file="res://assets/sounds/music/menu_music.mp3"
dest_files=["res://.godot/imported/menu_music.mp3-aa66988442ee0305322e3502470ef258.mp3str"]
[params]
loop=true
loop_offset=0
bpm=0
beat_count=0
bar_beats=4

19
music_manager.gd Normal file
View File

@ -0,0 +1,19 @@
extends Node
# AudioStreamPlayer do odtwarzania muzyki
var music_player: AudioStreamPlayer
func _ready():
# Tworzymy AudioStreamPlayer
music_player = AudioStreamPlayer.new()
add_child(music_player)
# Ładujemy muzykę
var music_stream = load("res://assets/sounds/music/game_music.mp3") as AudioStream
music_stream.set_loop(true)
music_player.stream = music_stream
# Funkcja do uruchomienia muzyki
func play_music():
if not music_player.playing:
music_player.play()

1
music_manager.gd.uid Normal file
View File

@ -0,0 +1 @@
uid://iwksv67aalhy

View File

@ -11,13 +11,14 @@ config_version=5
[application] [application]
config/name="Space Empire" config/name="Space Empire"
run/main_scene="uid://krtvmtme8s5f" run/main_scene="uid://sxae8i12io4y"
config/features=PackedStringArray("4.5", "Forward Plus") config/features=PackedStringArray("4.5", "Forward Plus")
config/icon="res://icon.svg" config/icon="res://icon.svg"
[autoload] [autoload]
Manager="*res://Manager.gd" Manager="*res://Manager.gd"
MusicManager="*res://music_manager.gd"
[display] [display]

107
scenes/menu.tscn Normal file
View File

@ -0,0 +1,107 @@
[gd_scene load_steps=9 format=3 uid="uid://sxae8i12io4y"]
[ext_resource type="Script" uid="uid://ol6efor868gk" path="res://scripts/menu.gd" id="1_vjb58"]
[ext_resource type="Texture2D" uid="uid://xuw4ki75j3fy" path="res://assets/background/menubg.png" id="1_yqeox"]
[ext_resource type="AudioStream" uid="uid://ditln0kq3u3dm" path="res://assets/sounds/music/menu_music.mp3" id="3_con2f"]
[ext_resource type="Script" path="res://scenes/button_script.gd" id="3_mhnvy"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_yqeox"]
bg_color = Color(0.1567365, 0.410904, 0.5666233, 1)
border_width_left = 2
border_width_top = 2
border_width_right = 2
border_width_bottom = 2
border_color = Color(0, 0, 0, 1)
corner_radius_top_left = 12
corner_radius_top_right = 12
corner_radius_bottom_right = 12
corner_radius_bottom_left = 12
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_vjb58"]
bg_color = Color(0.5891781, 0.78593767, 0.93167466, 1)
border_width_left = 2
border_width_top = 2
border_width_right = 2
border_width_bottom = 2
corner_radius_top_left = 12
corner_radius_top_right = 12
corner_radius_bottom_right = 12
corner_radius_bottom_left = 12
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_con2f"]
bg_color = Color(0.09019608, 0.15294118, 0.28235295, 1)
border_width_left = 2
border_width_top = 2
border_width_right = 2
border_width_bottom = 2
corner_radius_top_left = 12
corner_radius_top_right = 12
corner_radius_bottom_right = 12
corner_radius_bottom_left = 12
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_mhnvy"]
bg_color = Color(0.09026273, 0.15419397, 0.28203714, 1)
border_width_left = 2
border_width_top = 2
border_width_right = 2
border_width_bottom = 2
corner_radius_top_left = 12
corner_radius_top_right = 12
corner_radius_bottom_right = 12
corner_radius_bottom_left = 12
[node name="MainMenu" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_vjb58")
[node name="TextureRect" type="TextureRect" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
texture = ExtResource("1_yqeox")
expand_mode = 1
[node name="VBoxContainer" type="VBoxContainer" parent="."]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -125.0
offset_top = -37.0
offset_right = 117.0
offset_bottom = 167.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/separation = 20
[node name="start" type="Button" parent="VBoxContainer"]
layout_mode = 2
theme_override_font_sizes/font_size = 31
theme_override_styles/normal = SubResource("StyleBoxFlat_yqeox")
theme_override_styles/pressed = SubResource("StyleBoxFlat_vjb58")
theme_override_styles/hover = SubResource("StyleBoxFlat_con2f")
text = "START"
script = ExtResource("3_mhnvy")
[node name="exit" type="Button" parent="VBoxContainer"]
layout_mode = 2
theme_override_font_sizes/font_size = 31
theme_override_styles/normal = SubResource("StyleBoxFlat_yqeox")
theme_override_styles/pressed = SubResource("StyleBoxFlat_vjb58")
theme_override_styles/hover = SubResource("StyleBoxFlat_mhnvy")
text = "WYJŚCIE"
[node name="AudioStreamPlayer2D" type="AudioStreamPlayer2D" parent="."]
stream = ExtResource("3_con2f")
volume_db = 7.068
autoplay = true

View File

@ -1,6 +1,8 @@
[gd_scene load_steps=2 format=3 uid="uid://b1a8a10jb4auf"] [gd_scene load_steps=4 format=3 uid="uid://b1a8a10jb4auf"]
[ext_resource type="Script" uid="uid://cntq3qk522oqg" path="res://scripts/sector.gd" id="1_l8itw"] [ext_resource type="Script" uid="uid://cntq3qk522oqg" path="res://scripts/sector.gd" id="1_l8itw"]
[ext_resource type="Texture2D" uid="uid://di7qrtp4lusa3" path="res://assets/icons/galaxy_button.png" id="2_c2nvg"]
[ext_resource type="Texture2D" uid="uid://cxanptjcnnwh" path="res://assets/icons/galaxy_button_hover.png" id="3_d5vc0"]
[node name="Sector" type="Node2D"] [node name="Sector" type="Node2D"]
script = ExtResource("1_l8itw") script = ExtResource("1_l8itw")
@ -9,56 +11,55 @@ script = ExtResource("1_l8itw")
position = Vector2(572.00006, 328.5) position = Vector2(572.00006, 328.5)
[node name="PlanetStatPanel" type="Panel" parent="."] [node name="PlanetStatPanel" type="Panel" parent="."]
offset_right = 284.0 offset_right = 320.0
offset_bottom = 204.0 offset_bottom = 204.0
[node name="PlanetName" type="Label" parent="PlanetStatPanel"] [node name="PlanetName" type="Label" parent="PlanetStatPanel"]
layout_mode = 0 layout_mode = 0
offset_left = 10.0 offset_left = 8.0
offset_top = 10.0 offset_top = 16.0
offset_right = 260.0 offset_right = 278.0
offset_bottom = 35.0 offset_bottom = 41.0
theme_override_colors/font_color = Color(0.15989491, 0.40655294, 0.47780138, 1)
[node name="PopulationPanel" type="Label" parent="PlanetStatPanel"] [node name="PopulationPanel" type="Label" parent="PlanetStatPanel"]
layout_mode = 1 layout_mode = 1
anchors_preset = -1 anchors_preset = -1
anchor_bottom = 0.277 anchor_bottom = 0.277
offset_left = 10.0 offset_left = 8.0
offset_top = 46.0 offset_top = 48.0
offset_right = 260.0 offset_right = 278.0
offset_bottom = 24.186996 offset_bottom = 16.491997
[node name="ResourcePlanet" type="Label" parent="PlanetStatPanel"] [node name="ResourcePlanet" type="Label" parent="PlanetStatPanel"]
layout_mode = 0 layout_mode = 0
offset_left = 10.0 offset_left = 8.0
offset_top = 82.0 offset_top = 80.0
offset_right = 260.0 offset_right = 278.0
offset_bottom = 107.0 offset_bottom = 105.0
[node name="MiningRate" type="Label" parent="PlanetStatPanel"] [node name="MiningRate" type="Label" parent="PlanetStatPanel"]
layout_mode = 0 layout_mode = 0
offset_left = 10.0 offset_left = 8.0
offset_top = 118.0 offset_top = 112.0
offset_right = 260.0 offset_right = 278.0
offset_bottom = 143.0 offset_bottom = 137.0
[node name="GrowthRate" type="Label" parent="PlanetStatPanel"] [node name="GrowthRate" type="Label" parent="PlanetStatPanel"]
layout_mode = 0 layout_mode = 0
offset_left = 12.0 offset_left = 8.0
offset_top = 150.0 offset_top = 144.0
offset_right = 262.0 offset_right = 278.0
offset_bottom = 175.0 offset_bottom = 169.0
[node name="BackButton" type="Button" parent="."] [node name="BackButton" type="TextureButton" parent="."]
anchors_preset = 6 offset_left = 2337.0
anchor_left = 1.0 offset_top = 1199.0
anchor_top = 0.5 offset_right = 2407.0
anchor_right = 1.0 offset_bottom = 1269.0
anchor_bottom = 0.5 size_flags_horizontal = 8
offset_left = 1291.0 size_flags_vertical = 8
offset_top = 742.0 texture_normal = ExtResource("2_c2nvg")
offset_right = 1377.0 texture_hover = ExtResource("3_d5vc0")
offset_bottom = 773.0 ignore_texture_size = true
grow_horizontal = 0 stretch_mode = 0
grow_vertical = 2
text = "Galaktyka"

12
scripts/menu.gd Normal file
View File

@ -0,0 +1,12 @@
extends Control
func _ready():
$VBoxContainer/start.connect("pressed", Callable(self, "_on_start_pressed"))
$VBoxContainer/exit.connect("pressed", Callable(self, "_on_exit_pressed"))
func _on_start_pressed():
get_tree().change_scene_to_file("res://scenes/Galaxy.tscn")
MusicManager.play_music()
func _on_exit_pressed():
get_tree().quit()

1
scripts/menu.gd.uid Normal file
View File

@ -0,0 +1 @@
uid://ol6efor868gk

View File

@ -3,10 +3,10 @@ extends Node2D
var StarScene = preload("res://scenes/Star.tscn") var StarScene = preload("res://scenes/Star.tscn")
var PlanetScene = preload("res://scenes/Planet.tscn") var PlanetScene = preload("res://scenes/Planet.tscn")
@onready var PlanetStatPanel = $PlanetStatPanel @onready var PlanetStatPanel = $PlanetStatPanel
@onready var BackButton = $BackButton @onready var BackButton: TextureButton = $BackButton
var ORBIT_STEP = 150 var ORBIT_STEP = 120
const FIRST_ORBIT_STEP = 200 const FIRST_ORBIT_STEP = 160
var tracked_planet: Node = null var tracked_planet: Node = null
func _ready(): func _ready():
@ -15,6 +15,14 @@ func _ready():
spawn_star() spawn_star()
spawn_planets() spawn_planets()
BackButton.pressed.connect(_on_back_pressed) BackButton.pressed.connect(_on_back_pressed)
var screen_center = get_viewport_rect().size / 2
var offset = 20
var button_size = BackButton.get_size() # Vector2(width, height)
BackButton.position = get_viewport_rect().size - button_size - Vector2(offset, offset)
func _process(delta): func _process(delta):
if tracked_planet and PlanetStatPanel.visible: if tracked_planet and PlanetStatPanel.visible:
@ -130,7 +138,7 @@ func _update_panel():
if tracked_planet == null or tracked_planet.data == null: if tracked_planet == null or tracked_planet.data == null:
return return
var colonized_text = " (Skolonizowana)" if tracked_planet.data["is_colonized"] else "" var colonized_text = " (Skolonizowana)" if tracked_planet.data["is_colonized"] else ""
PlanetStatPanel.get_node("PlanetName").text = "Name: " + tracked_planet.data["name"] + colonized_text PlanetStatPanel.get_node("PlanetName").text = "Nazwa: " + tracked_planet.data["name"] + colonized_text
PlanetStatPanel.get_node("PopulationPanel").text = "Populacja: %d / %d" % [tracked_planet.data["population"], tracked_planet.data["max_population"]] PlanetStatPanel.get_node("PopulationPanel").text = "Populacja: %d / %d" % [tracked_planet.data["population"], tracked_planet.data["max_population"]]
PlanetStatPanel.get_node("MiningRate").text = "Potencjał surowcowy: %.2f" % tracked_planet.data["mining_rate"] PlanetStatPanel.get_node("MiningRate").text = "Potencjał surowcowy: %.2f" % tracked_planet.data["mining_rate"]
var mined_per_cycle = Manager.get_mined_per_cycle(tracked_planet.data) var mined_per_cycle = Manager.get_mined_per_cycle(tracked_planet.data)