Find the Superheroes Scratch Project

Find the Superheroes:

In this  project, we will create a game to find all the superheroes hidden in the background.

Our goals:

  • ○ Create code for one hero and apply to all other heroes.
  • ○ Set up heroes to be in random positions.
  • ○ Build logic for what happens when you click on a hero.

Step 1:

Let’s create a starting block for our program.

Our scratch code will begin when the green flag is clicked!

Steps:

  1. Click on Captain America sprite.
  2. Click on Events.
  3. Drag When green flag clicked to an empty space.

Step 2:

Our next step is to have our hero show up after hiding and set a new position.

Steps:

  1. Click on Looks.
  2. Drag show to the when green flag  .
  3. Click on Motion.
  4. Drag set x to under show .
  5. Drag set y to under set x to.

Step 3:

In this next step we are goin to create random numbers for our x and y positions.

Steps:

  1. Click on Operators.
  2. Drag the first pick random into  set x to   .
  3. Drag the second pick random into  set y to   .

Step 4:

Our next step is to create random numbers for our hero to use.

This code works by selecting a range of numbers the code can choose from. For example, if I said pick a number from 0 to 10.. Except here we use (-) negative numbers!

These random numbers will allow our hero to appear at random locations on the background picture.

Steps:

  1. Set x to pick random  -230 to 230*
  2. Set y to pick random  -134 to 175 **

* -230 to 230 for x position is for how wide scratch game is.

**-134 to 175 for y position is for how tall our scratch game is , excluding the bottom area for our text.

Step 5:

Next we will create code for what happens when you click on a hero .

Steps:

  1. Click on Events.
  2. Drag  when this sprite clicked to an empty space.
  3. Click on Looks.
  4. Drag  say (  ) for 2 seconds to when this sprite clicked.
  5. Type your own custom message!

Step 6:

The next two code blocks will change our “Hero Found” by adding 1 to its total.

The hide block will hide the hero from the scene so we can’t click them again.

Steps:

  1. Click on Variables.
  2. Drag  change Heroes Found by 1 under the say block
  3. Click on Looks.
  4. Drag  hide und the change block.

Test our your code now by pressing the green flag! Our first  hero should now be randomly appearing at different locations and react when you click on them.

Step 7:

The next step is to copy our code from Captain America to the other heroes. All heroes will use the same game logic for how they appear and interact.

The best way to copy code from one sprite to another is to drag code blocks into other sprites.

Steps:.

  1. Drag  when flag clicked code into the next sprite, Hawkeye.
  2. Drag  when this sprite is clicked code into the next sprite, Hawkeye.
  3. Repeat and copy these steps for each hero!
  4. Do not drag these codes into the Winning Sign

Test our your code again ! All heroes should now be randomly appearing at different locations and give you 1 point for finding them.

Step 8:

Our next step is to set up all the rules of our game.

The ‘Winning Sign‘ Sprite will contain all our game logic to control resetting, adding  and what happens when we reach 6 points!

Steps:.

  1. Click on Winning Sign sprite.
  2. Click on Variables 
  3. Drag  set Heroes Found to 0 under hide
  4. Click on Control.
  5. Drag forever* under set Heroes Found
  6. Drag if < > then** inside the forever loop.

*forever loops are used to repeat code inside it.. forever!

**if < > then is used to control when a code should be used or not. It checks for permission before running the code inside it.

Step 9:

Next up is to set up our if then statement. ifs are used to control code and check permission before running any code inside of it.

Our code will check if our ‘Heroes Found’ is equal to 6.

Steps:.

  1. Click on Operators,
  2. Drag <     =  > into the if then.
  3. Click on Variables.
  4. Drag Heroes Found into the first bubble for < = >.
  5. Change the <Heroes Found = > to 6.

Step 10:

Our last step is to make our ‘Winning Sign’ appear after you clicked on 6 heroes total.

We will add some code inside the if  statement

Steps:.

  1. Click on Looks
  2. Drag show inside if then
  3. Drag change color effect by 10 inside if then

Its complete!

Test your final game and try to find each superhero to get the ‘Win’ sign to appear!

EXTRA:

Add this new code to each of your heroes to give them a really disappearing cool effect!

Steps:.

  1. Click on Events
  2. Drag when this sprite clicked into an empty area.
  3. Click on Control.
  4. Drag repeat under when this sprite clicked.
  5. Change repeat to 100
  6. Click on Looks.
  7. Drag change color effect into repeat
  8. Change the effect to pixelate and change effect by 1