Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Create a “Whack Alonzo” Game

snap.berkeley.edu/run
PUBLIC

This course material was developed under the Creative Commons Attribution-ShareAlike 4.0 International License CC BY-SA 4.0.
In this project, you can build a small interactive computer game with Snap!’s mascot
Alonzo.

In the game, you can get points by clicking Alonzo, who is randomly hopping around the
stage. But there’s a small twist. Alonzo will get a little more invisible each time you click
him. You hopefully have a quick eye.

You can start by giving your sprite an Alonzo costume from the costume library.

Now you can teach Alonzo, how to move. When the game starts, Alonzo should
repeatedly go to a random position.

Alonzo is currently moving as fast as he


can. Try to slow him down a little, so your
game is actually playable.

If Alonzo is clicked, the player’s score will change. Create a variable to store your score.

Set this variable to 0 when your game starts (green flag is clicked) and change it,
whenever Alonzo is clicked.

Test your current version of the game. Is Alonzo moving to random positions, when the
green flag is clicked? Does your score change, if you click Alonzo?

2
If your game works, you can now add the transparency (ghost effect). If your sprite is
completely visible, its ghost effect is 0. Is it absolutely transparent, the ghost effect is 100.

Set Alonzo’s transparency to 0 at the beginning of the game. In


case you can’t find Alonzo anymore while programming, you can
make him visible again with these blocks:

Refine the “when I am clicked”-script so that Alonzo gets a little more transparent each
time the script runs. Now, you need to click ten times until Alonzo is invisible (ghost effect
= 100).

Test your game! Unfortunately, you can only play once now, because Alonzo stays
invisible.

To play several rounds, you need to reset Alonzo’s ghost effect to 0


after he became completely invisible. Since there is no reporter for a
sprite’s graphic effect, you need to work with a helper variable in
which you count the number of clicks that hit Alonzo. You know, that
when you click Alonzo ten times, he is completely ghosted. If this is
the case, you want to reset Alonzo’s ghost effect as well as the clicks
counter to 0.
Add that script to the “when I am clicked” hat block. Also, don’t forget to set the clicks to 0
at the beginning of the game.

Now, you can add different difficulty levels. Alonzo could e.g. become
smaller throughout the game or you could reduce the time he waits
before he moves to another position.

Start tinkering and take your ideas to make it your computer game.

You might also like