Project 545: Grid Game

9. "Add X" button movement and animation

Add code to the "Add X" button to make Nano move to the right when the button is clicked on.
This challenge doesn't have a starting point

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 right of the grid

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

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

5. Move right

To make Nano move right, add 70 to 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'.