|
|
|
|
@ -7,8 +7,7 @@ extends Node2D
|
|
|
|
|
@onready var player_2_score: Label = %Player2Score
|
|
|
|
|
@onready var game_text: Label = %GameText
|
|
|
|
|
|
|
|
|
|
var points: Vector2i
|
|
|
|
|
|
|
|
|
|
var points: Vector2i = Vector2i(0, 0)
|
|
|
|
|
var game_mode = "idle"
|
|
|
|
|
|
|
|
|
|
func _ready() -> void:
|
|
|
|
|
@ -26,9 +25,6 @@ func _input(event: InputEvent) -> void:
|
|
|
|
|
elif event.is_action_pressed("esc"):
|
|
|
|
|
get_tree().quit()
|
|
|
|
|
|
|
|
|
|
func _on_ball_body_entered(body: Node) -> void:
|
|
|
|
|
print("ball hits " + str(body.name))
|
|
|
|
|
|
|
|
|
|
func _on_game_over(winning_player: int) -> void:
|
|
|
|
|
if winning_player == 1:
|
|
|
|
|
points.x += 1
|
|
|
|
|
@ -39,11 +35,11 @@ func _on_game_over(winning_player: int) -> void:
|
|
|
|
|
game_mode = "idle"
|
|
|
|
|
|
|
|
|
|
if points.x >= 10:
|
|
|
|
|
game_over(1)
|
|
|
|
|
_game_over(1)
|
|
|
|
|
elif points.y >= 10:
|
|
|
|
|
game_over(2)
|
|
|
|
|
_game_over(2)
|
|
|
|
|
|
|
|
|
|
func game_over(player_wins: int) -> void:
|
|
|
|
|
func _game_over(player_wins: int) -> void:
|
|
|
|
|
game_mode = "game_over"
|
|
|
|
|
game_text.text = "Game Over! Winning Player: " + str(player_wins)
|
|
|
|
|
game_text.visible = true
|