Pong/Scripts/Managers/UI/Score.gd
Fries 425bf2ad27 make a settings menu and general refactoring
i added more to the main menu, as it has a settings menu now, that stores its files with json. i also changed the font to atkinson hyperlegible and made a BaseMenu class that takes care of the screen scaling for menus.

i also refactored the project folder structure to make it more organized.
2023-05-20 21:42:38 -07:00

34 lines
941 B
GDScript

extends HFlowContainer
var PlayerOneScore: int
var PlayerTwoScore: int
var PlayerOneLabel: Label
var PlayerTwoLabel: Label
enum {PlayerOne, PlayerTwo}
# Called when the node enters the scene tree for the first time.
func _ready():
PlayerOneLabel = get_node("Player1")
PlayerTwoLabel = get_node("Player2")
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta):
pass
## when the ball collides with the wall, this method is called by the WallManager
func score(player_number: int):
if player_number == PlayerOne:
PlayerOneScore += 1
update_label(player_number)
elif player_number == PlayerTwo:
PlayerTwoScore += 1
update_label(player_number)
## this method takes care of updating labels
func update_label(player_number: int):
if player_number == PlayerOne:
PlayerOneLabel.text = str(PlayerOneScore)
elif player_number == PlayerTwo:
PlayerTwoLabel.text = str(PlayerTwoScore)