Fries
7bae1587d2
this is so i can scale all the objects to the proper positions and scales when the resolution changes.
30 lines
835 B
GDScript
30 lines
835 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")
|
|
|
|
## 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)
|