class Objects{
int objX, objX_c;
int objY, objY_c;
int charX;
int charY;
int score;
int objC = 8;
int i;
int[][] objList = new int[500][2];
boolean[] view = new boolean[500];
int count = 0;
PImage purseObj;
String[] purse = new String[12];
String path = "";
// make image arr
void setup(){
purse[0] = "purse.png";
purse[1] = "purse2.png";
purse[2] = "purse3.png";
purse[3] = "purse4.png";
purse[4] = "purse5.png";
purse[5] = "purse6.png";
purse[6] = "purse7.png";
purse[7] = "purse8.png";
purse[8] = "purse9.png";
purse[9] = "purse10.png";
purse[10] = "purse11.png";
purse[11] = "purse12.png";
score = 0;
}
void newObj(){
int stringX = random(10,width-10);
int stringY = random(10,height-70);
objList[count][0] = stringX;
objList[count][1] = stringY;
view[count] = true;
count++;
}
void drawObj(int charX, int charY){
charX = charX + 23;
for(i=0; i<count; i++){
if(view[i]){
purseObj = loadImage(path+purse[i%purse.length]);
objX = objList[i][0];
objY = objList[i][1];
objX_c = objX+20;
objY_c = objY + 15;
// calibrated for image padding
if((charX >= objX)&&(charX <= objX_c)&&(charY <= (objY+6)&&(charY >= (objY-30)))){
if(view[i]){
view[i] = false;
score++;
}
}
else{
if(view[i]){
image(purseObj, objX, objY);
}
}
}
}
}
void objSpawn(){
if((count-score) < objC){
newObj();
}
}
}