Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

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...

1 answer below »
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
Answered Same Day Sep 22, 2021

Solution

Ramachandran answered on Sep 22 2021
139 Votes
Order-91729
ouncing_balls
ouncing_balls.pde
list of intege
IntList xPos = new IntList();
IntList yPos = new IntList();
IntList xSpeed = new IntList();
IntList ySpeed = new IntList();
IntList ballColors = new IntList();
int ballRadius = 80;
int maxWidth = 750;
int maxHeight = 800;
color white = color(255);
void setup(){
size(750, 800);
stroke(0);

for(int i=0;i<5;i++){
addBall(randomInt(0, maxWidth), randomInt(0, maxHeight), white);
}
}
void draw(){
background(255);
for(int i=0;i ...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here