Project 545: Grid Game

7. "Subtract X" button movement and animation

Add code to the "Subtract X" button to make Nano move left when the button is clicked on, and change costumes.
Starting point file for this challenge

Your goal

Steps

1. Start with "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 far left of the grid

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

If Nano's Xpos is greater than -209 then that means it is not yet at the far left side of the grid.

5. Move left

To make Nano move left, subtract 70 from the X 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'.