From 93402b77234530653d7170bd5fd9428162ba8833 Mon Sep 17 00:00:00 2001 From: Martin Felis Date: Wed, 21 Jul 2021 22:46:26 +0200 Subject: [PATCH] added icons, auto hide map --- assets/map.svg | 91 +++++++++++++++++++++++ assets/map.svg.import | 34 +++++++++ assets/parrot.svg | 123 ++++++++++++++++++++++++++++++++ assets/parrot.svg.import | 34 +++++++++ assets/shovel_button.svg | 77 ++++++++++++++++++++ assets/shovel_button.svg.import | 34 +++++++++ scenes/Game.tscn | 40 +++++++---- scenes/World.gd | 19 ++++- scenes/pirate.gd | 6 +- 9 files changed, 439 insertions(+), 19 deletions(-) create mode 100644 assets/map.svg create mode 100644 assets/map.svg.import create mode 100644 assets/parrot.svg create mode 100644 assets/parrot.svg.import create mode 100644 assets/shovel_button.svg create mode 100644 assets/shovel_button.svg.import diff --git a/assets/map.svg b/assets/map.svg new file mode 100644 index 0000000..e610ebf --- /dev/null +++ b/assets/map.svg @@ -0,0 +1,91 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + diff --git a/assets/map.svg.import b/assets/map.svg.import new file mode 100644 index 0000000..a386941 --- /dev/null +++ b/assets/map.svg.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/map.svg-ddafebeea8d021f5b8860c188ece7064.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/map.svg" +dest_files=[ "res://.import/map.svg-ddafebeea8d021f5b8860c188ece7064.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/parrot.svg b/assets/parrot.svg new file mode 100644 index 0000000..bceeb0d --- /dev/null +++ b/assets/parrot.svg @@ -0,0 +1,123 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + diff --git a/assets/parrot.svg.import b/assets/parrot.svg.import new file mode 100644 index 0000000..1e618b1 --- /dev/null +++ b/assets/parrot.svg.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/parrot.svg-d7b6842ec6398f3afca3d8c35aac112b.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/parrot.svg" +dest_files=[ "res://.import/parrot.svg-d7b6842ec6398f3afca3d8c35aac112b.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/shovel_button.svg b/assets/shovel_button.svg new file mode 100644 index 0000000..6a60be8 --- /dev/null +++ b/assets/shovel_button.svg @@ -0,0 +1,77 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + diff --git a/assets/shovel_button.svg.import b/assets/shovel_button.svg.import new file mode 100644 index 0000000..3008d5c --- /dev/null +++ b/assets/shovel_button.svg.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/shovel_button.svg-628a9bc45d5d05a53fcc9d2c20db78c8.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/shovel_button.svg" +dest_files=[ "res://.import/shovel_button.svg-628a9bc45d5d05a53fcc9d2c20db78c8.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/scenes/Game.tscn b/scenes/Game.tscn index 5a1de73..76d6dbf 100644 --- a/scenes/Game.tscn +++ b/scenes/Game.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=18 format=2] +[gd_scene load_steps=21 format=2] [ext_resource path="res://scenes/World.gd" type="Script" id=1] [ext_resource path="res://scenes/Grid.gd" type="Script" id=2] @@ -11,8 +11,11 @@ [ext_resource path="res://assets/boat.svg" type="Texture" id=9] [ext_resource path="res://assets/shovel.svg" type="Texture" id=10] [ext_resource path="res://assets/Yeah.png" type="Texture" id=11] +[ext_resource path="res://assets/shovel_button.svg" type="Texture" id=12] [ext_resource path="res://scenes/SoundEffectsPlayer.gd" type="Script" id=13] [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] [sub_resource type="DynamicFont" id=1] size = 27 @@ -293,36 +296,43 @@ __meta__ = { "_edit_use_anchors_": false } +[node name="Timer" type="Timer" parent="World/UI/IslandMap"] + [node name="VBoxContainer" type="VBoxContainer" parent="World/UI"] anchor_left = 1.0 anchor_right = 1.0 anchor_bottom = 1.0 -margin_left = -115.0 -margin_top = 92.0 +margin_left = -128.0 +rect_scale = Vector2( 0.5, 0.5 ) custom_constants/separation = 21 +alignment = 1 __meta__ = { "_edit_use_anchors_": false } [node name="MapButton" type="Button" parent="World/UI/VBoxContainer"] -margin_right = 115.0 -margin_bottom = 100.0 +margin_right = 291.0 +margin_bottom = 262.0 rect_min_size = Vector2( 100, 100 ) -text = "Map" +icon = ExtResource( 15 ) +flat = true [node name="BirdyButton" type="Button" parent="World/UI/VBoxContainer"] -margin_top = 121.0 -margin_right = 115.0 -margin_bottom = 221.0 +margin_top = 283.0 +margin_right = 291.0 +margin_bottom = 545.0 rect_min_size = Vector2( 100, 100 ) -text = "Birdy" +icon = ExtResource( 16 ) +flat = true [node name="DigButton" type="Button" parent="World/UI/VBoxContainer"] -margin_top = 242.0 -margin_right = 115.0 -margin_bottom = 342.0 +margin_top = 566.0 +margin_right = 291.0 +margin_bottom = 828.0 rect_min_size = Vector2( 100, 100 ) text = "Dig" +icon = ExtResource( 12 ) +flat = true [node name="SuccessMessage" type="Control" parent="World/UI"] anchor_left = 0.5 @@ -344,9 +354,9 @@ anchor_left = 0.5 anchor_top = 0.5 anchor_right = 0.5 anchor_bottom = 0.5 -margin_left = -706.0 +margin_left = -700.96 margin_top = -264.0 -margin_right = 706.0 +margin_right = 711.04 margin_bottom = 264.0 mouse_filter = 2 texture = ExtResource( 11 ) diff --git a/scenes/World.gd b/scenes/World.gd index 9df8a11..b123037 100644 --- a/scenes/World.gd +++ b/scenes/World.gd @@ -27,6 +27,7 @@ onready var BirdyButton = get_node("UI/VBoxContainer/BirdyButton") onready var DigButton = get_node("UI/VBoxContainer/DigButton") onready var BirdyTimer = get_node("Birdy/Timer") +onready var MapTimer = get_node("UI/IslandMap/Timer") var Island = preload("Island.gd") var SpringDamper = preload("res://SpringDamper.gd") @@ -58,6 +59,8 @@ var birdy_spring_v = Vector2.ZERO var birdy_spring_xt = Vector2.ONE var birdy_duration = 4.0 +var map_duration = 4.0 + signal digging_started signal world_generation_triggered signal wrong_digsite @@ -128,6 +131,9 @@ func _process(delta): if bird_flying == true: bird_flying = false emit_signal("bird_flight_end") + + if MapTimer.time_left == 0: + emit_signal("map_closed") func draw_hex_path (path: Array, color: Color): @@ -428,15 +434,20 @@ func on_dig_stopped(): func on_treasure_found(): - SuccessMessage.visible = true +# SuccessMessage.visible = true + pass func on_map_opened(): BirdyButton.disabled = true + IslandMap.visible = true + MapTimer.one_shot = true + MapTimer.start(map_duration) func on_map_closed(): BirdyButton.disabled = false + IslandMap.visible = false func on_bird_flight_started(): @@ -620,7 +631,11 @@ func _unhandled_input(event): func _on_MapButton_pressed(): - IslandMap.visible = !IslandMap.visible + if IslandMap.visible: + emit_signal("map_closed") + else: + emit_signal("map_opened") + func _on_BirdyButton_pressed(): diff --git a/scenes/pirate.gd b/scenes/pirate.gd index 9f3dacf..28e692f 100644 --- a/scenes/pirate.gd +++ b/scenes/pirate.gd @@ -45,7 +45,10 @@ func _physics_process(delta): velocity = Vector2.ZERO else: velocity = r_to_target.normalized() * speed - + + if state == State.Digging: + velocity = Vector2.ZERO + position = position + velocity * delta var tile = Globals.WorldToHex(position) @@ -71,7 +74,6 @@ func on_leave_island(): func on_dig_start(): - print ("Start digging") state = State.Digging DigTimer.start(2.0)