aboutsummaryrefslogtreecommitdiffstats
path: root/godot
diff options
context:
space:
mode:
authorLibravatar Scarabeaver <kopakoraello@googlemail.com>2022-07-17 14:23:34 +0200
committerLibravatar Scarabeaver <kopakoraello@googlemail.com>2022-07-17 14:23:34 +0200
commit0d2293cc5277f9c61970e35011bbbb27470156f8 (patch)
tree6fca6c65dd2a6db4c092e49c29d634fa68599e29 /godot
parente9962e5a2468ae0c6a0b86f9127209c710249367 (diff)
parentf24e47e0ecdfb8a1f0bc97fb81194851c4740dbe (diff)
download2022-0d2293cc5277f9c61970e35011bbbb27470156f8.tar.gz
2022-0d2293cc5277f9c61970e35011bbbb27470156f8.tar.bz2
2022-0d2293cc5277f9c61970e35011bbbb27470156f8.zip
Merge branch 'main' of https://codeberg.org/code-your-friends/gmtk2022
Diffstat (limited to '')
-rw-r--r--godot/assets/sounds/jingle.wavbin0 -> 1615352 bytes
-rw-r--r--godot/assets/sounds/jingle.wav.import3
-rw-r--r--godot/scenes/Game.gd42
-rw-r--r--godot/scenes/Game.tscn26
4 files changed, 67 insertions, 4 deletions
diff --git a/godot/assets/sounds/jingle.wav b/godot/assets/sounds/jingle.wav
new file mode 100644
index 0000000..03ed55b
--- /dev/null
+++ b/godot/assets/sounds/jingle.wav
Binary files differ
diff --git a/godot/assets/sounds/jingle.wav.import b/godot/assets/sounds/jingle.wav.import
new file mode 100644
index 0000000..36c3835
--- /dev/null
+++ b/godot/assets/sounds/jingle.wav.import
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:4b2662086d424e91303656b293f6d490d90717cb44ee7e68cc4af152b316545b
+size 417
diff --git a/godot/scenes/Game.gd b/godot/scenes/Game.gd
index 56456c0..fef2cc8 100644
--- a/godot/scenes/Game.gd
+++ b/godot/scenes/Game.gd
@@ -1,7 +1,7 @@
extends Spatial
const NUM_LEVELS = 9
-const PAR = [1,2,3,4,5,6,7,8,9]
+const PAR = [5,2,3,4,5,6,7,8,9]
# level control
var current_level_id = 0
@@ -19,6 +19,8 @@ func _ready():
current_strokes = 0
levels[0].show()
+
+ $JinglePlayer.stream.loop_mode = AudioStreamSample.LOOP_DISABLED
# Called every frame. 'delta' is the elapsed time since the previous frame.
@@ -47,7 +49,10 @@ func _on_MainMenuButton_pressed():
func end_level():
- open_scoreboard()
+ open_scoreboard()
+ evaluate_player(current_strokes, PAR[current_level_id])
+ $BGMPLayer.stream_paused = true
+ $JinglePlayer.play()
post_game = true
@@ -89,3 +94,36 @@ func next_level():
levels[current_level_id].show()
close_scoreboard()
+ $Evaluation.hide()
+
+ $BGMPLayer.stream_paused = false
+ $JinglePlayer.stop()
+
+
+func evaluate_player(strokes, par):
+ if strokes <= 1:
+ $Evaluation/EvaluationLabel.text = "HOLE IN ONE"
+ $Evaluation.show()
+ return
+
+ var diff = strokes - par
+ if diff < -2:
+ $Evaluation/EvaluationLabel.text = "%d" % diff
+ elif diff == -2:
+ $Evaluation/EvaluationLabel.text = "EAGLE"
+ elif diff == -1:
+ $Evaluation/EvaluationLabel.text = "BIRDIE"
+ elif diff == 0:
+ $Evaluation/EvaluationLabel.text = "PAR"
+ elif diff == 1:
+ $Evaluation/EvaluationLabel.text = "BOGEY"
+ elif diff == 2:
+ $Evaluation/EvaluationLabel.text = "DOUBLE BOGEY"
+ else:
+ $Evaluation/EvaluationLabel.text = "+ %d" % diff
+
+ $Evaluation.show()
+
+
+func _on_JinglePlayer_finished():
+ $BGMPLayer.stream_paused = false
diff --git a/godot/scenes/Game.tscn b/godot/scenes/Game.tscn
index 411b825..f7223a4 100644
--- a/godot/scenes/Game.tscn
+++ b/godot/scenes/Game.tscn
@@ -1,4 +1,4 @@
-[gd_scene load_steps=7 format=2]
+[gd_scene load_steps=8 format=2]
[ext_resource path="res://scenes/Game.gd" type="Script" id=1]
[ext_resource path="res://scenes/levels/level1/level1.tscn" type="PackedScene" id=2]
@@ -6,6 +6,7 @@
[ext_resource path="res://assets/fonts/format.tres" type="DynamicFont" id=4]
[ext_resource path="res://scenes/objects/Scoreboard.tscn" type="PackedScene" id=5]
[ext_resource path="res://assets/sounds/bgm.mp3" type="AudioStream" id=6]
+[ext_resource path="res://assets/sounds/jingle.wav" type="AudioStream" id=7]
[node name="Game" type="Spatial"]
script = ExtResource( 1 )
@@ -16,10 +17,30 @@ visible = false
margin_right = -0.319946
margin_bottom = 0.47998
-[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
+[node name="Evaluation" type="Control" parent="."]
+visible = false
+anchor_right = 1.0
+anchor_bottom = 1.0
+
+[node name="EvaluationLabel" type="Label" parent="Evaluation"]
+anchor_left = 0.3
+anchor_top = 0.4
+anchor_right = 0.7
+anchor_bottom = 0.5
+theme = ExtResource( 3 )
+text = "Finished
+"
+align = 1
+valign = 1
+
+[node name="BGMPLayer" type="AudioStreamPlayer" parent="."]
stream = ExtResource( 6 )
autoplay = true
+[node name="JinglePlayer" type="AudioStreamPlayer2D" parent="."]
+stream = ExtResource( 7 )
+volume_db = 1.0
+
[node name="Level1" parent="." instance=ExtResource( 2 )]
[node name="PausePopup" type="Control" parent="."]
@@ -75,6 +96,7 @@ margin_right = 360.0
margin_bottom = 393.0
text = "Quit"
+[connection signal="finished" from="JinglePlayer" to="." method="_on_JinglePlayer_finished"]
[connection signal="pressed" from="PausePopup/Panel/VBoxContainer/ResumeButton" to="." method="_on_ResumeButton_pressed"]
[connection signal="pressed" from="PausePopup/Panel/VBoxContainer/MainMenuButton" to="." method="_on_MainMenuButton_pressed"]
[connection signal="pressed" from="PausePopup/Panel/VBoxContainer/QuitButton" to="." method="_on_QuitButton_pressed"]