From d10bfcc48ebaf5dcdf58d25ff0c3c29a2a8157ad Mon Sep 17 00:00:00 2001 From: Logan Date: Sat, 1 Oct 2022 21:01:12 -0600 Subject: Add next phase counter and improved interface script. --- scenes/interface.tscn | 7 +++++++ scripts/basketball.gd | 19 ++++++++++--------- scripts/interface.gd | 13 ++++++++++--- 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/scenes/interface.tscn b/scenes/interface.tscn index cba0c37..e41a650 100644 --- a/scenes/interface.tscn +++ b/scenes/interface.tscn @@ -32,4 +32,11 @@ text = "YOU LOSE. YOU WIN NOTHING. GOOD DAY SIR!" align = 1 +[node name="PhaseLabel" type="Label" parent="."] +margin_top = 112.0 +margin_right = 88.0 +margin_bottom = 128.0 +rect_scale = Vector2( 0.5, 0.5 ) +text = "Next Phase: " + [connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"] diff --git a/scripts/basketball.gd b/scripts/basketball.gd index 9001e68..7a50f69 100644 --- a/scripts/basketball.gd +++ b/scripts/basketball.gd @@ -13,7 +13,8 @@ onready var start_maximum = $"../Hoop".position.x - 40 var is_dragging = false var waiting_for_shoot = true var mouse_over_ball = false -var difficulty_phase = 1 +var phase = 1 +var phase_increment = [5, 15, 25, 35, 45, 55] func _ready(): start_position = global_position @@ -86,19 +87,19 @@ func _on_InnerShape_mouse_exited(): func position_changer(): # Progressive - if difficulty_phase == 1: + if phase == 1: start_position.x -= 20 start_position.x = clamp(start_position.x, start_minimum, start_maximum) # Random - if difficulty_phase == 2: + if phase == 2: start_position.x = rand_range(start_minimum, start_maximum) func _on_Hoop_score(): - if global_variables.score >= 5 and global_variables.score < 15: - difficulty_phase = 2 - if global_variables.score >= 15 and global_variables.score < 25: + if global_variables.score >= phase_increment[0] and global_variables.score < phase_increment[1]: + phase = 2 + if global_variables.score >= phase_increment[1] and global_variables.score < phase_increment[2]: start_minimum = (drag_radius * 2) + $"../Camera2D".limit_left - difficulty_phase = 1 - if global_variables.score >= 25 and global_variables.score < 35: - difficulty_phase = 2 + phase = 1 + if global_variables.score >= phase_increment[2] and global_variables.score < phase_increment[3]: + phase = 2 position_changer() diff --git a/scripts/interface.gd b/scripts/interface.gd index 4a25ce3..6aab7dd 100644 --- a/scripts/interface.gd +++ b/scripts/interface.gd @@ -1,16 +1,23 @@ extends CanvasLayer var time_left = 30 +var phase_index = 0 func _ready(): - $ScoreLabel.text = "Score: " + str(global_variables.score) - $TimerLabel.text = "Time: " + str(time_left) + update_labels() $Timer.start() func _on_Hoop_score(): - $ScoreLabel.text = "Score: " + str(global_variables.score) time_left += 10 + update_labels() + +func update_labels(): update_timer() + $ScoreLabel.text = "Score: " + str(global_variables.score) + if phase_index < $"../Basketball".phase_increment.size() - 1: + if $"../Basketball".phase_increment[phase_index] <= global_variables.score: + phase_index += 1 + $PhaseLabel.text = "Next Phase: " + str($"../Basketball".phase_increment[phase_index] - global_variables.score) func update_timer(): $TimerLabel.text = "Time: " + str(time_left) -- cgit v1.2.3