Need help with collison detection for duck/koopa hunt :) PLEASE HELP!
int score = 0;
int dir=1;
int x,y,w,h;
float x1,y1;
float x2,y2;
PImage tree;
PImage target;
PImage koopa;
PImage redmush;
PImage koopa2;
int koopa2x[];
int koopa2y[];
int koopa2app[];
boolean starts=false;
boolean kill=true;
int [] xkoopa2 = new int [2];
int [] ykoopa2 = new int [2];
void setup(){
size(800,600);
noStroke();
minim = new Minim(this);
player = minim.loadFile("Kill The Noise - Real Life (Original Mix).mp3");
player.play();
tree = loadImage("tree2.gif");
target = loadImage("untitled2.png");
koopa = loadImage("smas1paratroopa.gif");
redmush = loadImage("smas1mushroom.gif");
koopa2 = loadImage("Red-Koopa.gif");
x1=(random(0,610));
x2=(random(0,610));
y1=(random(0,610));
y2=(random(0,610));
for(int a=0; a<5; a++){
koopa2app[a]=1;
}
xkoopa2[0]=0;
for (int a=1; a<2; a++){
xkoopa2 [a] = xkoopa2 [a-1]+400;
}
for (int a=0; a<2; a++){
ykoopa2 [a] = 402;
}
}
void draw(){
noCursor();
background(175);
fill(240,8,24);
textFont(loadFont("VinetaBT-Regular-48.vlw"), 48.0);
textAlign(CENTER);
text("Koopa Hunt", width/2,height/8,48);
textFont(loadFont("Swiss911BT-ExtraCompressed-48.vlw"), 30.0);
text("Aim the curser to shoot the Koopa's\n" +
"\n" +
"Koopa's will appear at the\n" +
"\n" +
"bottom of the screen\n" +
"\n" +
"Shoot Koopa's to win points\n" +
"\n" +
"Press ENTER to start", width/2, height/4, 86);
// koopa
image(koopa,370,250,50,50);
if (keyCode==ENTER){
starts=true;
}
if (starts){
background(40,240,255);
y1=y1-3;
x1=x1+2;
for(int a=0; a<5) a++){
if(koopa2app[a]==1){
}
}
if (y1>=600) {
y1=int(0);
x1=int(random(600,200));
}
if (x1>=600) {
x1=int(0);
y1=int(random(600,200));
}
if (kill)image(koopa,x1,y1,50,50);
for (int a=0;a<2; a++){
xkoopa2[a] = xkoopa2[a] -5;
if (kill)image(koopa2,xkoopa2[a],ykoopa2[a],50,50);
if(xkoopa2[a] <=0){
xkoopa2[a]=850;
}
}
}
//draw field
fill(0,200,10);
rect(0,450,800,150);
//mouseX, mouseY return the x & y coordinate of the mouse cursor
image(target,mouseX,mouseY,35,35);
//draw tree
image(tree, 20, 160,220,300);
// green mushroom
fill(240,8,24);
text("Score "+score,635,590);
image(redmush,550,550,50,50);
}
void mousePressed(){
if(mousePressed)kill=false;
}