INQ241B
Mobile Apps

Activity 5

Create a Pong App

Pong is a classic video game based on table tennis. If you have never played Pong, it is a game with a ball bouncing around the screen. The player controls a paddle that the ball can bounce off of but can only move along one edge. The goal is to prevent the ball from getting past the paddle.

Details

Use App Inventor to create a Pong app. The app should have the following components:

  1. A canvas component that takes up the entire screen. Note, in order to get the canvas to fill its parent, the screen, the screen's scrollable property must not be checked.

  2. A Ball component inside the canvas. The ball should have an initial heading, interval, and speed so that it moves diagonally in the canvas.

  3. An ImageSprite component inside the canvas. The sprite should be located near the bottom of the canvas and have an image that is wider than it is tall. The sprite should have an initial heading, interval, and speed so that it is not moving.

The app should have blocks that do the following:

  1. When the ball reaches an edge of the canvas, it bounces off of the edge.

  2. When the user drags the sprite it moves left and right to match the user's finger location. Note, the sprite should not move up and down.

  3. When the ball collides with the sprite, it bounces off. Since the sprite is at the bottom of the canvas it will bounce like it is hitting the bottom of the canvas. The bottom edge of the canvas is represented with the number -1.

  4. If the ball reaches the bottom edge of the canvas, the ball stops and the text "Game Over" is displayed.

  5. If the user touches the canvas while "Game Over" is displayed, the game resets.