Select Page

CS 1334 University of TX Dallas Pong Ball Programming Project Lab Report

Question Description

I’m working on a javascript exercise and need support to help me learn.

Lab Assignment 10 – Part 1: Pong- Ball

We’re going to make a game: Pong-Ball!

  1. Use 2 rectangles to divide the screen into two areas
  2. Define variables, as necessary to use for determining the size and position of these background rectangles:
    • Left side of the screen for buttons and scores, Left section width: approx. 1/3 of the screen
    • Right part of the screen for the game action, Right section width: approx. 2/3 of the screen

ADD Balls:

Write a function: drawBall, with function input parameters: xPosition, yPosition, ballColor. When this function is executed, it will draw a colored ball. Each ball should be about 5 pixels wide, stroke is optional.

Create 5 arrays to hold the xPosition, yPosition, xSpeed, ySpeed, and color of each ball?. Create a variable: maxBalls that specifies the maximum number of balls to create.

Timer: Every 30 seconds (or so) randomly add a new ball ? – up to the maximum number of balls

MOVE the Balls:

In the Processing draw function( ):
Use a for-loop so that: for each ball:
call the drawBall function.
update xPosition by adding xSpeed
update yPosition by adding ySpeed ?

  1. Make the balls bounce: If the ball hits the walls (defined by the wide rectangle) it should bounce:
    • If it hits the left or right wall, the xSpeed should reverse ?
    • If it hits the top or bottom wall, the ySpeed should reverse ?
  1. Make the bounce have a random ‘wobble ?behavior’

Whenever the ball bounces, take a random amount (between -0.5 and 0.5) and subtract it from the xSpeed and add it to the ySpeed

"Place your order now for a similar assignment and have exceptional work written by our team of experts, guaranteeing you "A" results."

Order Solution Now