Goal:
Now that our sprite and our screen looks good, lets go ahead and code what the can do.
Let’s start with what needs to happen Pikachu is collided with by the pokeball, setting his health, and what happens when his health reaches zero.
Steps:
- In the top right corner of the screen, find the button called Blocks, and click it.
- From Variables, place an initialize global block on the screen and call it health.
- From Math, attach a 0(zero) block to the end of the initialize global block and set it to 100.
- From Pikachu, place a CollidedWith block on the screen.
- From Control, place an IF/THEN block.
- From Math, attach an =(equal) block to the IF portion of the IF/THEN block and then change it to <(Less Than).
- From Variables, place a get block in the left side of the <(Less Than) block and set it to health.
- From Math, place a 0(zero) block in the right side of the <(Less Than) block.