Due: Thursday 11/21 10:00am

Submission name: work27_blast

a27_blast

Start by grabbing the modified Ball class code from thesource. You can find it in a new directory called Classes. This is similar to the Ball class with the following changes (these are already done, you need not change them):

  • The center of the ball is now a PVector.
  • The constructor takes the center of the ball and size as arguments.

Create a driver file with the following:

  • Global variables:
    • Ball[][] grid
    • Ball projectile
    • You make also want to include other constants as needed.
  • setup()
    • Instantiate grid to a 3 (rows) x 5 (cols) 2D array.
    • Call makeBalls()
    • Call newProjectile()
  • draw()
    • Clear the screen.
    • Call drawGrid()
    • Move and display projectile
    • Call processCollisions)()
  • keyPressed():
    • space: set the yspeed of projectile to -1
    • LEFT/RIGHT: move projectile left/right
  • void makeBalls(Ball[][] g)
    • Populates g with Ball objects. They should all be the same size, arranged such that each ball is a size distance away from its neighboring Ball objects.
  • void newProjectile(int psize)
    • Set projectile to a new Ball at the bottom center of the screen.
  • void drawGrid(Ball[][] g)
    • Draw all the Ball objects in g
  • void processCollisions(Ball p, Ball[][] g)
    • Check if p collides with any Ball objects in g.
    • If so, set the entry in the array to null, and call newProjectile