image Computational Thinking on Faster and Faster

Suppose we start with the following simple game:

There are 5 pearls.
The pearls start out moving in a random direction.
When a pearl reaches b ottom border, it turns around.

How can we make the pearls move faster whenever they wrap around? This can be simply done by adding the following sentence:

When a pearl reaches a border, the speed of the pearl increases by 2.

Putting everything together, we have

There are 5 pearls. The pearls start out moving in a random direction.
When a pearl reaches a border, it turns around.
When a pearl reaches a border, the speed of the pearl increases by 2.


Try it yourself: How can you use a time-controlled game to increase the speed (Hint: whenever the two objects collide, the speed of the pearls increases)


Complete Sample Games for Computational Thinking

// Game #1. Faster and Faster Pong.

There is a ball.
You control the brick.
When you press the left arrow key, the brick moves left.
When you press the right arrow key, the brick moves right.

The speed of the ball is initially 3 pixels per frame.
The speed of the brick is 8 pixels per frame.
The ball starts out moving down.
When the ball and the brick collide, the speed of the ball increases by 1.
When the ball and the brick collide, the score increases by 1.
When the ball and the brick collide, the ball reverses direction.
When the ball reaches the border, the ball reverses direction.
When the brick reaches the border, the brick wraps around.

When the score is equal to 15, you win.
When the ball reaches the bottom border, gameover.

Map:

-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
---------k


Next page

Tutorials Home