Making a game for class were balls fall from the top of the screen at random x variables and have slightly different speeds. I have everything figured out but 1 thing:
I need to figure out how to make it so when a ball is popped (when a ball hits the pad) the points value is displayed and floats to the top.I am rather new to processing and any help would be greatly appreciated.
ArrayList balls;
int ballRadius = 25;
float level = 1;
int score = 0;
float ballspop = 0;
void setup(){
size (650, 700);
fill(0);
smooth();
strokeWeight(4);
PFont font = loadFont("ComicSansMS-Bold-24.vlw");
textFont(font);
balls = new ArrayList();
for (int i = 0; i < level*2; i++){
balls.add(new Ball(random(15,width-15), random(-300,0), ballRadius));
}
}
text ("popped "+(ballspop/(level*2)*100 +"%") , 0 , height/2 + 50);
if ((ballspop/(level*2)*100)>= 50) text ("Click to start next level", 0, height/2);
else if ((ballspop/(level*2)*100)< 50) {
text ("Casfadsfad", 0, height/2);
}
}
for (int i = balls.size()-1; i >= 0; i--) {
Ball ball = (Ball) balls.get(i);
ball.move();
ball.display();
Ball(float xPos, float yPos, float bWidth) {
x = xPos;
y = yPos;
w = bWidth;
speed = 0;
gravity = 0.98;
bounceCount = 0;
}
void move() {
speed = speed + gravity;
y = y + speed;
if (y > height) {
speed = speed * -0.8;
y = height;
bounceCount++;
}
if (x == (mouseX)+25 && y == height){
noLoop();
}
}
void display()
{
// This is what i am using at the moment but it doesn't really work.
if(mouseX > x-50 && mouseX+32 < x+50 && y > height-40) { for (int r = 1; r < 7; r ++) { text (50- (bounceCount*10), x,(y - 10*r)); }}
if (bounceCount == 0){
fill (0,255,0);
}
else if (bounceCount == 1){
fill (255,255,0);
}
else if (bounceCount == 2){
fill (255,150,0);
}
else if (bounceCount == 3||bounceCount == 4){
fill (255,0,0);
}
else if (bounceCount == -1){
fill(255);
stroke(255);
}
else if ( bounceCount == 5) {
fill(200,200,200); }