diff --git a/Globals.gd b/Globals.gd index 6d21904..b76e34a 100644 --- a/Globals.gd +++ b/Globals.gd @@ -21,6 +21,8 @@ var draw_island_bbox = false var zoom_sailing = 1.0 var zoom_birdy = 4 +var game_num_islands = 4 + # Called when the node enters the scene tree for the first time. func _ready(): HexGrid.hex_scale = Vector2(hex_size, hex_size) diff --git a/Menu.gd b/Menu.gd new file mode 100644 index 0000000..1858b73 --- /dev/null +++ b/Menu.gd @@ -0,0 +1,31 @@ +extends Node2D + + +# Declare member variables here. Examples: +# var a = 2 +# var b = "text" + + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +#func _process(delta): +# pass + + +func _on_SimpleButton_pressed(): + Globals.game_num_islands = 4; + get_tree().change_scene("res://scenes/Game.tscn") + + +func _on_MediumButton_pressed(): + Globals.game_num_islands = 6; + get_tree().change_scene("res://scenes/Game.tscn") + + +func _on_HardButton_pressed(): + Globals.game_num_islands = 10; + get_tree().change_scene("res://scenes/Game.tscn") diff --git a/Menu.tscn b/Menu.tscn new file mode 100644 index 0000000..c538010 --- /dev/null +++ b/Menu.tscn @@ -0,0 +1,72 @@ +[gd_scene load_steps=3 format=2] + +[ext_resource path="res://Menu.gd" type="Script" id=1] +[ext_resource path="res://assets/title logo.png" type="Texture" id=2] + +[node name="Menu" type="Node2D"] +script = ExtResource( 1 ) + +[node name="CanvasLayer" type="CanvasLayer" parent="."] + +[node name="HBoxContainer2" type="HBoxContainer" parent="CanvasLayer"] +anchor_right = 1.0 +margin_bottom = 445.0 +rect_scale = Vector2( 0.5, 0.5 ) +size_flags_horizontal = 5 +size_flags_vertical = 5 +alignment = 1 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="TextureRect" type="TextureRect" parent="CanvasLayer/HBoxContainer2"] +margin_right = 1523.0 +margin_bottom = 445.0 +rect_scale = Vector2( 0.5, 0.5 ) +size_flags_horizontal = 13 +size_flags_vertical = 13 +texture = ExtResource( 2 ) +stretch_mode = 1 + +[node name="VBoxContainer" type="VBoxContainer" parent="CanvasLayer"] +anchor_left = 0.5 +anchor_top = 1.0 +anchor_right = 0.5 +anchor_bottom = 1.0 +margin_left = -278.0 +margin_top = -100.0 +margin_right = 278.0 +custom_constants/separation = 64 +alignment = 1 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="HBoxContainer" type="HBoxContainer" parent="CanvasLayer/VBoxContainer"] +margin_right = 556.0 +margin_bottom = -300.0 +custom_constants/separation = 128 + +[node name="SimpleButton" type="Button" parent="CanvasLayer/VBoxContainer/HBoxContainer"] +margin_right = 100.0 +margin_bottom = 100.0 +rect_min_size = Vector2( 100, 100 ) +text = "Leicht" + +[node name="MediumButton" type="Button" parent="CanvasLayer/VBoxContainer/HBoxContainer"] +margin_left = 228.0 +margin_right = 328.0 +margin_bottom = 100.0 +rect_min_size = Vector2( 100, 100 ) +text = "Mittel" + +[node name="HardButton" type="Button" parent="CanvasLayer/VBoxContainer/HBoxContainer"] +margin_left = 456.0 +margin_right = 556.0 +margin_bottom = 100.0 +rect_min_size = Vector2( 100, 100 ) +text = "Schwer" + +[connection signal="pressed" from="CanvasLayer/VBoxContainer/HBoxContainer/SimpleButton" to="." method="_on_SimpleButton_pressed"] +[connection signal="pressed" from="CanvasLayer/VBoxContainer/HBoxContainer/MediumButton" to="." method="_on_MediumButton_pressed"] +[connection signal="pressed" from="CanvasLayer/VBoxContainer/HBoxContainer/HardButton" to="." method="_on_HardButton_pressed"] diff --git a/assets/arrowback.svg b/assets/arrowback.svg new file mode 100644 index 0000000..7954917 --- /dev/null +++ b/assets/arrowback.svg @@ -0,0 +1,67 @@ + + + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/assets/arrowback.svg.import b/assets/arrowback.svg.import new file mode 100644 index 0000000..119f0da --- /dev/null +++ b/assets/arrowback.svg.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/arrowback.svg-3ee67320f3741b3ed312b0e6e2b38099.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/arrowback.svg" +dest_files=[ "res://.import/arrowback.svg-3ee67320f3741b3ed312b0e6e2b38099.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/assets/arrowrepeat.svg b/assets/arrowrepeat.svg new file mode 100644 index 0000000..53c93f7 --- /dev/null +++ b/assets/arrowrepeat.svg @@ -0,0 +1,68 @@ + + + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/assets/arrowrepeat.svg.import b/assets/arrowrepeat.svg.import new file mode 100644 index 0000000..232e121 --- /dev/null +++ b/assets/arrowrepeat.svg.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/arrowrepeat.svg-0bd94e0b70fb55dbaf70ab0942d209af.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/arrowrepeat.svg" +dest_files=[ "res://.import/arrowrepeat.svg-0bd94e0b70fb55dbaf70ab0942d209af.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/assets/title logo.png b/assets/title logo.png new file mode 100644 index 0000000..90f1b69 Binary files /dev/null and b/assets/title logo.png differ diff --git a/assets/title logo.png.import b/assets/title logo.png.import new file mode 100644 index 0000000..b2d57e8 --- /dev/null +++ b/assets/title logo.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/title logo.png-c2d3e5236fe75694f1e466cbba375e2f.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/title logo.png" +dest_files=[ "res://.import/title logo.png-c2d3e5236fe75694f1e466cbba375e2f.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/project.godot b/project.godot index 62c543c..7676bdc 100644 --- a/project.godot +++ b/project.godot @@ -21,7 +21,7 @@ _global_script_class_icons={ [application] config/name="Pirate Treasure Hunt" -run/main_scene="res://scenes/Game.tscn" +run/main_scene="res://Menu.tscn" config/icon="res://assets/pirate.svg" [autoload] diff --git a/scenes/Game.tscn b/scenes/Game.tscn index f383516..ecfc7d3 100644 --- a/scenes/Game.tscn +++ b/scenes/Game.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=27 format=2] +[gd_scene load_steps=29 format=2] [ext_resource path="res://scenes/World.gd" type="Script" id=1] [ext_resource path="res://scenes/Grid.gd" type="Script" id=2] @@ -16,6 +16,8 @@ [ext_resource path="res://scenes/MusicPlayer.gd" type="Script" id=14] [ext_resource path="res://assets/map.svg" type="Texture" id=15] [ext_resource path="res://assets/parrot.svg" type="Texture" id=16] +[ext_resource path="res://assets/arrowback.svg" type="Texture" id=17] +[ext_resource path="res://assets/arrowrepeat.svg" type="Texture" id=18] [sub_resource type="DynamicFont" id=1] size = 27 @@ -175,21 +177,31 @@ script = ExtResource( 8 ) [node name="UI" type="CanvasLayer" parent="World"] -[node name="TopContainer" type="HBoxContainer" parent="World/UI"] -anchor_right = 1.0 +[node name="HBoxContainer" type="HBoxContainer" parent="World/UI"] margin_left = 10.0 margin_top = 10.0 margin_right = -10.0 -margin_bottom = 20.0 +margin_bottom = 10.0 +rect_scale = Vector2( 0.25, 0.25 ) __meta__ = { "_edit_use_anchors_": false } -[node name="GenerateButton" type="Button" parent="World/UI/TopContainer"] -margin_right = 113.0 -margin_bottom = 64.0 -rect_min_size = Vector2( 64, 64 ) -text = "Generate World" +[node name="BackButton" type="Button" parent="World/UI/HBoxContainer"] +margin_right = 268.0 +margin_bottom = 262.0 +icon = ExtResource( 17 ) +flat = true + +[node name="RepeatButton" type="Button" parent="World/UI/HBoxContainer"] +margin_left = 272.0 +margin_right = 540.0 +margin_bottom = 262.0 +rect_min_size = Vector2( 256, 64 ) +disabled = true +action_mode = 0 +icon = ExtResource( 18 ) +flat = true [node name="IslandMap" type="TextureRect" parent="World/UI"] visible = false @@ -463,7 +475,8 @@ render_target_update_mode = 1 [connection signal="treasure_found" from="World" to="SoundEffectsPlayer" method="_on_World_treasure_found"] [connection signal="world_generation_triggered" from="World" to="SoundEffectsPlayer" method="_on_World_world_generation_triggered"] [connection signal="wrong_digsite" from="World" to="SoundEffectsPlayer" method="_on_World_wrong_digsite"] -[connection signal="pressed" from="World/UI/TopContainer/GenerateButton" to="World" method="_on_generate_button_pressed"] +[connection signal="pressed" from="World/UI/HBoxContainer/BackButton" to="World" method="_on_BackButton_pressed"] +[connection signal="pressed" from="World/UI/HBoxContainer/RepeatButton" to="World" method="_on_GenerateButton_pressed"] [connection signal="visibility_changed" from="World/UI/IslandMap" to="World" method="_on_IslandMap_visibility_changed"] [connection signal="pressed" from="World/UI/VBoxContainer/MapButton" to="World" method="_on_MapButton_pressed"] [connection signal="pressed" from="World/UI/VBoxContainer/BirdyButton" to="World" method="_on_BirdyButton_pressed"] diff --git a/scenes/World.gd b/scenes/World.gd index e751e00..d870c93 100644 --- a/scenes/World.gd +++ b/scenes/World.gd @@ -14,6 +14,7 @@ onready var ZoomValueLabel = get_node("UI/DebugContainer/ZoomValue") onready var HexCoordValueLabel = get_node("UI/DebugContainer/HexCoordValue") onready var WorldCoordValueLabel = get_node("UI/DebugContainer/WorldCoordValue") onready var TileTypeValueLabel = get_node("UI/DebugContainer/TileTypeValue") +onready var RepeatButton = get_node("UI/HBoxContainer/RepeatButton") onready var SuccessMessage = get_node("UI/SuccessMessage") onready var PlayerChar = get_node("PlayerChar") onready var PlayerBoat = get_node("PlayerBoat") @@ -340,7 +341,7 @@ func generate(): randomize() var radius = 800 - var num_islands = 4 + var num_islands = Globals.game_num_islands var island_files = [] for i in range (10): @@ -485,7 +486,7 @@ func on_dig_stopped(): func on_treasure_found(): -# SuccessMessage.visible = true + RepeatButton.disabled = false pass @@ -614,10 +615,6 @@ func update_player_navigation_target(target_world: Vector2): # # Input & Events # -func _on_generate_button_pressed(): - emit_signal("world_generation_triggered") - generate() - func handle_game_event(event): if Editor and Editor.is_active(): @@ -710,3 +707,14 @@ func _on_IslandMap_visibility_changed(): emit_signal("map_opened") else: emit_signal("map_closed") + + +func _on_GenerateButton_pressed(): + emit_signal("world_generation_triggered") + RepeatButton.disabled = true + generate() + + +func _on_BackButton_pressed(): + get_tree().change_scene("res://Menu.tscn") +