Review: Touch the Button
In the info section of the orientation, the game “touch the button 15 times” had a very basic problem - no matter what, when the game was over, the same screen was shown, with the only difference being the score.
This can be changed using two using two blocks: ||info:on life zero||
and ||info:on countdown end||
. These blocks are used to override (change) the standard behavior for running out of lives and time running out for a countdown.
Initial Game:
controller.A.onEvent(ControllerButtonEvent.Pressed, function () {
info.changeScoreBy(2)
info.changeLifeBy(-1)
})
info.setLife(15)
info.startCountdown(2)
Student Task #1: Using ||info:on countdown end||
Modify the behavior of the countdown ending to add a penalty for running out of time.
- Add in the
||info:on countdown end||
block - Inside the
||info:on countdown end||
block, use the||info:change score by||
block to subtract 10 points from the score - After subtracting 10 from the score in the
||info:on countdown end||
, use the||game:game over||
block to end the game
Student Task #2: Using ||info:on life zero||
Give the player a bonus when they touch the button enough, and then continue the game.
- Add in the
||info:on life zero||
block - Add in a
||info:stop countdown||
block into the||info:on life zero||
block to end the countdown - Add a
||game:splash||
screen after the countdown is stopped that tells the player that they are moving onto the next level - Copy the two blocks from the
||loops:on start||
block into the||info:on life zero||
block after the||game:splash||
, so that the lives and countdown both ‘reset’ - Use the
||info:set score to||
block to set the score to two times the current score in the||info:on life zero||
block using the||math:x||
and||info:score||
blocks