Clarkson University IgniteCS: Design

Intro to
Animation
CLARKSON UNIVERSITY
IGNITECS: DESIGN
Introduction to Scratch

Scratch is a “drag and drop” type programming
language
The beginning

First lets open a new scratch project

It will look similar
to the following
Prepare our workspace

Clear the space for out new game

We need to delete the initial cat, right click on it
and select delete
Our first Sprite

A sprite is a type of object in our
world.

We will create a paddle object first.

To create an object with our design
click on the
next to the “New Sprite” label
Next steps

We need to design our paddle object

I made my paddle a blue bar, named player 1.
Our dream paddle’s
behavior

Our paddle can move left
and right, when you press
left and right keys.

We would like it to be
located at the bottom of
the screen.
Initializing our paddle

We would like to start our paddle in the middle
and bottom.

We will add script so
that it starts at (0, -125)
Initializing script

On the press of the start button:

Tell the paddle to go to
x position 0, and y position -150.
Moving right

We would like the paddle to move right when we
press the right arrow key.

To move right, we will move in the positive X
direction

We will add a new event, press right key.
The script

When the right arrow key event occurs, we will
change the x position by 10 units.
Attempt to move left

We want to make it so when you press the left
arrow key, the paddle moves to the left.

Try it out: Attempt to repeat this process for the
left arrow
Our Final Paddle Script:
Let us make our second
paddle

We want this paddle to
be in the upper half
and respond to a and
d keys.
Let us add the ball sprite:

I added my soccer ball by
clicking the and selecting
my soccer ball.
Programming the soccer
ball:

We would like our ball to…
be center in the screen,
select a random direction
move 10 steps forever,
but.. bounce around the screen.

Sounds complicated…
First center the ball
(On a grid, the coordinates 0,0 are the center of the screen)
Next, select a random
direction
This is based on a 360 degree angle system
We want the program to pick a random number
between 0 and 360
Then moving

After a random direction is picked….
…we want the ball to move 10 steps forward
Now, we need to make it
bounce off our paddles.
Every time the soccer ball hits a paddle, we need it to turn
around and bounce off
Let us make our goals.

Let us add the “endzones” to the background.
If the soccer ball hits one of these “endzones”, the
other team will score/the game will end
When the ball hits a red
“endzone”, the game is
over.
Key code here:
Can anyone explain
this statement?
Try it out!

Modify your pong game

Attempt to guide a person sprite through a maze

And more!

Helpful documentation can be found at:
https://scratch.mit.edu