All code to be done in processing software, free downloadable software from processing.org
Assignment Instructions
Video attached for further visual explanation
1. Write code to define 4 parallel a
ays to store info for unlimited balls (right now we do not know the size). The names of the parallel a
ays are:
a. xPos
. yPos
c. xSpeed
d. ySpeed
e. ballColors
2. Write a function addBall with following features:
1.
a. It does not return any value
. Takes in the following parameters:
i. X co-ordinate of the ball
ii. Y co-ordinate of the ball
iii. Color of the ball
c. Goal of addBall: to make changes to the following a
ays:
i. Append the first paraeter to the a
ay xPos.
ii. Append the second parameter to the a
ay yPos.
iii. Append a random value between 2 and 5 to the a
ay xSpeed.
iv. Append a random value between 3 and 7 to the a
ay ySpeed.
v. Append the third parameter to the a
ay ballColors.
3. Inside void setup() do the following:
a. Code a for-loop that runs 5 times. Inside the loop body, write code to call addBall with random values for the first 2 parameters and color white as the value for the 3 rd parameter.
4. Inside void mousePressed () :
a. Call addBall once with mouseX , mouseY as values to first 2 parameters and a random color as the 3rd paramete
5. Inside void draw() :
a. Using a for-loop, make sure to draw all the balls with the information in the a
ays xPos, yPos, xSpeed, ySpeed, ballColors.
Lavf XXXXXXXXXX