I'm not totally new to processing, but I am a bit stuck on a program/game. The goal is to create a one-time event upon mouseClicked (here an "exploding" circle that expands and then loses opacity). There are forty circle objects bouncing randomly around the screen. When the circle(s) collide with the explosion and only the explosion while it is occurring, not other unexploded or already exploded circles, they become explosions themselves, thus starting a chain reaction.
So far I have implemented the mouseclicked explosion but am having trouble with the collision detection. I have added a boolean intersects function but am not sure where to call it (still fuzzy on calling elements in classes and getters/setters, but working on it). Any ideas or suggestions would be very helpful, I think I just need a push in the right direction. Thank you!
//tab 1
MovingCircles[] myCirclesArray = new MovingCircles[41];
int myLength = 40;
void setup() {
size(700, 400);
smooth();
frameRate = 100;
for(int i=0; i<myLength; i++) {
myCirclesArray[i] = new MovingCircles(300, 200, 20);
}
}
void draw() {
background(255);
for(int i=0; i<myLength; i++) {
myCirclesArray[i].drawCircles();
myCirclesArray[i].update();
myCirclesArray[i].checkCollisions();
}
}
void mouseClicked(){
myCirclesArray[myLength] = new MovingCircles(mouseX, mouseY, 0);
The sketch is a basic game-ish thing; a fly is loosely attached to the cursor, which then is supposed to follow the cursor to collect about 50 small sugar cubes on the screen. A large spider moves in a Brownian-motion pattern across the screen while this is happening. What I want to happen is:
--The white blocks to vanish when the fly passes over them --The "scream" in the minim library to play when the spider hits the fly --A thirty-second timer in the upper-right-hand corner. When the timer hits 30 seconds (30000 millis) the game resets.
The code for the main sketch is below--it is not complete (the timer and collision coding, especially), although the sketch does load without error messages at this point. Any help would be greatly appreciated, as my professor is unavailable through the weekend except by email. Thank you!
//Game
import ddf.minim.*;
import ddf.minim.signals.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;
//Minim Library import
Minim minim;
AudioSample scream;
AudioSample click;
//declares variables for audio samples (scream and click)
I am taking a class in processing and this is part of my first project. What I need is for the image that is active depending on keyPressed (there are 4 images, changing each time a different key is pressed) to change to one of three colors of the active image upon mouseClick. However, whenever I use keyPressed to change to images 2-4 and then click on it, it reverts to image 1. I need something like (keyPressed)image2_color1(click)image2_color2(click)image2_color3(back to beginning) and not (keyPressed)image2_color1(click)image1_color1. Help would be greatly appreciated-- the project is due Monday and this is the only problem I have left with the code, which is below.