aboutsummaryrefslogtreecommitdiffstats
path: root/godot/scenes/Game.gd
diff options
context:
space:
mode:
authorLibravatar David <david003@gmx.net>2022-07-17 15:10:33 +0200
committerLibravatar David <david003@gmx.net>2022-07-17 15:10:33 +0200
commitcbb2770401241f864fc0df712e27a3a84572e499 (patch)
tree3a61589e0e523bf11172859f5bcb4a8d1f5f2f03 /godot/scenes/Game.gd
parent1b015a5989a3da04f08aaa06db444c875ea97df1 (diff)
parent9e9101b8c27d723696367692ac7ba24e5248ce37 (diff)
download2022-cbb2770401241f864fc0df712e27a3a84572e499.tar.gz
2022-cbb2770401241f864fc0df712e27a3a84572e499.tar.bz2
2022-cbb2770401241f864fc0df712e27a3a84572e499.zip
Merge branch 'main' of codeberg.org:code-your-friends/gmtk2022
Diffstat (limited to '')
-rw-r--r--godot/scenes/Game.gd42
1 files changed, 40 insertions, 2 deletions
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