Added music and sound effects

master
Martin Felis 2021-07-20 22:44:13 +02:00
parent d9a2d936ba
commit 659c0fcfcc
39 changed files with 401 additions and 16 deletions

View File

@ -15,7 +15,7 @@ var DebugLabel = null
var hex_size = 128 var hex_size = 128
var debug_nav = false var debug_nav = false
var draw_grid = false var draw_grid = true
# 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():

BIN
audio/effects/hauruck.mp3 Normal file

Binary file not shown.

View File

@ -0,0 +1,15 @@
[remap]
importer="mp3"
type="AudioStreamMP3"
path="res://.import/hauruck.mp3-126c13d0c4e966cb60459eb15346cc20.mp3str"
[deps]
source_file="res://audio/effects/hauruck.mp3"
dest_files=[ "res://.import/hauruck.mp3-126c13d0c4e966cb60459eb15346cc20.mp3str" ]
[params]
loop=true
loop_offset=0

Binary file not shown.

View File

@ -0,0 +1,15 @@
[remap]
importer="mp3"
type="AudioStreamMP3"
path="res://.import/hier_ist_er_nicht.mp3-528b3c9fbc5bfbeb9eb03dabb60e9514.mp3str"
[deps]
source_file="res://audio/effects/hier_ist_er_nicht.mp3"
dest_files=[ "res://.import/hier_ist_er_nicht.mp3-528b3c9fbc5bfbeb9eb03dabb60e9514.mp3str" ]
[params]
loop=true
loop_offset=0

Binary file not shown.

View File

@ -0,0 +1,15 @@
[remap]
importer="mp3"
type="AudioStreamMP3"
path="res://.import/hilf_mir_papagei.mp3-9b2d4bcf46843ac4b62fecac52f5880c.mp3str"
[deps]
source_file="res://audio/effects/hilf_mir_papagei.mp3"
dest_files=[ "res://.import/hilf_mir_papagei.mp3-9b2d4bcf46843ac4b62fecac52f5880c.mp3str" ]
[params]
loop=true
loop_offset=0

Binary file not shown.

View File

@ -0,0 +1,15 @@
[remap]
importer="mp3"
type="AudioStreamMP3"
path="res://.import/juhuu_gefunden.mp3-d09b438b198abe9ddf317dab4a829662.mp3str"
[deps]
source_file="res://audio/effects/juhuu_gefunden.mp3"
dest_files=[ "res://.import/juhuu_gefunden.mp3-d09b438b198abe9ddf317dab4a829662.mp3str" ]
[params]
loop=true
loop_offset=0

Binary file not shown.

View File

@ -0,0 +1,15 @@
[remap]
importer="mp3"
type="AudioStreamMP3"
path="res://.import/noch_einen_schatz_finden.mp3-7c3e7f84760b8dd45443a9c17487750e.mp3str"
[deps]
source_file="res://audio/effects/noch_einen_schatz_finden.mp3"
dest_files=[ "res://.import/noch_einen_schatz_finden.mp3-7c3e7f84760b8dd45443a9c17487750e.mp3str" ]
[params]
loop=true
loop_offset=0

BIN
audio/effects/wheee.mp3 Normal file

Binary file not shown.

View File

@ -0,0 +1,15 @@
[remap]
importer="mp3"
type="AudioStreamMP3"
path="res://.import/wheee.mp3-114481cbf7c46661183c3d201e121939.mp3str"
[deps]
source_file="res://audio/effects/wheee.mp3"
dest_files=[ "res://.import/wheee.mp3-114481cbf7c46661183c3d201e121939.mp3str" ]
[params]
loop=true
loop_offset=0

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,15 @@
[remap]
importer="mp3"
type="AudioStreamMP3"
path="res://.import/wo_war_nochmal_der_schatz.mp3-33340d1382b5235694d3645775d65afb.mp3str"
[deps]
source_file="res://audio/effects/wo_war_nochmal_der_schatz.mp3"
dest_files=[ "res://.import/wo_war_nochmal_der_schatz.mp3-33340d1382b5235694d3645775d65afb.mp3str" ]
[params]
loop=true
loop_offset=0

View File

@ -0,0 +1,15 @@
[remap]
importer="mp3"
type="AudioStreamMP3"
path="res://.import/looperman-l-2353443-0126764-yungkimchi-adventure-synthwave-arp.mp3-addf6a44c60d5349e357a73df59d2f6e.mp3str"
[deps]
source_file="res://audio/music/looperman-l-2353443-0126764-yungkimchi-adventure-synthwave-arp.mp3"
dest_files=[ "res://.import/looperman-l-2353443-0126764-yungkimchi-adventure-synthwave-arp.mp3-addf6a44c60d5349e357a73df59d2f6e.mp3str" ]
[params]
loop=true
loop_offset=0

View File

@ -0,0 +1,21 @@
[remap]
importer="wav"
type="AudioStreamSample"
path="res://.import/looperman-l-2353443-0126764-yungkimchi-adventure-synthwave-arp.wav-1db12a8cec1c474148650c1bddcc1e91.sample"
[deps]
source_file="res://audio/music/looperman-l-2353443-0126764-yungkimchi-adventure-synthwave-arp.wav"
dest_files=[ "res://.import/looperman-l-2353443-0126764-yungkimchi-adventure-synthwave-arp.wav-1db12a8cec1c474148650c1bddcc1e91.sample" ]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop=false
compress/mode=0

View File

@ -0,0 +1,15 @@
[remap]
importer="mp3"
type="AudioStreamMP3"
path="res://.import/looperman-l-2550509-0151182-goin-on-an-adventure.mp3-98542903c1b049edcff8ef66a7b3e7c4.mp3str"
[deps]
source_file="res://audio/music/looperman-l-2550509-0151182-goin-on-an-adventure.mp3"
dest_files=[ "res://.import/looperman-l-2550509-0151182-goin-on-an-adventure.mp3-98542903c1b049edcff8ef66a7b3e7c4.mp3str" ]
[params]
loop=true
loop_offset=0

View File

@ -0,0 +1,21 @@
[remap]
importer="wav"
type="AudioStreamSample"
path="res://.import/looperman-l-2550509-0151182-goin-on-an-adventure.wav-164c13a935cb6b863bc6166c4afdf271.sample"
[deps]
source_file="res://audio/music/looperman-l-2550509-0151182-goin-on-an-adventure.wav"
dest_files=[ "res://.import/looperman-l-2550509-0151182-goin-on-an-adventure.wav-164c13a935cb6b863bc6166c4afdf271.sample" ]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop=false
compress/mode=0

View File

@ -0,0 +1,15 @@
[remap]
importer="mp3"
type="AudioStreamMP3"
path="res://.import/looperman-l-2648038-0125430-imthewizzy-adventure.mp3-77d12c5a8191e0995c347435d5a08d32.mp3str"
[deps]
source_file="res://audio/music/looperman-l-2648038-0125430-imthewizzy-adventure.mp3"
dest_files=[ "res://.import/looperman-l-2648038-0125430-imthewizzy-adventure.mp3-77d12c5a8191e0995c347435d5a08d32.mp3str" ]
[params]
loop=true
loop_offset=0

View File

@ -0,0 +1,21 @@
[remap]
importer="wav"
type="AudioStreamSample"
path="res://.import/looperman-l-2648038-0125430-imthewizzy-adventure.wav-fbe07fb77581d1abb3ea8845407840ec.sample"
[deps]
source_file="res://audio/music/looperman-l-2648038-0125430-imthewizzy-adventure.wav"
dest_files=[ "res://.import/looperman-l-2648038-0125430-imthewizzy-adventure.wav-fbe07fb77581d1abb3ea8845407840ec.sample" ]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop=false
compress/mode=0

View File

@ -0,0 +1,15 @@
[remap]
importer="mp3"
type="AudioStreamMP3"
path="res://.import/looperman-l-2762820-0244446-nick-mira-type-8bit-adventure.mp3-d7c5438cde05bb54b09e12f548c7cc30.mp3str"
[deps]
source_file="res://audio/music/looperman-l-2762820-0244446-nick-mira-type-8bit-adventure.mp3"
dest_files=[ "res://.import/looperman-l-2762820-0244446-nick-mira-type-8bit-adventure.mp3-d7c5438cde05bb54b09e12f548c7cc30.mp3str" ]
[params]
loop=true
loop_offset=0

View File

@ -0,0 +1,21 @@
[remap]
importer="wav"
type="AudioStreamSample"
path="res://.import/looperman-l-2762820-0244446-nick-mira-type-8bit-adventure.wav-5d849cbafd3780327785fa958a2c3be9.sample"
[deps]
source_file="res://audio/music/looperman-l-2762820-0244446-nick-mira-type-8bit-adventure.wav"
dest_files=[ "res://.import/looperman-l-2762820-0244446-nick-mira-type-8bit-adventure.wav-5d849cbafd3780327785fa958a2c3be9.sample" ]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop=false
compress/mode=0

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=16 format=2] [gd_scene load_steps=18 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]
@ -11,6 +11,8 @@
[ext_resource path="res://assets/boat.svg" type="Texture" id=9] [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/shovel.svg" type="Texture" id=10]
[ext_resource path="res://assets/Yeah.png" type="Texture" id=11] [ext_resource path="res://assets/Yeah.png" type="Texture" id=11]
[ext_resource path="res://audio/music/looperman-l-2550509-0151182-goin-on-an-adventure.mp3" type="AudioStream" id=12]
[ext_resource path="res://scenes/SoundEffectsPlayer.gd" type="Script" id=13]
[sub_resource type="DynamicFont" id=1] [sub_resource type="DynamicFont" id=1]
size = 27 size = 27
@ -114,6 +116,7 @@ text = "Grass"
script = ExtResource( 1 ) script = ExtResource( 1 )
[node name="Grid" type="Node2D" parent="World"] [node name="Grid" type="Node2D" parent="World"]
visible = false
script = ExtResource( 2 ) script = ExtResource( 2 )
[node name="Islands" type="Node2D" parent="World"] [node name="Islands" type="Node2D" parent="World"]
@ -324,6 +327,7 @@ margin_top = -20.0
margin_right = 20.0 margin_right = 20.0
margin_bottom = 20.0 margin_bottom = 20.0
rect_scale = Vector2( 0.5, 0.5 ) rect_scale = Vector2( 0.5, 0.5 )
mouse_filter = 1
__meta__ = { __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
@ -345,15 +349,13 @@ __meta__ = {
[node name="DigSites" type="Node2D" parent="World"] [node name="DigSites" type="Node2D" parent="World"]
[node name="PlayerChar" type="KinematicBody2D" parent="World"] [node name="PlayerChar" type="Node2D" parent="World"]
script = ExtResource( 5 ) script = ExtResource( 5 )
[node name="Pirate" type="Sprite" parent="World/PlayerChar"] [node name="Pirate" type="Sprite" parent="World/PlayerChar"]
scale = Vector2( 0.45498, 0.45498 ) scale = Vector2( 0.45498, 0.45498 )
texture = ExtResource( 3 ) texture = ExtResource( 3 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="World/PlayerChar"]
[node name="Shovel" type="Sprite" parent="World/PlayerChar"] [node name="Shovel" type="Sprite" parent="World/PlayerChar"]
visible = false visible = false
scale = Vector2( 0.455, 0.455 ) scale = Vector2( 0.455, 0.455 )
@ -385,12 +387,26 @@ render_target_update_mode = 1
[node name="Camera2D" type="Camera2D" parent="IslandMapRenderer"] [node name="Camera2D" type="Camera2D" parent="IslandMapRenderer"]
[node name="MusicPlayer" type="AudioStreamPlayer" parent="."]
stream = ExtResource( 12 )
volume_db = -16.124
autoplay = true
[node name="SoundEffectsPlayer" type="AudioStreamPlayer" parent="."]
script = ExtResource( 13 )
[connection signal="value_changed" from="Editor/UI/Editor/IslandIndex" to="Editor" method="_on_IslandIndex_value_changed"] [connection signal="value_changed" from="Editor/UI/Editor/IslandIndex" to="Editor" method="_on_IslandIndex_value_changed"]
[connection signal="pressed" from="Editor/UI/Editor/ClearWorldButton" to="Editor" method="_on_ClearWorldButton_pressed"] [connection signal="pressed" from="Editor/UI/Editor/ClearWorldButton" to="Editor" method="_on_ClearWorldButton_pressed"]
[connection signal="pressed" from="Editor/UI/Editor/LoadWorldButton" to="Editor" method="_on_LoadWorldButton_pressed"] [connection signal="pressed" from="Editor/UI/Editor/LoadWorldButton" to="Editor" method="_on_LoadWorldButton_pressed"]
[connection signal="pressed" from="Editor/UI/Editor/SaveWorldButton" to="Editor" method="_on_SaveWorldButton_pressed"] [connection signal="pressed" from="Editor/UI/Editor/SaveWorldButton" to="Editor" method="_on_SaveWorldButton_pressed"]
[connection signal="bird_flight_start" from="World" to="SoundEffectsPlayer" method="_on_World_bird_flight_start"]
[connection signal="map_opened" from="World" to="SoundEffectsPlayer" method="_on_World_map_opened"]
[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/TopContainer/GenerateButton" to="World" method="_on_generate_button_pressed"]
[connection signal="toggled" from="World/UI/TopContainer/EditIslandButton" to="Editor" method="_on_EditIslandButton_toggled"] [connection signal="toggled" from="World/UI/TopContainer/EditIslandButton" to="Editor" method="_on_EditIslandButton_toggled"]
[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"]
[connection signal="pressed" from="World/UI/VBoxContainer/DigButton" to="World" method="_on_DigButton_pressed"] [connection signal="pressed" from="World/UI/VBoxContainer/DigButton" to="World" method="_on_DigButton_pressed"]

View File

@ -5,6 +5,7 @@ var offset_world = Vector2.ZERO
var center_coord = Vector2.ZERO var center_coord = Vector2.ZERO
var center_world_coord = Vector2.ZERO var center_world_coord = Vector2.ZERO
var rect_local = Rect2() var rect_local = Rect2()
var rect_world = Rect2()
var radius_world = 0.0 var radius_world = 0.0
var is_active = false var is_active = false
var landing_site_local_coord = null var landing_site_local_coord = null
@ -31,6 +32,8 @@ func set_tile(coord: Vector2, value: String):
func set_offset_world(value: Vector2): func set_offset_world(value: Vector2):
offset_world = value offset_world = value
rect_world.position = rect_local.position + value
rect_world.size = rect_local.size
func clear_island(): func clear_island():
@ -171,7 +174,6 @@ func _draw():
draw_set_transform (treasure_local_coords + offset_world, 0, Vector2.ONE) draw_set_transform (treasure_local_coords + offset_world, 0, Vector2.ONE)
draw_polygon(HexTileDrawer.HexPoints, HexTileDrawer.create_color_array("#922")) draw_polygon(HexTileDrawer.HexPoints, HexTileDrawer.create_color_array("#922"))
draw_set_transform(transform.origin + offset_world, transform.get_rotation(), transform.get_scale()) draw_set_transform(transform.origin, transform.get_rotation(), transform.get_scale())
if Globals.debug_nav and is_active: draw_rect(rect_world, Color.red, false)
draw_rect(rect_local, Color.red, false)

View File

@ -0,0 +1,52 @@
extends AudioStreamPlayer
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
var hauruck = preload("res://audio/effects/hauruck.mp3")
var hilf_mir_papagei = preload("res://audio/effects/hilf_mir_papagei.mp3")
var hier_ist_er_nicht = preload("res://audio/effects/hier_ist_er_nicht.mp3")
var juhuu_gefunden = preload("res://audio/effects/juhuu_gefunden.mp3")
var noch_einen_schatz_finden = preload("res://audio/effects/noch_einen_schatz_finden.mp3")
var wheee = preload("res://audio/effects/wheee.mp3")
var wo_war_nochmal_der_schatz = preload("res://audio/effects/wo_war_nochmal_der_schatz.mp3")
# Called when the node enters the scene tree for the first time.
func _ready():
hauruck.loop = false
hilf_mir_papagei.loop = false
hier_ist_er_nicht.loop = false
juhuu_gefunden.loop = false
wheee.loop = false
wo_war_nochmal_der_schatz.loop = false
noch_einen_schatz_finden.loop = false
func _on_World_treasure_found():
stream = juhuu_gefunden
play()
func _on_World_map_opened():
stream = wo_war_nochmal_der_schatz
play()
func _on_World_bird_flight_start():
stream = hilf_mir_papagei
play()
func _on_World_wrong_digsite():
stream = hier_ist_er_nicht
play()
func _on_World_world_generation_triggered():
stream = noch_einen_schatz_finden
play()

View File

@ -22,6 +22,10 @@ onready var FPSValueLabel = get_node("UI/TopContainer/FPSValue")
onready var IslandMap = get_node("UI/IslandMap") onready var IslandMap = get_node("UI/IslandMap")
onready var IslandMapRenderer = get_node("../IslandMapRenderer") onready var IslandMapRenderer = get_node("../IslandMapRenderer")
onready var MapButton = get_node("UI/VBoxContainer/MapButton")
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 BirdyTimer = get_node("Birdy/Timer")
var Island = preload("Island.gd") var Island = preload("Island.gd")
@ -46,6 +50,7 @@ var player_path_plan_end = null
var hex_line_path = [] var hex_line_path = []
var treasure_island = null var treasure_island = null
var treasure_map_rendered = false var treasure_map_rendered = false
var bird_flying = false
var birdy_spring = null var birdy_spring = null
var birdy_spring_x = Vector2.ONE var birdy_spring_x = Vector2.ONE
@ -53,7 +58,13 @@ var birdy_spring_v = Vector2.ZERO
var birdy_spring_xt = Vector2.ONE var birdy_spring_xt = Vector2.ONE
var birdy_duration = 4.0 var birdy_duration = 4.0
signal world_generation_triggered
signal wrong_digsite
signal treasure_found signal treasure_found
signal bird_flight_start
signal bird_flight_end
signal map_opened
signal map_closed
# #
# Godot Functions # Godot Functions
@ -71,6 +82,11 @@ func _ready():
PlayerChar.connect("dig_stopped", self, "on_dig_stopped") PlayerChar.connect("dig_stopped", self, "on_dig_stopped")
self.connect("treasure_found", self, "on_treasure_found") self.connect("treasure_found", self, "on_treasure_found")
self.connect("bird_flight_start", self, "on_bird_flight_started")
self.connect("bird_flight_end", self, "on_bird_flight_ended")
self.connect("map_opened", self, "on_map_opened")
self.connect("map_closed", self, "on_map_closed")
func _process(delta): func _process(delta):
if is_editor_active(): if is_editor_active():
@ -99,6 +115,15 @@ func _process(delta):
if BirdyTimer.time_left == 0: if BirdyTimer.time_left == 0:
birdy_spring_xt = Vector2.ONE birdy_spring_xt = Vector2.ONE
if birdy_spring_x.x > 1.2:
if bird_flying == false:
bird_flying = true
emit_signal("bird_flight_start")
elif birdy_spring_x.x < 1.1:
if bird_flying == true:
bird_flying = false
emit_signal("bird_flight_end")
func draw_hex_path (path: Array, color: Color): func draw_hex_path (path: Array, color: Color):
var path_len = len(path) var path_len = len(path)
@ -159,7 +184,7 @@ func get_tile_type(world_coord: Vector2):
func add_island_at(file_name, offset_world: Vector2): func add_island_at(file_name, offset_world: Vector2):
var island = Island.new() var island = Island.new()
island.load_island(file_name) island.load_island(file_name)
island.offset_world = offset_world island.set_offset_world(offset_world)
Islands.add_child(island) Islands.add_child(island)
@ -268,7 +293,7 @@ func generate():
island.load_island(file_name) island.load_island(file_name)
var rand_coord = Vector2(rng.randi_range(-radius, radius), rng.randi_range(-radius, radius)) var rand_coord = Vector2(rng.randi_range(-radius, radius), rng.randi_range(-radius, radius))
island.offset_world = Globals.WorldToHexCenter(rand_coord) island.set_offset_world(Globals.WorldToHexCenter(rand_coord))
var location_valid = check_island_location_valid(island) var location_valid = check_island_location_valid(island)
var overlap_retry_num = 0 var overlap_retry_num = 0
@ -279,7 +304,7 @@ func generate():
overlap_retry_num = overlap_retry_num + 1 overlap_retry_num = overlap_retry_num + 1
rand_coord = Vector2(rng.randi_range(-radius, radius), rng.randi_range(-radius, radius)) rand_coord = Vector2(rng.randi_range(-radius, radius), rng.randi_range(-radius, radius))
island.offset_world = Globals.WorldToHexCenter(rand_coord) island.set_offset_world(Globals.WorldToHexCenter(rand_coord))
location_valid = check_island_location_valid(island) location_valid = check_island_location_valid(island)
if !location_valid: if !location_valid:
@ -387,6 +412,7 @@ func on_dig_stopped():
on_treasure_found() on_treasure_found()
dig_site.texture = DigSiteTreasureSprite dig_site.texture = DigSiteTreasureSprite
else: else:
emit_signal("wrong_digsite")
dig_site.texture = DigSiteSprite dig_site.texture = DigSiteSprite
DigSites.add_child(dig_site) DigSites.add_child(dig_site)
@ -396,6 +422,28 @@ func on_treasure_found():
SuccessMessage.visible = true SuccessMessage.visible = true
func on_map_opened():
BirdyButton.disabled = true
DigButton.disabled = true
func on_map_closed():
BirdyButton.disabled = false
DigButton.disabled = false
func on_bird_flight_started():
print ("flight started")
DigButton.disabled = true
MapButton.disabled = true
func on_bird_flight_ended():
print ("flight ended")
DigButton.disabled = false
MapButton.disabled = false
func check_player_near_anchor(): func check_player_near_anchor():
if current_island == null: if current_island == null:
return false return false
@ -500,6 +548,7 @@ func update_player_navigation_target(target_world: Vector2):
# Input & Events # Input & Events
# #
func _on_generate_button_pressed(): func _on_generate_button_pressed():
emit_signal("world_generation_triggered")
generate() generate()
@ -507,6 +556,9 @@ func handle_game_event(event):
if Editor and Editor.is_active(): if Editor and Editor.is_active():
return false return false
if bird_flying:
return false
if event is InputEventMouseButton: if event is InputEventMouseButton:
# Move main character # Move main character
if event.pressed and event.button_index == BUTTON_LEFT: if event.pressed and event.button_index == BUTTON_LEFT:
@ -580,3 +632,10 @@ func _on_DigButton_pressed():
print ("dig pressed") print ("dig pressed")
if PlayerChar.state == PlayerChar.State.Walking: if PlayerChar.state == PlayerChar.State.Walking:
PlayerChar.on_dig_start() PlayerChar.on_dig_start()
func _on_IslandMap_visibility_changed():
if IslandMap.visible:
emit_signal("map_opened")
else:
emit_signal("map_closed")

View File

@ -1,4 +1,4 @@
extends KinematicBody2D extends Node2D
export (int) var speed = 200 export (int) var speed = 200
@ -36,10 +36,17 @@ func get_input():
velocity = velocity.normalized() * speed velocity = velocity.normalized() * speed
func _physics_process(_delta): func _physics_process(delta):
velocity = position.direction_to(target) * speed var r_to_target = target - position
if position.distance_to(target) > 5: var dist = r_to_target.length()
velocity = move_and_slide(velocity)
if delta > 0.0001 and dist < speed * delta:
position = target
velocity = Vector2.ZERO
else:
velocity = r_to_target.normalized() * speed
position = position + velocity * delta
var tile = Globals.WorldToHex(position) var tile = Globals.WorldToHex(position)
if tile != cur_tile: if tile != cur_tile: