diff --git a/Manager.gd b/Manager.gd index d6c1f03..d26f6c6 100644 --- a/Manager.gd +++ b/Manager.gd @@ -12,7 +12,7 @@ var current_sector: int = -1 # Timer aktualizacji var update_timer := 0.0 -const UPDATE_INTERVAL := 2.0 +const UPDATE_INTERVAL := 30.0 # Nazwy planet var planet_names = [ diff --git a/assets/background/menubg.png b/assets/background/menubg.png new file mode 100644 index 0000000..fe5d058 Binary files /dev/null and b/assets/background/menubg.png differ diff --git a/assets/background/menubg.png.import b/assets/background/menubg.png.import new file mode 100644 index 0000000..8f7f2c4 --- /dev/null +++ b/assets/background/menubg.png.import @@ -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 diff --git a/assets/icons/galaxy_button.png b/assets/icons/galaxy_button.png new file mode 100644 index 0000000..b4ddda1 Binary files /dev/null and b/assets/icons/galaxy_button.png differ diff --git a/assets/icons/galaxy_button.png.import b/assets/icons/galaxy_button.png.import new file mode 100644 index 0000000..bbb3816 --- /dev/null +++ b/assets/icons/galaxy_button.png.import @@ -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 diff --git a/assets/icons/galaxy_button_hover.png b/assets/icons/galaxy_button_hover.png new file mode 100644 index 0000000..cc8eb62 Binary files /dev/null and b/assets/icons/galaxy_button_hover.png differ diff --git a/assets/icons/galaxy_button_hover.png.import b/assets/icons/galaxy_button_hover.png.import new file mode 100644 index 0000000..52b0c14 --- /dev/null +++ b/assets/icons/galaxy_button_hover.png.import @@ -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 diff --git a/assets/sounds/music/game_music.mp3 b/assets/sounds/music/game_music.mp3 new file mode 100644 index 0000000..19566f2 Binary files /dev/null and b/assets/sounds/music/game_music.mp3 differ diff --git a/assets/sounds/music/game_music.mp3.import b/assets/sounds/music/game_music.mp3.import new file mode 100644 index 0000000..acdd95f --- /dev/null +++ b/assets/sounds/music/game_music.mp3.import @@ -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 diff --git a/assets/sounds/music/menu_music.mp3 b/assets/sounds/music/menu_music.mp3 new file mode 100644 index 0000000..425d835 Binary files /dev/null and b/assets/sounds/music/menu_music.mp3 differ diff --git a/assets/sounds/music/menu_music.mp3.import b/assets/sounds/music/menu_music.mp3.import new file mode 100644 index 0000000..3fa42ad --- /dev/null +++ b/assets/sounds/music/menu_music.mp3.import @@ -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 diff --git a/music_manager.gd b/music_manager.gd new file mode 100644 index 0000000..c9f7136 --- /dev/null +++ b/music_manager.gd @@ -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() diff --git a/music_manager.gd.uid b/music_manager.gd.uid new file mode 100644 index 0000000..de6845e --- /dev/null +++ b/music_manager.gd.uid @@ -0,0 +1 @@ +uid://iwksv67aalhy diff --git a/project.godot b/project.godot index fb42796..8b42399 100644 --- a/project.godot +++ b/project.godot @@ -11,13 +11,14 @@ config_version=5 [application] config/name="Space Empire" -run/main_scene="uid://krtvmtme8s5f" +run/main_scene="uid://sxae8i12io4y" config/features=PackedStringArray("4.5", "Forward Plus") config/icon="res://icon.svg" [autoload] Manager="*res://Manager.gd" +MusicManager="*res://music_manager.gd" [display] diff --git a/scenes/menu.tscn b/scenes/menu.tscn new file mode 100644 index 0000000..dcf06be --- /dev/null +++ b/scenes/menu.tscn @@ -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 diff --git a/scenes/sector.tscn b/scenes/sector.tscn index 0d4c891..cc1d6c8 100644 --- a/scenes/sector.tscn +++ b/scenes/sector.tscn @@ -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="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"] script = ExtResource("1_l8itw") @@ -9,56 +11,55 @@ script = ExtResource("1_l8itw") position = Vector2(572.00006, 328.5) [node name="PlanetStatPanel" type="Panel" parent="."] -offset_right = 284.0 +offset_right = 320.0 offset_bottom = 204.0 [node name="PlanetName" type="Label" parent="PlanetStatPanel"] layout_mode = 0 -offset_left = 10.0 -offset_top = 10.0 -offset_right = 260.0 -offset_bottom = 35.0 +offset_left = 8.0 +offset_top = 16.0 +offset_right = 278.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"] layout_mode = 1 anchors_preset = -1 anchor_bottom = 0.277 -offset_left = 10.0 -offset_top = 46.0 -offset_right = 260.0 -offset_bottom = 24.186996 +offset_left = 8.0 +offset_top = 48.0 +offset_right = 278.0 +offset_bottom = 16.491997 [node name="ResourcePlanet" type="Label" parent="PlanetStatPanel"] layout_mode = 0 -offset_left = 10.0 -offset_top = 82.0 -offset_right = 260.0 -offset_bottom = 107.0 +offset_left = 8.0 +offset_top = 80.0 +offset_right = 278.0 +offset_bottom = 105.0 [node name="MiningRate" type="Label" parent="PlanetStatPanel"] layout_mode = 0 -offset_left = 10.0 -offset_top = 118.0 -offset_right = 260.0 -offset_bottom = 143.0 +offset_left = 8.0 +offset_top = 112.0 +offset_right = 278.0 +offset_bottom = 137.0 [node name="GrowthRate" type="Label" parent="PlanetStatPanel"] layout_mode = 0 -offset_left = 12.0 -offset_top = 150.0 -offset_right = 262.0 -offset_bottom = 175.0 +offset_left = 8.0 +offset_top = 144.0 +offset_right = 278.0 +offset_bottom = 169.0 -[node name="BackButton" type="Button" parent="."] -anchors_preset = 6 -anchor_left = 1.0 -anchor_top = 0.5 -anchor_right = 1.0 -anchor_bottom = 0.5 -offset_left = 1291.0 -offset_top = 742.0 -offset_right = 1377.0 -offset_bottom = 773.0 -grow_horizontal = 0 -grow_vertical = 2 -text = "Galaktyka" +[node name="BackButton" type="TextureButton" parent="."] +offset_left = 2337.0 +offset_top = 1199.0 +offset_right = 2407.0 +offset_bottom = 1269.0 +size_flags_horizontal = 8 +size_flags_vertical = 8 +texture_normal = ExtResource("2_c2nvg") +texture_hover = ExtResource("3_d5vc0") +ignore_texture_size = true +stretch_mode = 0 diff --git a/scripts/menu.gd b/scripts/menu.gd new file mode 100644 index 0000000..64624b5 --- /dev/null +++ b/scripts/menu.gd @@ -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() diff --git a/scripts/menu.gd.uid b/scripts/menu.gd.uid new file mode 100644 index 0000000..9bcdf77 --- /dev/null +++ b/scripts/menu.gd.uid @@ -0,0 +1 @@ +uid://ol6efor868gk diff --git a/scripts/sector.gd b/scripts/sector.gd index 49c6f10..4fec407 100644 --- a/scripts/sector.gd +++ b/scripts/sector.gd @@ -3,10 +3,10 @@ extends Node2D var StarScene = preload("res://scenes/Star.tscn") var PlanetScene = preload("res://scenes/Planet.tscn") @onready var PlanetStatPanel = $PlanetStatPanel -@onready var BackButton = $BackButton +@onready var BackButton: TextureButton = $BackButton -var ORBIT_STEP = 150 -const FIRST_ORBIT_STEP = 200 +var ORBIT_STEP = 120 +const FIRST_ORBIT_STEP = 160 var tracked_planet: Node = null func _ready(): @@ -15,6 +15,14 @@ func _ready(): spawn_star() spawn_planets() 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): if tracked_planet and PlanetStatPanel.visible: @@ -130,7 +138,7 @@ func _update_panel(): if tracked_planet == null or tracked_planet.data == null: return 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("MiningRate").text = "Potencjał surowcowy: %.2f" % tracked_planet.data["mining_rate"] var mined_per_cycle = Manager.get_mined_per_cycle(tracked_planet.data)