Starting Games in Scratch

Scratch is a pretty cool tool for writing games (and lots of other things), made available for free on the Internet by the nice people at MIT.

These are some notes to get you started; There are lots of experimenting and poking around you will need to do yourself!

1.Getting a copy of Scratch to play with

2. Starting it up

Tour of the Scratch Screen

3. Making Scratch Say Hello

4. Making Scratch Move (Motion)

5. Getting Help - STFW (Search the fantastic Web)

6. Do it again. And Again . And Again ...  Loops

7. Get Scratch to draw a line...

8. IF … Then Deciding what to do

9. Finding out when you hit things

10. Sharing your characters - import and export

11. Give Scratch a memory  - Variables

12.Listen for things that happen - Broadcasts

13. Here’s Some I Did earlier - Scratch Examples

14. What Happens Next?

1.Getting a copy of Scratch to play with

OR

If all goes well, you should see the Scratch the Cat icon  somewhere on your desktop, or in the folder that you copied the files from.

2. Starting it up

Double click on Scratch the Cat. All being well, you should see the something like the picture.

Try it out! Take a look around. Try pushing buttons and click on things. Find out what they do. Tell your friends to see who has found the coolest.

Tour of the Scratch Screen

Try it out!  Can you find out how to ….

  • Edit the picture of Scratch the cat  to make him look different
  • Record a sound and play it back
  • Drag blocks from the left to the middle and make them ‘Stick’ together?
  • Find out all the 8 different types of blocks (colours) that are available to play with
  • Save your work (project)?

3. Making Scratch Say Hello

Try it out! 

  • Can you make scratch say your name instead?
  • Can you make the program run when you press a different key (like ‘S’ for start)?


4. Making Scratch Move (Motion)

Try it out! 

  • Now make Scratch turn left / right / up / down when you press an arrow key.
  • Add another step make Sratch move 10 steps in each direction.
  • Make Scratch say ‘I am moving left’ or ‘right’ as he moves
  • Find a new Picture on the web / on disk. Use that instead of Scratch the cat.
  • Get Scratch to play a sound as he moves.
  • Hint; Use four different code blocks, one for each key.


5. Getting Help - STFW (Search the fantastic Web)

Ok , you’re bumping into a problem or you want to know more?

Try it out!:

  • Find out how to change the background (‘Stage’ in Scratch). Make it look as good, weird , funny or Gothic as you can.
  • Find out out to give Scratch the cat a different costume. Find out how to press a key to switch between the two.

Some other places to get help

If you want to find out more (and thanks to)


6. Do it again. And Again . And Again ...  Loops

What’s a loop? Anything that you want Scratch to do again, and again, and again!

Try it out! 

  • Make Scratch turn in a loop 100 times instead of 20.
  • As he turns, make scratch a little bigger each time.


7. Get Scratch to draw a line...

Try it out! 

  • Make the pen colour change as scratch moves. You should end up with a multi-colour line.
  • What other visual and sound effects can you add?
  • Find out how to clear the colours you’ve drawn. Make it clear when you press the ‘C’ key.


8. IF … Then Deciding what to do

IF and WHEN allow you to make a decision. IF it is 12 O’clock I will eat Pizza ELSE I will play with Scratch

Try it out!  

  • Add another IF to check ‘P’ key has been pressed, put pen down.
  • Add another IF to check ‘U’ key has been pressed, take the pen up.


9. Finding out when you hit things

Seeing if you’ve bumped in to something is pretty important. How much fun would your game be if you never noticed that you’ve hit a wall?

Try it out! 

  • Draw a maze on screen. Get Scratch to bounce around the maze.
  • Hint: this is probably easier if you draw the maze in black, then get scratch to see if he is touching a colour.
  • Hint:Remove the bit the stops the program when you hit something.

Try it out! 

  • Make loads of copies of Scratch the cat . Get them moving. Get them to say ‘ouch’ when they hit each other


10. Sharing your characters - import and export

Scripts (the coloured code blocks)are tied to a sprite (e.g. Scratch the Cat). So when you move a Sprite, your code blocks move with it. Cool.

See the guy (or girl) beside you? They’re probably doing something pretty cool. How do you share your characters with them?

Ok, got that, now how does my friend take in my sprite?

Try it out! 

  • Make two scratch cats, one on each computer.
  • Make each scratch move when you press different keys
  • Share Scratch with each other
  • Update your project ; when your scratch bumps into another - say ‘sorry!’


11. Give Scratch a memory  - Variables

What are variables? They’re a box that you can store a number, word, or pretty much anything else in. Variables give Scratch the Cat a memory.

Try it out!

- Change the program to get it to count backwards. Add a loud noise when it gets to 0

- Make another variable called Name. Get scratch to ask you your name, then say ‘Hello [yourname].


12.Listen for things that happen - Broadcasts

Your monsters would be pretty dumb if they didn’t listen out for other things that happen in the game. How can we ‘listen’ for things that happen? Here’s one way

 

Click on the Green Sprite (Scratch)

Drag and drop the blocks from the left to the middle of the screen so they look like this picture

Click on the Orange  Sprite (Scratch)

Drag and drop the blocks from the left to the middle of the screen so they look like the picture on the left.

When you click on the Green Scratch, it says ‘Hello’ and broadcasts a ‘Hello’ message to anybody that might be listening.

Orange Scratch *is* listening for the Hello Message, and says ‘Hello Back’ whenever he hears this message.

Note that at no point are the cats linked - they’re just sending and listening for a message.

Why not connect the sprites together directly?

For 2 sprites , you’ve 1 connection. 3 sprites have 7 connections.  10 Sprites have more than 1000 connections. The numbers get even bigger  (and even more complicated) very quickly.

Broadcasting is an easier way for  your sprites to talk, listen and react to each other. You just listen for the messages that you’re interested in.

Try it out!

  • Change the script that orange scratch broadcasts when he moves up / down / left or right
  • Have the green scratch listen and move in the opposite direction


13. Here’s Some I Did earlier - Scratch Examples

Scratch comes with some pretty good examples. To find them, click the ‘File’ Menu, then ‘Open’. In the box that appears on the screen click ‘examples’.

Some of the ones that we liked are below. Which is your favourite?

Games

- pong

- pacman

- marble racer - velocity

- scrolling demo

- Guessing Game

Greetings

-Slideshow

Simulations

- Spinners

- gravity blocks

- soundgraph - microphone

Try it out!

- Open One of examples. Play with it while

- Look at the Scripts behind the examples - can you talk a friend through how it works

- Can you make it better? Change some of the scripts and see what happens.

14. What Happens Next?

Well done, now you have all the bits you need to program Games!.

The words may be different in other computer languages, but the ideas are the same.

What are you going to do next?

Credits; © PaulB@FirstPartners.net , tested at CoderDojo Drogheda and Leiden. Feel free to reuse (but mention where you got it from - MIT License) Cover image from  http://bit.ly/ScratchBookCover