class logo

CS 122 - Day 2 Exercises

This page lists some problems for today's class. After today, you should be able to solve these problems on your own. Problems with this color are more challenging.

1) Loops

Make your sprite walk around the edge of the screen forever by using the "forever" loop command and "glide commands

2) Animation

Animate your the cat walking across the screen using the "forever" loop, the "move" command, the "wait" command, and the "next costume" command

3) Conditionals

Make the cat reappear on the other side of the screen after walking across it (using the above animation) by adding an "if" command that checks the cat's xposition and moves it if the xposition is greater than some value (like 180)

Download solution

4) Variables

Animate a marble rolling around the screen using the same loop style animation of the previous exercises only this time use a variable to control how fast it moves. Have the left and right arrow keys modify the variable so you can change the speed/direction of the marble.

5) Gravity

Simulate a ball bouncing by applying constant acceleration downward and bouncing the ball when it hits the bottom (hint, multiple the velocity by -1 to simulate a bounce).

6) Pen Commands

Use the Pen commands, a loop, and a variable (which is modified each time through the loop) to draw 5 concentric squares of different sizes around the origin.

Download solution

7) Spiral

Draw a square spiral from the origin

8) Circles

Drawn concentric circles around the origin