To connection between the interface and gameplay updates will be handled by a global signal bus
Create a new script in the Scripts folder
By adding it to the globals
The script has three signals
Now create a new scene with CanvasLayer as root
Add a Control node as child
Set the Anchor Preset to Full Rect
Add a MarginContainer as a child of Control
Set the Anchors Preset to Top Left
Add a VBoxContainer as a child of MarginContainer
Add a Label as a child rename to ScoreLabel
Add an HBoxContainer as a child
Add 3 Sprite2D as children
Add the Player.png as the texture of each Sprite
Place them in the scene under the score
Add a script to the HUD node
Create onready references to
Score label and lives container
Add a variable for the score
Create a function to update the score
Update the score variable
Update the score label
Create a function to update the lives
Create a variable to store how many life icons there are
Loop through all the icons
If the number of icons is less than number of lives
Make the icon invisible
So that the number of icons displayed
Matches the number of lives the player has
Set the default value for score label
Connect the SignalBus to the new functions:
update_score and update_lives
Assign 3 lives as initial value
Update the on destroy function
Broadcast the score signal
Update the area entered function
Tell the SignalBus to update the score
Game Over Menu and Restart Button
Add a CenterContainer as child of HUD node
Add a VBoxContainer as child
Add onready references to
GameOverMenu
GameOverLabel
RestartButton