diff --git a/Game.gd b/Game.gd index 3ab2d89..eb0f1fb 100644 --- a/Game.gd +++ b/Game.gd @@ -18,6 +18,7 @@ onready var chunk3 := $chunk3 onready var redhat := $RedHat onready var game_ui := $GameUI onready var music := $MusicPlayer +onready var sndKnock := $SoundKnock onready var House := preload("res://objects/house/House.tscn") @@ -30,8 +31,7 @@ var wolf_period: int var is_wolf_from_left: bool var is_wolf_watching := false -var difficulty: int -var scores_table_name: String +var difficulty: String var gen_thread := Thread.new() var gen_thread_mutex := Mutex.new() @@ -44,8 +44,6 @@ var debug_mode := 0 # Game settings: NORMAL const RUN_SPEED_NORMAL := 5.0 const STRAFE_SPEED_NORMAL := 1.5 -const TIME_LIMIT_NORMAL := 80.0 -const CHUNKS_TOTAL_NORMAL := 20 const LIVES_NORMAL := 3 const FILLED_BLOCK_LENGTH_NORMAL := 10 const EMPTY_BLOCK_LENGTH_NORMAL := 3 @@ -56,14 +54,14 @@ const STONE_PROBABILITY_NORMAL := 75 const FLOWER_PROBABILITY_NORMAL := 50 const WOLF_PERIOD_NORMAL := 5 -func setup_game(new_difficulty: int): - match new_difficulty: - GameDifficulty.NORMAL: - difficulty = new_difficulty - scores_table_name = Settings.SCORES_TABLE_NORMAL +var startup_time_limit: float + +func setup_game(): + redhat.TIME_LIMIT = startup_time_limit + match difficulty: + Settings.SCORES_TABLE_NORMAL: redhat.RUN_SPEED = RUN_SPEED_NORMAL redhat.STRAFE_SPEED = STRAFE_SPEED_NORMAL - redhat.TIME_LIMIT = TIME_LIMIT_NORMAL redhat.lives = LIVES_NORMAL objgen.FILLED_BLOCK_LENGTH = FILLED_BLOCK_LENGTH_NORMAL objgen.EMPTY_BLOCK_LENGTH = EMPTY_BLOCK_LENGTH_NORMAL @@ -72,7 +70,6 @@ func setup_game(new_difficulty: int): objgen.LOG_PROBABILITY = LOG_PROBABILITY_NORMAL objgen.STONE_PROBABILITY = STONE_PROBABILITY_NORMAL objgen.FLOWER_PROBABILITY = FLOWER_PROBABILITY_NORMAL - chunks_left = CHUNKS_TOTAL_NORMAL WOLD_PERIOD = WOLF_PERIOD_NORMAL game_ui.high_score = Settings.get_high_score(Settings.SCORES_TABLE_NORMAL) _: @@ -80,12 +77,12 @@ func setup_game(new_difficulty: int): emit_signal("quit") func save_score(score:int): - Settings.set_score(scores_table_name, score) + Settings.set_score(difficulty, score) Settings.save() func _ready(): - setup_game(GameDifficulty.NORMAL) + setup_game() wolf_period = WOLD_PERIOD is_wolf_from_left = true # TODO random? regenerate_map(chunk1) @@ -261,6 +258,8 @@ func _on_RedHat_loose(_reason): func _on_RedHat_win(): + sndKnock.play() + music.stop() $GameUI.on_win() yield(get_tree().create_timer(END_GAME_TIMEOUT), "timeout") quit_game() diff --git a/Game.tscn b/Game.tscn index bf3a563..bc62724 100644 --- a/Game.tscn +++ b/Game.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=10 format=2] +[gd_scene load_steps=11 format=2] [ext_resource path="res://Game.gd" type="Script" id=1] [ext_resource path="res://objects/ground/ground.tscn" type="PackedScene" id=2] @@ -9,6 +9,7 @@ [ext_resource path="res://configs/default_env.tres" type="Environment" id=7] [ext_resource path="res://objects/ObjGenerator.gd" type="Script" id=8] [ext_resource path="res://audio/389788__fmceretta__fun-music.mp3" type="AudioStream" id=9] +[ext_resource path="res://audio/Knock (modified) - 256513.mp3" type="AudioStream" id=10] [node name="Game" type="Spatial"] script = ExtResource( 1 ) @@ -77,6 +78,9 @@ stream = ExtResource( 9 ) volume_db = -13.983 autoplay = true +[node name="SoundKnock" type="AudioStreamPlayer" parent="."] +stream = ExtResource( 10 ) + [connection signal="flowers_changed" from="RedHat" to="GameUI" method="on_flowers_changed"] [connection signal="lives_changed" from="RedHat" to="GameUI" method="on_lives_changed"] [connection signal="loose" from="RedHat" to="." method="_on_RedHat_loose"] diff --git a/Main.gd b/Main.gd index 57e1a19..1acc390 100644 --- a/Main.gd +++ b/Main.gd @@ -30,6 +30,9 @@ func open_menu(): func start_game(): unload() cur_scene = Game.instance() + cur_scene.difficulty = Settings.SCORES_TABLE_NORMAL + cur_scene.startup_time_limit = 80.0 + cur_scene.chunks_left = 20 add_child(cur_scene) Input.mouse_mode = Input.MOUSE_MODE_CAPTURED cur_scene.connect("quit", self, "open_menu") diff --git a/audio/Knock (modified) - 256513.mp3 b/audio/Knock (modified) - 256513.mp3 new file mode 100644 index 0000000..578a279 Binary files /dev/null and b/audio/Knock (modified) - 256513.mp3 differ diff --git a/audio/Knock (modified) - 256513.mp3.import b/audio/Knock (modified) - 256513.mp3.import new file mode 100644 index 0000000..63725ab --- /dev/null +++ b/audio/Knock (modified) - 256513.mp3.import @@ -0,0 +1,15 @@ +[remap] + +importer="mp3" +type="AudioStreamMP3" +path="res://.import/Knock (modified) - 256513.mp3-ec7150bbd5fdf3584074fc72bfb2a80b.mp3str" + +[deps] + +source_file="res://audio/Knock (modified) - 256513.mp3" +dest_files=[ "res://.import/Knock (modified) - 256513.mp3-ec7150bbd5fdf3584074fc72bfb2a80b.mp3str" ] + +[params] + +loop=false +loop_offset=0 diff --git a/audio/MenuClick - 448080__breviceps__wet-click.wav b/audio/MenuClick - 448080__breviceps__wet-click.wav new file mode 100644 index 0000000..c35a2e5 Binary files /dev/null and b/audio/MenuClick - 448080__breviceps__wet-click.wav differ diff --git a/audio/MenuClick - 448080__breviceps__wet-click.wav.import b/audio/MenuClick - 448080__breviceps__wet-click.wav.import new file mode 100644 index 0000000..143fb24 --- /dev/null +++ b/audio/MenuClick - 448080__breviceps__wet-click.wav.import @@ -0,0 +1,23 @@ +[remap] + +importer="wav" +type="AudioStreamSample" +path="res://.import/MenuClick - 448080__breviceps__wet-click.wav-7cf8e9a48874f555d9ab92723cdc314d.sample" + +[deps] + +source_file="res://audio/MenuClick - 448080__breviceps__wet-click.wav" +dest_files=[ "res://.import/MenuClick - 448080__breviceps__wet-click.wav-7cf8e9a48874f555d9ab92723cdc314d.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_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=0 diff --git a/audio/MenuHover - 422971__dkiller2204__sfxkeypickup.wav b/audio/MenuHover - 422971__dkiller2204__sfxkeypickup.wav new file mode 100644 index 0000000..a8e041b Binary files /dev/null and b/audio/MenuHover - 422971__dkiller2204__sfxkeypickup.wav differ diff --git a/audio/MenuHover - 422971__dkiller2204__sfxkeypickup.wav.import b/audio/MenuHover - 422971__dkiller2204__sfxkeypickup.wav.import new file mode 100644 index 0000000..bf65e3e --- /dev/null +++ b/audio/MenuHover - 422971__dkiller2204__sfxkeypickup.wav.import @@ -0,0 +1,23 @@ +[remap] + +importer="wav" +type="AudioStreamSample" +path="res://.import/MenuHover - 422971__dkiller2204__sfxkeypickup.wav-346fe7ac7ddb7bd95a3fcfbabd76f803.sample" + +[deps] + +source_file="res://audio/MenuHover - 422971__dkiller2204__sfxkeypickup.wav" +dest_files=[ "res://.import/MenuHover - 422971__dkiller2204__sfxkeypickup.wav-346fe7ac7ddb7bd95a3fcfbabd76f803.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_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=0 diff --git a/audio/Pickup - 531175__ryusa__synth-glockenspiel-bell-item-money-gold-coin-pick-up.wav b/audio/Pickup - 531175__ryusa__synth-glockenspiel-bell-item-money-gold-coin-pick-up.wav new file mode 100644 index 0000000..47d83dc Binary files /dev/null and b/audio/Pickup - 531175__ryusa__synth-glockenspiel-bell-item-money-gold-coin-pick-up.wav differ diff --git a/audio/Pickup - 531175__ryusa__synth-glockenspiel-bell-item-money-gold-coin-pick-up.wav.import b/audio/Pickup - 531175__ryusa__synth-glockenspiel-bell-item-money-gold-coin-pick-up.wav.import new file mode 100644 index 0000000..f7df492 --- /dev/null +++ b/audio/Pickup - 531175__ryusa__synth-glockenspiel-bell-item-money-gold-coin-pick-up.wav.import @@ -0,0 +1,23 @@ +[remap] + +importer="wav" +type="AudioStreamSample" +path="res://.import/Pickup - 531175__ryusa__synth-glockenspiel-bell-item-money-gold-coin-pick-up.wav-178ae31b27116cee5aae5db83186f1fc.sample" + +[deps] + +source_file="res://audio/Pickup - 531175__ryusa__synth-glockenspiel-bell-item-money-gold-coin-pick-up.wav" +dest_files=[ "res://.import/Pickup - 531175__ryusa__synth-glockenspiel-bell-item-money-gold-coin-pick-up.wav-178ae31b27116cee5aae5db83186f1fc.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_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=0 diff --git a/characters/redhat/RedHat.gd b/characters/redhat/RedHat.gd index df8e766..7eb0add 100644 --- a/characters/redhat/RedHat.gd +++ b/characters/redhat/RedHat.gd @@ -35,6 +35,7 @@ onready var foot_r := $RedHat/RedHatFootR onready var anim := $AnimationPlayer onready var sndFall := $SoundFall onready var sndSink := $SoundSink +onready var sndPickup := $SoundPickup # Configuration (based on difficulty). var RUN_SPEED: float @@ -278,6 +279,7 @@ func _on_RedHat_area_entered(area:Area): if (state == RUN) or (state == JUMP): area.queue_free() flowers += 1 + sndPickup.play() emit_signal("flowers_changed", flowers) SimpleArea.AreaType.WOLF: if blink_count <= 0: diff --git a/characters/redhat/RedHat.tscn b/characters/redhat/RedHat.tscn index 5afac27..b0a3f3f 100644 --- a/characters/redhat/RedHat.tscn +++ b/characters/redhat/RedHat.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=15 format=2] +[gd_scene load_steps=16 format=2] [ext_resource path="res://audio/346694__deleted_user_2104797__body-fall_02.wav" type="AudioStream" id=1] [ext_resource path="res://characters/redhat/rh-test-foot.tres" type="Material" id=2] @@ -6,6 +6,7 @@ [ext_resource path="res://characters/redhat/rh-test-cloak.tres" type="Material" id=4] [ext_resource path="res://characters/redhat/RedHat.gd" type="Script" id=5] [ext_resource path="res://audio/421184__inspectorj__water-pouring-a.wav" type="AudioStream" id=6] +[ext_resource path="res://audio/Pickup - 531175__ryusa__synth-glockenspiel-bell-item-money-gold-coin-pick-up.wav" type="AudioStream" id=7] [sub_resource type="ArrayMesh" id=1] resource_name = "redhat_Cone001" @@ -166,4 +167,7 @@ stream = ExtResource( 1 ) [node name="SoundSink" type="AudioStreamPlayer" parent="."] stream = ExtResource( 6 ) +[node name="SoundPickup" type="AudioStreamPlayer" parent="."] +stream = ExtResource( 7 ) + [connection signal="area_entered" from="." to="." method="_on_RedHat_area_entered"] diff --git a/ui/MenuUI.gd b/ui/MenuUI.gd index 90d28ed..905b2dd 100644 --- a/ui/MenuUI.gd +++ b/ui/MenuUI.gd @@ -18,10 +18,14 @@ func _ready(): func _on_ButtonQuit_pressed(): + $SoundClick.play() + yield(get_tree().create_timer(0.3), "timeout") emit_signal("quit") func _on_ButtonStart_pressed(): + $SoundClick.play() + yield(get_tree().create_timer(0.3), "timeout") emit_signal("start") @@ -35,8 +39,13 @@ func _input(event): func _on_SoundVolume_drag_ended(_value_changed): #if value_changed: --> Bug? False if clicked instead of dragging. + $SoundClick.play() Settings.save() func _on_SoundVolume_value_changed(value): AudioServer.set_bus_volume_db(Settings.AUDIO_BUS_MASTER, linear2db(value)) Settings.sound_volume = value + + +func _on_hover(): + $SoundHover.play() diff --git a/ui/MenuUI.tscn b/ui/MenuUI.tscn index 2431dc3..b388bc6 100644 --- a/ui/MenuUI.tscn +++ b/ui/MenuUI.tscn @@ -1,8 +1,10 @@ -[gd_scene load_steps=4 format=2] +[gd_scene load_steps=6 format=2] [ext_resource path="res://ui/MenuUI.gd" type="Script" id=1] [ext_resource path="res://ui/balkara_font/balkara_16.tres" type="DynamicFont" id=2] [ext_resource path="res://ui/balkara_font/balkara_32.tres" type="DynamicFont" id=3] +[ext_resource path="res://audio/MenuHover - 422971__dkiller2204__sfxkeypickup.wav" type="AudioStream" id=4] +[ext_resource path="res://audio/MenuClick - 448080__breviceps__wet-click.wav" type="AudioStream" id=5] [node name="MenuUI" type="Control"] pause_mode = 2 @@ -60,7 +62,16 @@ margin_bottom = -30.0 max_value = 1.0 step = 0.01 +[node name="SoundClick" type="AudioStreamPlayer" parent="."] +stream = ExtResource( 5 ) + +[node name="SoundHover" type="AudioStreamPlayer" parent="."] +stream = ExtResource( 4 ) + +[connection signal="mouse_entered" from="ButtonStart" to="." method="_on_hover"] [connection signal="pressed" from="ButtonStart" to="." method="_on_ButtonStart_pressed"] +[connection signal="mouse_entered" from="ButtonQuit" to="." method="_on_hover"] [connection signal="pressed" from="ButtonQuit" to="." method="_on_ButtonQuit_pressed"] [connection signal="drag_ended" from="SoundVolume" to="." method="_on_SoundVolume_drag_ended"] +[connection signal="mouse_entered" from="SoundVolume" to="." method="_on_hover"] [connection signal="value_changed" from="SoundVolume" to="." method="_on_SoundVolume_value_changed"]