How can I make the class Candy disappear when Eyeball touch it?
String gameState;
PImage sc; // SCARLET FOREST
void setup() {
size(810, 810);
eyeballSetup();
for(int i=0;i<candies.length;i++){
candies[i] = new Candy(random(width),random(height));
gameState = “START”;
sc=loadImage(“SC.png”);
}
}
void draw() {
if(gameState == “START”){
startGame();
} else if(gameState==“PLAY”){
playGame();
}else if(gameState== “WIN”){
winGame();
}else if(gameState == “LOSE”){
loseGame();
}
}
void startGame(){
background(sc);
image(sc,810,810);
textAlign(CENTER);
textSize(50);
fill(181,60,126);
text(“Click here to play”,width/2,height/2-20);
textSize(40);
fill(188,50,127);
text(“levels 1 2 3”, width/2,height/2+30);
if(mousePressed==true){
gameState = “PLAY”;
}
}
void playGame(){
background(sc);
image(sc,810,810);
// Move eyeball.
eyeballMove();
// Draw coins.
for(int i=0;i<candies.length;i++){
candies[i].draw();
}
// Draw eyeball.
eyeballDraw(x, y, rot);
}
void winGame(){
}
void loseGame(){
}
void resetGame(){
}
void keyPressed() {
if (key==‘w’||key==‘W’) {
eyeballUp();
} else if (key==‘s’||key==‘S’) {
eyeballDown();
} else if (key==‘a’||key==‘A’) {
eyeballLeft();
} else if (key==‘d’||key==‘D’) {
eyeballRight();
}
}
//class
class Candy {
float candy_x, candy_y;
boolean candy_isVisible;
Candy(float ix, float iy){
candy_x = ix;
candy_y = iy;
candy_isVisible = true;
}
void draw(){
if(!candy_isVisible){
return;
}
fill(255,0,90);
rect(candy_x, candy_y,30,50);
}
}
Candy[] candies = new Candy[15];
int r; // EyeBall’s raio.
int pupil_r, x, y, rot; // Eyeball’s Features.
int speed=3; // Eyeball’s speed
// Eyeball’s functions…
void eyeballSetup(){
r= 30;
pupil_r= 10;
x=width/2;
y=height/2;
rot=0;
}
void eyeballMove() {
if (rot==0) {
y=y+speed;
eyeballDown();
}
if (rot==90) {
x=x-speed;
eyeballLeft();
}
if (rot==180) {
y=y-speed;
eyeballUp();
}
if (rot==270) {
x=x+speed;
eyeballRight();
}
if (x<25) {
x=x+speed;
eyeballRight();
}
if (x>785) {
x=x-speed;
eyeballLeft();
}
if (y<25) {
y=y+speed;
eyeballDown();
}
if (y>785) {
eyeballUp();
}
}
void eyeballDraw(int x, int y, int rot) {
//olho
ellipseMode(CENTER);
translate(x, y);
rotate(radians(rot));
fill(255);
noStroke();
ellipse(0, 0, r,r);
//pupila
fill(0);
ellipse(0,0, pupil_r, pupil_r);
}
void eyeballUp() {
rot=180;
}
void eyeballDown() {
rot=0;
}
void eyeballLeft() {
rot=90;
}
void eyeballRight() {
rot=270;
}
//PS im stuck pls help