Added menu and difficulty levels

master
Martin Felis 2021-08-01 17:24:42 +02:00
parent 2ace012fab
commit bd3d44a783
12 changed files with 380 additions and 17 deletions

View File

@ -21,6 +21,8 @@ var draw_island_bbox = false
var zoom_sailing = 1.0 var zoom_sailing = 1.0
var zoom_birdy = 4 var zoom_birdy = 4
var game_num_islands = 4
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready(): func _ready():
HexGrid.hex_scale = Vector2(hex_size, hex_size) HexGrid.hex_scale = Vector2(hex_size, hex_size)

31
Menu.gd Normal file
View File

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

72
Menu.tscn Normal file
View File

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

67
assets/arrowback.svg Normal file
View File

@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="256"
height="256"
viewBox="0 0 67.733332 67.733335"
version="1.1"
id="svg8"
inkscape:version="0.92.5 (2060ec1f9f, 2020-04-08)"
sodipodi:docname="arrowback.svg">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.35"
inkscape:cx="-23.88777"
inkscape:cy="-514.50325"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
showgrid="true"
inkscape:window-width="394"
inkscape:window-height="1041"
inkscape:window-x="1522"
inkscape:window-y="37"
inkscape:window-maximized="0"
units="px">
<inkscape:grid
type="xygrid"
id="grid1405" />
</sodipodi:namedview>
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-229.26665)">
<path
style="fill:#ffffff;stroke:#4d4d4d;stroke-width:26.45669324;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none;fill-opacity:1"
d="M 101.42773 16 L 20 116 L 20 131 L 101.42773 231 L 140 211 L 100 156 L 250 161 L 229.16602 123.5 L 250 86 L 100 91 L 140 36 L 101.42773 16 z "
transform="matrix(0.26458333,0,0,0.26458333,0,229.26665)"
id="path1384" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

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

68
assets/arrowrepeat.svg Normal file
View File

@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="256"
height="256"
viewBox="0 0 67.733332 67.733335"
version="1.1"
id="svg8"
inkscape:version="0.92.5 (2060ec1f9f, 2020-04-08)"
sodipodi:docname="arrowrepeat.svg">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.7"
inkscape:cx="-84.35613"
inkscape:cy="32.475023"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
showgrid="true"
inkscape:window-width="1518"
inkscape:window-height="1041"
inkscape:window-x="0"
inkscape:window-y="37"
inkscape:window-maximized="0"
units="px">
<inkscape:grid
type="xygrid"
id="grid1405" />
</sodipodi:namedview>
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-229.26665)">
<path
style="fill:#fafafa;fill-opacity:1;stroke:#4d4d4d;stroke-width:5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 13.229167,278.47915 13.229166,14.55208 17.197917,0 14.552083,-6.61458 3.96875,-29.10417 -13.229167,-19.84375 H 30.427083 L 19.84375,246.72915 V 236.14582 L 7.9375,237.46873 v 25.13542 l 19.84375,7.9375 6.614583,-9.26042 -10.583333,-5.29166 7.9375,-6.61459 11.90625,0 5.291667,9.26042 v 14.55208 l -9.260417,7.9375 -11.906249,1.32292 -7.9375,-7.9375 z"
id="path2353"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cccccccccccccccccccccc" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

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

BIN
assets/title logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

View File

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

View File

@ -21,7 +21,7 @@ _global_script_class_icons={
[application] [application]
config/name="Pirate Treasure Hunt" config/name="Pirate Treasure Hunt"
run/main_scene="res://scenes/Game.tscn" run/main_scene="res://Menu.tscn"
config/icon="res://assets/pirate.svg" config/icon="res://assets/pirate.svg"
[autoload] [autoload]

View File

@ -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/World.gd" type="Script" id=1]
[ext_resource path="res://scenes/Grid.gd" type="Script" id=2] [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://scenes/MusicPlayer.gd" type="Script" id=14]
[ext_resource path="res://assets/map.svg" type="Texture" id=15] [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/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] [sub_resource type="DynamicFont" id=1]
size = 27 size = 27
@ -175,21 +177,31 @@ script = ExtResource( 8 )
[node name="UI" type="CanvasLayer" parent="World"] [node name="UI" type="CanvasLayer" parent="World"]
[node name="TopContainer" type="HBoxContainer" parent="World/UI"] [node name="HBoxContainer" type="HBoxContainer" parent="World/UI"]
anchor_right = 1.0
margin_left = 10.0 margin_left = 10.0
margin_top = 10.0 margin_top = 10.0
margin_right = -10.0 margin_right = -10.0
margin_bottom = 20.0 margin_bottom = 10.0
rect_scale = Vector2( 0.25, 0.25 )
__meta__ = { __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[node name="GenerateButton" type="Button" parent="World/UI/TopContainer"] [node name="BackButton" type="Button" parent="World/UI/HBoxContainer"]
margin_right = 113.0 margin_right = 268.0
margin_bottom = 64.0 margin_bottom = 262.0
rect_min_size = Vector2( 64, 64 ) icon = ExtResource( 17 )
text = "Generate World" 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"] [node name="IslandMap" type="TextureRect" parent="World/UI"]
visible = false 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="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="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="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="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/MapButton" to="World" method="_on_MapButton_pressed"]
[connection signal="pressed" from="World/UI/VBoxContainer/BirdyButton" to="World" method="_on_BirdyButton_pressed"] [connection signal="pressed" from="World/UI/VBoxContainer/BirdyButton" to="World" method="_on_BirdyButton_pressed"]

View File

@ -14,6 +14,7 @@ onready var ZoomValueLabel = get_node("UI/DebugContainer/ZoomValue")
onready var HexCoordValueLabel = get_node("UI/DebugContainer/HexCoordValue") onready var HexCoordValueLabel = get_node("UI/DebugContainer/HexCoordValue")
onready var WorldCoordValueLabel = get_node("UI/DebugContainer/WorldCoordValue") onready var WorldCoordValueLabel = get_node("UI/DebugContainer/WorldCoordValue")
onready var TileTypeValueLabel = get_node("UI/DebugContainer/TileTypeValue") 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 SuccessMessage = get_node("UI/SuccessMessage")
onready var PlayerChar = get_node("PlayerChar") onready var PlayerChar = get_node("PlayerChar")
onready var PlayerBoat = get_node("PlayerBoat") onready var PlayerBoat = get_node("PlayerBoat")
@ -340,7 +341,7 @@ func generate():
randomize() randomize()
var radius = 800 var radius = 800
var num_islands = 4 var num_islands = Globals.game_num_islands
var island_files = [] var island_files = []
for i in range (10): for i in range (10):
@ -485,7 +486,7 @@ func on_dig_stopped():
func on_treasure_found(): func on_treasure_found():
# SuccessMessage.visible = true RepeatButton.disabled = false
pass pass
@ -614,10 +615,6 @@ func update_player_navigation_target(target_world: Vector2):
# #
# Input & Events # Input & Events
# #
func _on_generate_button_pressed():
emit_signal("world_generation_triggered")
generate()
func handle_game_event(event): func handle_game_event(event):
if Editor and Editor.is_active(): if Editor and Editor.is_active():
@ -710,3 +707,14 @@ func _on_IslandMap_visibility_changed():
emit_signal("map_opened") emit_signal("map_opened")
else: else:
emit_signal("map_closed") 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")