In this project, we will create a game to find all the superheroes hidden in the background.
Let’s create a starting block for our program.
Our scratch code will begin when the green flag is clicked!
Our next step is to have our hero show up after hiding and set a new position.
In this next step we are goin to create random numbers for our x and y positions.
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.
* -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.
Next we will create code for what happens when you click on a hero .
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.
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.
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.
Test our your code again ! All heroes should now be randomly appearing at different locations and give you 1 point for finding them.
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!
*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.
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.
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
Test your final game and try to find each superhero to get the ‘Win’ sign to appear!
Add this new code to each of your heroes to give them a really disappearing cool effect!