private ArrayList<Obj> targets, splashes, flyers, rain;
private ArrayList<Integer> scores;
private ArrayList<ArrayList<Obj>> allObjects;
private int score,time,gameStage,lives;
final int FULL_AMMO=8, NUM_TARGETS=3, NUM_FLYING_TARGETS=2, RAIN_DENSITY=30;
private PImage backScreen,bloodyScreen,splash;
targets = new ArrayList<Obj>();
splashes = new ArrayList<Obj>();
flyers = new ArrayList<Obj>();
rain = new ArrayList<Obj>();
while(rain.size()<RAIN_DENSITY){
scores = new ArrayList<Integer>();
while(targets.size()<NUM_TARGETS){
targets.add(new Target());
while(flyers.size()<NUM_FLYING_TARGETS){
flyers.add(new FlyingTarget());
allObjects = new ArrayList<ArrayList<Obj>>();
allObjects.add(splashes);
backScreen = loadImage("background.jpg");
bloodyScreen = loadImage("bloodyScreen.png");
splash = loadImage("splash.png");
int highScore=scores.get(0);
for(int i=1;i<scores.size();i++)
if(scores.get(i)>highScore) highScore=scores.get(i);
if(highScore==0) return "---";
for(int i=0; i<lives; i++)
image(backScreen,width/2,height/2);
image(bloodyScreen,width/2,height/2,width,height);
text("High Score\n"+highScore(),width/2,85);
text("THE HORDE",width/2,250);
Button playButton = new Button("PLAY",width/2,height-200);
Button rulesButton = new Button("DIRECTIONS",width/2,height-150);
if(gun.getAmmo()>=0 && gameStage==0){
if(playButton.isPressed()){
((Target)t).sendToBackPosition();
if(rulesButton.isPressed()){
Button back = new Button("Okay!",width/2,150);
image(backScreen,width/2,height/2);
text("use your crosshair to aim at the zombies",gun.getX(),gun.getY()-20);
text("use MOUSE1 to shoot",gun.bx,gun.by-100);
text("we will keep track of the number of zombies you kill",width/2,100);
text("You have 10 lives",width/2,50);
if(back.isPressed() && gun.getAmmo()>=0 && gameStage==4){
image(backScreen,width/2-mouseX/10+width/20,height/2-mouseY/10);
for(ArrayList<Obj> list : allObjects){
text("LIVES",width-150,60);
text(lives+" "+getLivesTally(),width-150,90);
text((int)time,width/2,50);
if(lives<=0) gameStage=3;
image(backScreen,width/2,height/2);
image(bloodyScreen,width/2,height/2,width,height);
text("YOU DIED",width/2,200);
text("You killed "+score+" zombies in "+(int)time+" seconds",width/2,300);
text("Thank you for playing!",width/2,35);
Button p = new Button("CONTINUE",width/2,height/2+50);
if(p.isPressed()&& !(gun.getAmmo()<=0) && gameStage==3){
if(gameStage==1) gameScreen();
if(gameStage==3) endScreen();
if(gameStage==4) howToPlay();
for(int i=0;i<targets.size();i++){
if(((Target)targets.get(i)).getSize()>255){
splashes.add(new Splash(splash,targets.get(i).getX(),targets.get(i).getY()));
targets.add(new Target());
for(int i=0;i<flyers.size();i++){
if(((Target)flyers.get(i)).getSize()>255){
splashes.add(new Splash(splash,flyers.get(i).getX(),flyers.get(i).getY()));
flyers.add(new FlyingTarget());
for(int i=0;i<targets.size();i++){
Target t = ((Target)targets.get(i));
double distance = (Math.sqrt((t.getX()-mouseX)*(t.getX()-mouseX)+(t.getY()-mouseY)*(t.getY()-mouseY)));
if(distance<=t.getSize()/2 && gameStage==1){
targets.add(new Target());
for(int i=0;i<flyers.size();i++){
Target t = ((Target)flyers.get(i));
double distance = (Math.sqrt((t.getX()-mouseX)*(t.getX()-mouseX)+(t.getY()-mouseY)*(t.getY()-mouseY)));
if(distance<=t.getSize()/2 && gameStage==1){
flyers.add(new FlyingTarget());
if(keyCode==LEFT) gameStage--;