Project 545: Grid Game

8. "Add Y" button movement and animation

Follow the same steps as challenges 5 and 7, add code to the "Add Y" button to make Nano move up when the button is clicked on, and change appearance.
Starting point file for this challenge

Your goal

Steps

1. Add "when this sprite clicked"

We want Nano to move when we click on the button sprite, so we'll start with a "when this sprite clicked" block, from the "Events" tab.

2. Increase 'Clicks' variable by 1

We are going to keep track of the number of moves it takes for us to get to a battery, so whenever we move Nano, we will add 1 to the number of clicks.

3. Add an "if ____ then ____" statement

Go to the "Control" tab and get a "if ____ then ____" statement

4. Check if Nano is at the top of the grid

Nano shouldn't be able to move up anymore once it is at the top of the grid. We need to check Nano's Y position so that we only make it move up when there is somewhere for it to go.

If Nano's Ypos is less than 139 then that means it is not yet at the top of the grid.

5. Move up

To make Nano move up, add 70 to the Y position variable.

6. Another "when this sprite clicked"

Add another "when this sprite clicked" block to your code.

7. Switch costume to 'Down'

Go to the purple "Looks" tab and add the "switch costume to ___" block. Select the costume named 'down'. 

8. Wait 0.1 second

We want to be able to see the costume change, even if it is really fast, so we are going to wait 0.1 seconds before we switch the costume back to the original.

9. Switch costume to 'Up'

To make the button look like it is no longer pressed down, using the same block form step 6, we will switch its costume back to the original, named 'up'.