Skip to content

Commit

Permalink
Add more sounds. Add possibility for more levels.
Browse files Browse the repository at this point in the history
  • Loading branch information
gshadows committed Feb 5, 2023
1 parent c9bc6a0 commit a70f8d1
Show file tree
Hide file tree
Showing 15 changed files with 132 additions and 16 deletions.
25 changes: 12 additions & 13 deletions Game.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand All @@ -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()
Expand All @@ -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
Expand All @@ -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
Expand All @@ -72,20 +70,19 @@ 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)
_:
printerr("Wrong game difficulty: ", difficulty)
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)
Expand Down Expand Up @@ -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()
Expand Down
6 changes: 5 additions & 1 deletion Game.tscn
Original file line number Diff line number Diff line change
@@ -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]
Expand All @@ -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 )
Expand Down Expand Up @@ -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"]
Expand Down
3 changes: 3 additions & 0 deletions Main.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Binary file added audio/Knock (modified) - 256513.mp3
Binary file not shown.
15 changes: 15 additions & 0 deletions audio/Knock (modified) - 256513.mp3.import
Original file line number Diff line number Diff line change
@@ -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
Binary file not shown.
23 changes: 23 additions & 0 deletions audio/MenuClick - 448080__breviceps__wet-click.wav.import
Original file line number Diff line number Diff line change
@@ -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
Binary file not shown.
23 changes: 23 additions & 0 deletions audio/MenuHover - 422971__dkiller2204__sfxkeypickup.wav.import
Original file line number Diff line number Diff line change
@@ -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
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions characters/redhat/RedHat.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 5 additions & 1 deletion characters/redhat/RedHat.tscn
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
[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]
[ext_resource path="res://characters/redhat/rh-test-main.tres" type="Material" id=3]
[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"
Expand Down Expand Up @@ -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"]
9 changes: 9 additions & 0 deletions ui/MenuUI.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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")


Expand All @@ -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()
13 changes: 12 additions & 1 deletion ui/MenuUI.tscn
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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"]

0 comments on commit a70f8d1

Please sign in to comment.