In Project 4, Space Age, we introduced the practice of adding a Game Manager sprite to handle the game initiation and termination, level up, as well as scoring. Keep the game logic in a centralized location such as Game Manager, which makes it easier to configure and update the game. The Hunger Run starter project also includes a Game Manager sprite.
We will create the code to initialize the game and determine the game completion or termination.
Perform the following steps to initialize the system:
2
and 5
in the go to x: () y: () block respectively.480
in the set <grid_length> to () block.0
in the set <game_score> to () block.0.2
in the set <frame_rate> to () block.10
in the set <grid_count> to () block. This number should be equal to or less than the number of the costumes in the brick sprite.3
in the set <bad_food_start_grid_idx> to () block. The bad_food_start_grid_idx
variable is the platform number when bad food can start appearing. For example, if this variable is set to 3
, then mushroom can appear starting from grid 3.0.75
in the set <scroll_speed> to () block.Perform the following steps to initialize the game:
game_start
message is broadcasted when the Start button is pressed.0
in the set <curr_scroll_amount> to () block.2
in the wait () secs block. This is to give the player a chance to take a breather before the fast-scrolling action.To win the game, Marco or Polo has to finish the run without eating bad food. When the last frame has been reached, the brick sprite would send out the scroll_max_reached message. To handle the scroll_max_reached message, perform the following steps:
24
and -24
in the go to x: () y: () respectively.3.136.233.153