diff options
Diffstat (limited to '')
-rw-r--r-- | Scripts/drawing.gd | 11 | ||||
-rw-r--r-- | Scripts/game.gd | 38 | ||||
-rw-r--r-- | Scripts/scene_control.gd | 34 |
3 files changed, 39 insertions, 44 deletions
diff --git a/Scripts/drawing.gd b/Scripts/drawing.gd index 18e2a6c..61896f9 100644 --- a/Scripts/drawing.gd +++ b/Scripts/drawing.gd @@ -9,11 +9,9 @@ func _ready(): Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) -func _start_drawing(): - line.clear_points() - path.curve.clear_points() +func start_drawing(): + reset() drawing = true - owner.set_driving(false) func _end_drawing(): @@ -25,3 +23,8 @@ func _input(event): if drawing and event is InputEventMouseMotion: line.add_point(event.position) path.curve.add_point(event.position) + + +func reset(): + line.clear_points() + path.curve.clear_points() diff --git a/Scripts/game.gd b/Scripts/game.gd index bacb709..3c4326f 100644 --- a/Scripts/game.gd +++ b/Scripts/game.gd @@ -10,7 +10,8 @@ var post_game = false var scenes = [ # preload("res://Nodes/levels/level1/level1.tscn"), # preload("res://Nodes/levels/level2/level2.tscn") - preload("res://Nodes/Level_test.tscn") + preload("res://Nodes/Level_test.tscn"), + preload("res://Nodes/Level_test_2.tscn") ] # Called when the node enters the scene tree for the first time. @@ -22,7 +23,6 @@ func _ready(): # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta): if Input.is_action_just_pressed("ui_cancel"): - close_scoreboard() get_tree().paused = true $PausePopup.show() Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) @@ -33,7 +33,6 @@ func _on_QuitButton_pressed(): func _on_ResumeButton_pressed(): - print('aaaa') $PausePopup.hide() get_tree().paused = false Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) @@ -45,31 +44,13 @@ func _on_MainMenuButton_pressed(): func end_level(): - open_scoreboard() # evaluate_player(current_strokes, PAR[current_level_id]) $BGMPLayer.stream_paused = true $JinglePlayer.play() post_game = true -func open_scoreboard(): -# strokes_per_level[current_level_id] = current_strokes -# $Scoreboard.update_values(strokes_per_level, PAR) -# $Scoreboard.show() - pass - - -func close_scoreboard(): -# $Scoreboard.hide() - pass - - -func is_post_game(): - return post_game - - func next_level(): - post_game = false current_level_id += 1 if current_level_id >= NUM_LEVELS: @@ -77,20 +58,9 @@ func next_level(): return load_scene_by_index(current_level_id) - close_scoreboard() - $Evaluation.hide() - $BGMPLayer.stream_paused = false - $JinglePlayer.stop() - - -func evaluate_player(strokes, par): - $Evaluation/EvaluationLabel.text = "%d Seconds" % 42 - $Evaluation.show() - - -func _on_JinglePlayer_finished(): - $BGMPLayer.stream_paused = false + # $BGMPLayer.stream_paused = false + # $JinglePlayer.stop() func load_scene_by_index(index): diff --git a/Scripts/scene_control.gd b/Scripts/scene_control.gd index d01342f..7f0ba5e 100644 --- a/Scripts/scene_control.gd +++ b/Scripts/scene_control.gd @@ -7,23 +7,30 @@ class_name SceneControl @onready var car = $Car @onready var checkpoints = $Checkpoints.get_children() @onready var ui = $UI/Control -@onready var start = $Start - -var finish_line: Area2D +@onready var drawing = $DrawNode var is_driving = false var current_time = 0.0 +var game_control +var start + func _ready(): - finish_line = $FinishLine/Area2D as Area2D - finish_line.body_entered.connect(_on_finish_line_body_entered) + game_control = get_tree().root.get_child(0) + + $FinishLine/Area2D.body_entered.connect(_on_finish_line_body_entered) + $UI/Control/PostGameUI/RestartButton.pressed.connect(reset_level) + $UI/Control/PostGameUI/NextLevelButton.pressed.connect(next_level) + + start = $Start as TextureButton + start.pressed.connect(start_drawing) + reset_level() func _physics_process(delta): if car.driving: current_time += delta - print(current_time) ui.update_timer_label(current_time) @@ -43,12 +50,17 @@ func set_driving(driving: bool): func reset_level(): ui.update_timer_label(-1) + ui.switch_to_in_game_UI() + + $DrawNode.reset() for cp in checkpoints: cp.set_was_visited(false) car.global_position = start.global_position car.global_rotation = start.rotation; + + set_driving(false) func start_driving(): current_time = 0.0 @@ -64,6 +76,16 @@ func evaluate_driving(): func _on_finish_line_body_entered(node: Node2D): if evaluate_driving(): ui.switch_to_post_game_UI() + set_driving(false) + return set_driving(false) reset_level() + +func next_level(): + game_control.next_level() + + +func start_drawing(): + reset_level() + drawing.start_drawing() |