June 2018
Beginner to intermediate
298 pages
7h 38m
English
Now, you can add an instance of the HUD to the Main scene. Add the following variables to Main.gd:
var level = 0var score = 0var playing = false
These will track the named quantities. The following code will handle starting a new game:
func new_game(): for rock in $Rocks.get_children(): rock.queue_free() level = 0 score = 0 $HUD.update_score(score) $Player.start() $HUD.show_message("Get Ready!") yield($HUD/MessageTimer, "timeout") playing = true new_level()
First, you need to make sure that you remove any existing rocks that are left over from the previous game and initialize the variables. Don't worry about the start() function on the player; you'll add that soon.
After showing the "Get Ready!" message, you will use yield ...
Read now
Unlock full access