Scratch Even Harder! PA 2014 Task 1 Hiding and showing sprites Once your game has more than one level, you may wish to add or remove characters at each level. You might want to make your bad guy bigger or faster. There will be other uses for hiding and showing later in this booklet. To make a sprite appear only in one level, you will need a script like this. In the menu choose the option, press the drop-down on “Sprite1 and choose “Stage” you will now see “background # in the left hand window of the option. Next, drag it into a statement. Use the background number of the stage you wish to show the sprite on. Next simply add to your Forever If Else command. Note: The background number is this one, you can drag the stages up and down to rearrange them. Your sprite should now vanish from levels except #1. Tip: if you duplicate your sprite (right-click) you can resize, speed up etc and change the background#’ so it appears to change on the next level. 2 Task 2 Using a sprite to change levels This will require the sprites to be shown and hidden – as you will want a different one at each level (even if, as in my example, they all look the same). If you use this method, you won’t need a different coloured end zone. There are lots of gaming opportunities, too. For example you could catch a moving sprite. In my example, I have used bananas for my monkey – he’s hungry and will do anything to get them! You should make your game have a story too. The script is the same as in the Scratch Harder booklet, using broadcast for the sprite and receive on the stage, except for... The problem you will have is once you get to the next level, you won’t want the sprite any more – in my game, I may need more bananas, but they have to be in different places on different levels. Task 3 Score sprites You may want to use sprites to give a score you could also animate them. The scripts for this have already been shown in the Scratch Harder booklet. Here’s an example: First draw yourself (or find in folder, download etc) a suitable sprite. Here’s mine Then animate it. Tip: make sure that it stays close to the bad guy, or have the bad guy guarding it. You could also script it so that it vanishes once touched. You will then need to add a Forever If touching Sprite#, change score by #, Wait until Not touching sprite# script to your game sprite – a quick way to do this is to duplicate a similar one – lives for example and change the sprite and variable. 3 Task 4 Vanish after touching Use with anything . you can use a variation of the If background # = script in task 1 to make it reappear in the next level if you wish. It looks like this: If you want it to keep on vanishing, after reappearing, you will need this script: (add Forever) Finally, you will want the sprite to be shown when you re-start your game, so add a the when clicked, outside a Forever statement. Like this: 4 command to Task 5 Moving with the mouse Easy! This script will move your sprite left to right – like the “Pong” game This one does up and down. And, this one moves the sprite all over the screen. Task 6 Bouncing This can be your game sprite and the script could be in the bad guy, or the paddle in a “Pong” game. You can find other sounds, or record your own. This line makes the sprite leave at the opposite angle it which it hit. This turns the sprite so that it bounces off the edge at a different angle and won’t get stuck on one path. Finally, you will need a script to make your sprite bounce off the edge of the screen 5 Task 7 Gravity To make gravity work, our script has to make the sprite fall unless a key is pressed. This script will put our sprite at the top of the screen and make it move downwards. It will go off the bottom of the screen unless we do two things: Make it stop on the “ground” Provide an upwards movement Stopping on a surface (an orange one). Upwards motion This script will make our sprite go up for as long as the key is pressed 6 This one will only last for a fraction of a second before the sprite drops – more fun! Task 8 Scrolling To scroll from left to right we will need to make a new variable called “scroll x” (for up and down, “scroll y”). Scroll x counts the pixels in your sprite and scrolls the sprite to whatever number we choose. The sprite will disappear off the screen as it scrolls. We can use Goto to go straight to a place or increase/decrease the number to give the effect of movement. We now need to make a note of how many pixels wide our stage is and create some terrain (track) sprites for our game sprite to travel along. The stage is 480 pixels wide We will need a series of end to end terrain sprites. If we use Scratch to create our terrain sprites, they will be also 480 pixels wide – we can import larger ones created in Photo Plus or even download 7 them from the internet (Google “terrain sprites”). I’m going to show you how to create them using Scratch. First, click to open the sprite editor. Call our first sprite “terrain 0” 8 Next, give it this script, which will enable it to scroll: Now we can duplicate and modify, to make more. We need about four or five to begin with. Call them “terrain 1”, “terrain 2” etc, in the order they are to be used. Next, alter the number in the scripts too, like this: 9 Next, we want our game to reset to the beginning – add a set scroll x to 0 to the gravity script. Finally, we need a script to make the terrain move when we press a key. This script also animates the sprite too. Now we are ready to try it out! Select full screen and press the What to do next: Put an end zone and use it to begin another level (world). Use the other world to run a show/hide script for another set of terrain sprites Make some bad guys Collect things to give a score Make them vanish after being collected Set up a Lives variable Make things bounce Increase/decrease the size, or change the costume(s) of the game sprite 10
© Copyright 2026 Paperzz