June 2018
Beginner to intermediate
298 pages
7h 38m
English
Next, the new_game() function will initialize everything for a new game:
func new_game(): playing = true level = 1 score = 0 time_left = playtime $Player.start($PlayerStart.position) $Player.show() $GameTimer.start() spawn_coins()
In addition to setting the variables to their starting values, this function calls the Player's start() function to ensure it moves to the proper starting location. The game timer is started, which will count down the remaining time in the game.
You also need a function that will create a number of coins based on the current level:
func spawn_coins(): for i in range(4 + level): var c = Coin.instance() $CoinContainer.add_child(c) c.screensize = screensize c.position = Vector2(rand_range(0, screensize.x), ...
Read now
Unlock full access