CSC 221: Introduction to Programming
HW 1: Programming in Scratch
This assignment will introduce you to the process of programming using the animation/game
development tool Scratch. In designing, creating, and animating Scratch projects, you will
be learning the fundamental concepts of programming (e.g., variables, control, functions, objects),
which we will later
transfer to programming in Python.
You may work with a partner on Part 1 of this assignment. That is, you may select one classmate to work with on the five Scratch exercises. If you chose to have a partner, only one of you needs to turn in the exercises (with both names clearly identified). Part 2 of the assignment, the self-designed project, must be completed individually, although you can consult with your partner on implementation details. All Scratch projects should have instructions and credits entered in the Project Page.
Part 1: Scratch Exercises
- Create a new sprite of your own choosing. You might draw the sprite entirely from scratch
using the Paint Editor, or perhaps start with a photo and edit it. Then, animate that sprite so that
it performs a specific dance sequence when the green flag is clicked. For example, you might add a
sequence of blocks to the script of that sprite so that it moves 50 steps to the right, does a full
rotation, then moves back 50 steps to the left.
Once you have tested the behavior of your sprite, add a forever loop that encloses the dance steps.
Thus, clicking on the green flag should cause the sprite to repeat the dance move over and over (until
the stop sign is clicked to halt the script).
Next, modify your sprite so that it has multiple costumes. As it moves, it should
rotate through the costumes, yielding a more natural looking animation. Once you have done this,
make multiple copies of the sprite on the stage
(using the stamp button at the top of the stage) to create a group dance.
Finally, add a background image to the stage and music that plays in the background during the dance. Note: music files can be quite large, so consider using a small sample that repeats in order to keep your project size reasonable.
Save your sprites in a project named lastnameDance where lastname is your last name
- Create an animation that contains two characters carrying on a conversation. The two characters should enter the stage and then take turns speaking (or displaying text). For example, you might have the characters tell a joke:
(Character 1): How many psychologists does it take to change a light bulb?
Once you have your animation working, modify it so that the conversation can be easily changed. For each piece of text spoken/displayed by a character, you should have a variable that stores that text. The scripts should then access and speak/display the text. As a result, you should be able to change the conversation simply by changing the values of the variables.
(Character 2): I don't know, how many?
(Character 1): One, but the light bulb has to really want to change.
Save your sprite in a project named lastnameTalk where lastname is your last name
- Create a sprite that models a coin. Your coin sprite should have two costumes, depicting heads and tails (you can find and download your own coin images). When that sprite is clicked on, the costumes should toggle quickly between heads and tails, stopping at random on one of the two images. One way to accomplish this is to pick a random number, say either 10 or 11, then change the costume that many times.
Once you have your coin sprite working, add four variables to the project: number of heads, number of tails, percentage of heads, and percentage of tails. When the green flag is clicked, these variables should all be initialized to 0. Each time the coin is flipped, the appropriate variables should be updated so that they accurately reflect the coin flips since the last green flag. To make it clear what action the user should take, add instructions to the stage backdrop that tells the user to "Click on the coin to flip it."
Save your sprite in a project named lastnameFlip where lastname is your last name
- For this exercise, you will create a simple version of the old video game Pong. You will need three sprites to make the basic functionality work. You will need a line that runs the length of the right wall. You will need a small rectangle that serves as the paddle, moving up and down the right wall in response to the up and down arrow keys. Finally, you will need a ball that bounces around the screen.
When the game begins (at the click of the green flag), the ball should be positioned in the center of the screen and the paddle should be positioned on the right edge. When the space bar is pressed, the ball should begin moving in a random direction, and should bounce off the walls. The player can control the paddle using the up and down arrow keys. Whenever the ball hits the paddle, the ball should bounce off (i.e., its direction should become inverted). If the ball gets past the paddle and hits the line along the right wall, then the game should end (and all scripts stop).
When you have this basic functionality working, add a second paddle and line on the left side of the screen. Have this paddle controlled by the 'a' and 'z' keys. Then, add a scoreboard to the game. Whenever the ball gets past a paddle, the other player's score should be incremented.
Feel free to elaborate.
Save your project under the name lastnamePong where lastname is your last name
- For this exercise, you will create a simple version of the old video game Frogger.
First, create a sprite (call it the frog, although it need not look like a frog) and animate it.
The frog should begin at the bottom of the screen, and move in response to clicks of the arrow keys (up, down, left, or right).
Then add several identical sprites
(call them trucks) that move horizontally, back and forth across the stage at even intervals.
If a truck sprite ever touches the frog, a sound should be played and the frog should return to its starting point. If the frog reaches the top, then a victory song should play.
Tinker with the number, placement, and speed of the truck sprites so that it is challenging
to move the frog sprite from the bottom of the stage to the top, and back again. Feel free to elaborate.
Save your project under the name lastnameFrogger where lastname is your last name
Part 2: Animation/Game Project
Finally, you will build upon the programming skills you developed in Part 1 to
design and implement a Scratch animation or game. The content of your Scratch project
is entirely up to you. It might be an animation that tells a story or explains some topic.
It might be an interactive game or a puzzle. Or, it might be something completely different.
Devise something you find interesting and engaging, then go for it.
At a bare minimum, your project should have the following characteristics:
- It should have significant original content. It is fine to get ideas and small code segments
from existing projects, but the bulk of your project should come from your own ideas and code.
- It should involve multiple, interacting sprites, some of which you created on your own.
- More than one of the sprites should exhibit complex behaviors (i.e., have multiple
scripts that utilize control blocks and variables).
- The project should involve some interaction with the user, either in controlling the action or
providing input that is used by the project.
- It should utilize music and sound effects, as appropriate.