The words you are searching are inside this book. To get more targeted content, please make full-text search by clicking here.
Discover the best professional documents and content resources in AnyFlip Document Base.
Search
Published by alpadangy, 2021-08-30 23:59:25

basicgame

basicgame

Making a Basic Game in Page 1

Scratch

This tutorial shows you how to make a simple game in
Scratch. In this game, you are in a dungeon. You are trying to
get to the cake at the end of the dungeon. Monsters are
protecting the cake. Don't let them touch you!

Introduction to Scratch

Go to this website: http://o.ooli.ca/en/scratchgames/cake

1First, we'll choose 2
a picture for your
character in the 2 The picture will probably be
game. Go to the 1 too big. To make it smaller,
New Sprite icon click on the Size box and
and click on the enter a smaller number.
Choose a Sprite
button.

Then, choose a
picture that you
like. Scratch calls
these pictures
sprites.

34 On the left of the
screen are
You can move sprites around by dragging them. Move commands that
your pointer over the sprite, hold down your mouse you can give to
button, and then move the mouse. Let go of the button sprites. In Scratch,
when the sprite is in the spot you want. For now, move these commands
your sprite to the left side of the game. are called "blocks."
Click on the "move
__ steps" block.
What does your
sprite do when you
click on the block?

5 6There are many types of blocks. At
the far left of the screen, you can
change what sort of blocks are
shown. Click on "Looks" to show the
blocks for looks. Then click on the
"say __ for __ secs" block. What
happens?

What happens when you click on In the middle of the screen is a
the "think __ for __ secs" block? blank area. You can put together
The "hide" block? The "show"
block? Can you make your sprite blocks here to make more
say "goodbye" instead of "hello?" complicated commands. This is

called a “program” or “script.”

The Bat Page 2

The bat guards the dungeon. Let's write a program for the bat so
that it moves up and down.

1 Click on 2 At the start, we
the bat want the bat to
button in move up. Go to the
the list of "Motion" blocks,
sprites. and drag a "point in
direction" block to
your program.

3 Click on the direction number “90”. You 4 Drag a "move __
will see a circle with an arrow. Drag the steps" block to
arrow until it points upwards and the your program.
direction is 0. Afterwards, click on the Click on it. The bat
block you’ve just created so that the moves a little bit,
bat will now point up. but then it stops.

5 Go to the 6 Drag the
"Control" blocks. "move __
Drag a "forever" steps" block
block to your into the
program. The forever
"forever" block will block. What
repeat a happens
command until the when you
game ends. click on it?

7 8The bat will keep 9
moving up until it gets

stuck at the top of the

dungeon. What

happens when you

drag the bat back to

the bottom of the Go to the "Motion" blocks. The bat moves very fast.

dungeon? What Drag a "if on edge, bounce" Instead of having the bat

happens when you block into the forever block. move 10 steps, change

click on the red stop What happens when you click the number of steps to a

button? on the forever block now? smaller number.

10 Let's put everything 11 Now, stop your
together now. Drag all program by
the blocks together so clicking on the red
that they are under flag. Then restart
the block for when the it by clicking on
green flag is clicked. the green flag.

You Page 3

Now let's write a program that lets you move around the dungeon.

1 Click on 2 Go to the
the sprite “Motion” blocks.
for your Click on the “set
character rotation style
in the list ‘left-right’” block.
of sprites. This prevents
your sprite from
turning upside-
down when
moving around.

3 We will now 4
make a program
to let us use the Click the down arrow, and
keyboard to change the key to "right
move our sprite. arrow."
Go to the
"Events" blocks.
Drag a "when
___ key
pressed" block
into your
program.

56

What should the sprite do when you press the right arrow? It should Now drag a "move __ steps" block
turn to the right, and then walk. Go to the "Motion" blocks. Drag a and put it after the "point in
"point in direction ___" block and attach it to the "when right arrow direction 90" block. What happens
key pressed" block. If necessary, change the direction angle to 90. when you press the right arrow
key on your keyboard now?

7 What happens when you

press the left arrow key on
your keyboard? Nothing
happens. We need to write a
program for that. Write a
program that moves your
sprite when you press the up,
left, and down arrow keys.

Winning and Losing Page 4

Right now you can move, but nothing happens if you reach the cake or if the bat catches you. Let's write a

program to handle that.

1 2Make sure your Go to the
character’s sprite "Control" blocks.

is selected. Then, Drag a "forever"

go to the "Events" block and put it

blocks. Drag a after the "when

"when green flag green flag

clicked" block into clicked" block.

your program.

34

Now drag a "if __ Go to the "Sensing" blocks. Drag a "touching __?" block into the "if __ then" block.
then" block into the Scratch will only let you do this if the LEFT side of the "touching __?" block is over the
"forever" block. spot where you want it to go.

5 6Click the
down arrow
of the
"touching
__?" block.
Choose
"Cake."

Go to the "Looks" blocks. Drag a "say ___ for __ secs"
block inside the "if __ then" block. Have it say "you win!"

78 9

Click on the green flag. Move Now add some blocks so that if Also add some blocks so that
your sprite so that it touches you're touching the bat, it will say if you're touching the ghoul, it
the cake. What happens? "oh no!" will say "oh no!"

The Ghoul Page 5

Let's make a more dangerous monster. Let's program the ghoul to chase you.

3

12

Click on the ghoul sprite. Go to the "Control" blocks. Go to the "Motion" blocks. Drag a "point
Drag a "forever" block and towards ___" block into the forever
4 put it after the "when green block. Click on the down arrow of the
flag clicked" block. block, and choose your sprite.

5

Drag a "move ___ steps" Click on the green flag to start the program.
block and put it inside the The Ghoul will quickly chase your sprite.
forever block. Change the number of steps that the ghoul
moves so that it moves very slowly.

Your Turn

Can you add a sound effect if you get the cake? Can you make an explosion or a whirl effect if you get caught?
Can you add more enemies?

* A completed copy of this game is available at http://scratch.mit.edu/projects/25753675/
** Some of the art used in this tutorial is from Scratch and is licensed under CC BY-SA 2.0. Scratch is developed by the Lifelong Kindergarten
Group at the MIT Media Lab. See http://scratch.mit.edu


Click to View FlipBook Version