Step 1: Creating the “Power” Mechanic

Goal:


The first thing we’re going to do is make our hammer gain “power” as the player presses the spacebar.

As long as the time remaining is not zero, then we want to add power.

Then we will wait until it is not pressed. Why do we do this? What would happen if this wasn’t here? Try removing the not block to see what happens!

Steps:

  1. First select the “Hammer” sprite
  2. From Control place an “if then” block inside the repeat until block
  3. From Sensing place a key space pressed block inside the if then block
  4. From Variables place a change by block inside the if statement
  5. Inside that change by block, make sure “Power:” is selected, and set the number to 1
  6. From Control place a wait until block
  7. From Operators place a not block inside the wait until block
  8. From Sensing place a key space pressed block inside the not block

Code:


Click to replay