package com.ld57.game;

import java.util.Iterator;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.InputAdapter;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.audio.Sound;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.ScreenUtils;
import com.badlogic.gdx.utils.viewport.FitViewport;
import com.badlogic.gdx.utils.viewport.Viewport;

import Global.Global;
import effects.DirtTunnel;
import effects.Explosion;
import effects.FireParticle;
import effects.Fireworks;
import effects.Torch;
import effects.Tunnel;
import entities.Ball;
import entities.EvilShip;
import entities.PausePerson;
import entities.Player;
import levelElements.Dirt;
import levelElements.DirtChunk;
import levelElements.Drill;
import levelElements.Engine;
import levelElements.Gun;
import levelElements.Shipv1;
import levelElements.StoreIcon;
import unearthables.Amethyst;
import unearthables.AmethystHUD;
import unearthables.Copper;
import unearthables.CopperHUD;
import unearthables.Diamond;
import unearthables.DiamondHUD;
import unearthables.Food;
import unearthables.Gold;
import unearthables.GoldHUD;
import unearthables.Platinum;
import unearthables.PlatinumHUD;
import unearthables.Ruby;
import unearthables.RubyHUD;
import unearthables.Sapphire;
import unearthables.SapphireHUD;
import unearthables.Silver;
import unearthables.SilverHUD;
import unearthables.Topaz;
import unearthables.TopazHUD;
import unearthables.UnearthAmethyst;
import unearthables.UnearthCopper;
import unearthables.UnearthDiamond;
import unearthables.UnearthFood;
import unearthables.UnearthGold;
import unearthables.UnearthPlatinum;
import unearthables.UnearthRubies;
import unearthables.UnearthSapphire;
import unearthables.UnearthSilver;
import unearthables.UnearthTopaz;

public class LevelThree implements Screen {
	final ddd game;

	private Music levelMusic;
	private OrthographicCamera camera;
	private Viewport vport;
	private Player player;
//	private Player2 player2;
//	private Player3 player3;
//	private Player4 player4;
//	private Player5 player5;
//	private Player6 player6;
	int currentFrame = 1;
	int MAX_FRAMES = 5;

	public int sw = ddd.MW;// was 1440;
	public int sh = ddd.MH;// 720

	private Array<EvilShip> evilShips;

	// private Vector3 mousePos;
	private PausePerson pp;
	// private DeliveryTruck deliveryTruck;
	private Sound enter;
	private Sound enter2;
	private Sound death;
	private int isDeadTimer = 40;
	private boolean isEverythingLoaded;
	private String whatIsLoading = "";
	private int delayTimer;
	private int DTSpd = 2;// was 5
	private boolean isLevelAdded;
	private boolean isPlayerAdded;
	private Sound reverseSlide;
	private Sound click;
	private Sound click2;
	private Sound click3;
	private Sound click4;
	private Sound click5;
	private Sound click6;
	private Sound click7;
	private Sound boom;
	private boolean evilShipLoop;
	private boolean isEvilShipsAdded;
	private Torch torch;
	public Array<FireParticle> fireParticles;
	private Tunnel tunnel;
	private Array<Dirt> dirts;
	private DirtTunnel dirtTunnel;
	private Array<DirtChunk> dirtChunks;
	private UnearthRubies rubies;
	private Array<Ruby> rubyGems;
	private UnearthSapphire sapphires;
	private Array<Sapphire> sapphireGems;
	private UnearthAmethyst amethysts;
	private Array<Amethyst> amethystGems;
	private UnearthCopper coppers;
	private Array<Copper> copperMetals;
	private UnearthDiamond diamonds;
	private Array<Diamond> diamondGems;
	private UnearthFood foods;
	private Array<Food> foodHealth;
	private UnearthGold golds;
	private Array<Gold> goldMetals;
	private UnearthPlatinum platinums;
	private Array<Platinum> platinumMetals;
	private UnearthSilver silvers;
	private Array<Silver> silverMetals;
	private UnearthTopaz topazs;
	private Array<Topaz> topazGems;
	private Shipv1 shipv1;
	private Engine engine;
	private Drill drill;
	private Gun gun;
	private int cameraShakeTimer;
	private float cameraInitX;
	private float cameraInitY;
	private boolean isCameraPositionInitialized;
	private boolean onetime;
	private boolean playSoundOnce;
	private boolean onlyGoThroughLevelEndOnce;
	private AmethystHUD amethystHUD;
	private CopperHUD copperHUD;
	private DiamondHUD diamondHUD;
	private GoldHUD goldHUD;
	private PlatinumHUD platinumHUD;
	private RubyHUD rubyHUD;
	private SapphireHUD sapphireHUD;
	private SilverHUD silverHUD;
	private TopazHUD topazHUD;
	private Fireworks fireworks;
	private Array<Explosion> explosions;
	private StoreIcon storeIcon;

	public LevelThree(final ddd game) {
		this.game = game;
		// camera
		camera = new OrthographicCamera();
		vport = new FitViewport(sw, sh, camera);
		System.out.println("trying to create all the things!");
		// sounds
		// music
		levelMusic = Gdx.audio.newMusic(Gdx.files.internal("sfx/dddGameMusic.ogg"));
		levelMusic.setLooping(true);
		levelMusic.setVolume(1f);
		camera.position.set(vport.getWorldWidth() / 2, vport.getWorldHeight() / 2, 0);
		// sfx
		reverseSlide = Gdx.audio.newSound(Gdx.files.internal("sfx/reverseSlide.ogg"));// death?
		death = Gdx.audio.newSound(Gdx.files.internal("sfx/death.ogg"));// death?
		click = Gdx.audio.newSound(Gdx.files.internal("sfx/click.ogg"));
		click2 = Gdx.audio.newSound(Gdx.files.internal("sfx/click2.ogg"));
		click3 = Gdx.audio.newSound(Gdx.files.internal("sfx/click3.ogg"));
		click4 = Gdx.audio.newSound(Gdx.files.internal("sfx/click4.ogg"));
		click5 = Gdx.audio.newSound(Gdx.files.internal("sfx/click5.ogg"));
		click6 = Gdx.audio.newSound(Gdx.files.internal("sfx/click6.ogg"));
		click7 = Gdx.audio.newSound(Gdx.files.internal("sfx/click7.ogg"));
		boom = Gdx.audio.newSound(Gdx.files.internal("sfx/boom.ogg"));
		// add pause person. This is added to every screen in the game you want a pause menu.
		pp = new PausePerson(Gdx.graphics.getWidth() / 2 - 210, Gdx.graphics.getHeight() - 235f);
		enter = Gdx.audio.newSound(Gdx.files.internal("sfx/click7.ogg"));
		enter2 = Gdx.audio.newSound(Gdx.files.internal("sfx/click8.ogg"));
		// add an empty array to fill as the game goes on. ;-)
//		peoples = new Array<Person>();
//		plants = new Array<Plant>();
//		workers = new Array<Worker>();
		evilShips = new Array<EvilShip>();
//		balls = new Array<Ball>();
		if (ddd.TruckArriveTimer < 1000)
			ddd.TruckArriveTimer += 2000;
		fireParticles = new Array<FireParticle>();
		torch = new Torch();
		tunnel = new Tunnel();
		dirts = new Array<Dirt>();
		// gems and metals
		rubies = new UnearthRubies();
		rubyGems = new Array<Ruby>();
		amethysts = new UnearthAmethyst();
		amethystGems = new Array<Amethyst>();
		sapphires = new UnearthSapphire();
		sapphireGems = new Array<Sapphire>();
		coppers = new UnearthCopper();
		copperMetals = new Array<Copper>();
		diamonds = new UnearthDiamond();
		diamondGems = new Array<Diamond>();
		foods = new UnearthFood();
		foodHealth = new Array<Food>();
		golds = new UnearthGold();
		goldMetals = new Array<Gold>();
		platinums = new UnearthPlatinum();
		platinumMetals = new Array<Platinum>();
		silvers = new UnearthSilver();
		silverMetals = new Array<Silver>();
		topazs = new UnearthTopaz();
		topazGems = new Array<Topaz>();
		// gem/metal HUD stuff
		amethystHUD = new AmethystHUD(0, 0);
		copperHUD = new CopperHUD(0, 0);
		diamondHUD = new DiamondHUD(0, 0);
		goldHUD = new GoldHUD(0, 0);
		platinumHUD = new PlatinumHUD(0, 0);
		rubyHUD = new RubyHUD(0, 0);
		sapphireHUD = new SapphireHUD(0, 0);
		silverHUD = new SilverHUD(0, 0);
		topazHUD = new TopazHUD(0, 0);
		// explosions
		fireworks = new Fireworks();
		explosions = new Array<Explosion>();
		// level stuff
		dirtTunnel = new DirtTunnel();
		dirtChunks = new Array<DirtChunk>();
		shipv1 = new Shipv1(Global.P.x, Global.P.y);
		engine = new Engine(Global.P.x, Global.P.y);
		drill = new Drill(Global.P.x, Global.P.y);
		gun = new Gun(Global.P.x, Global.P.y);
		storeIcon = new StoreIcon(400, 400);
		cameraInitX = camera.position.x;
		cameraInitY = camera.position.y;
	}

	public void update(float dt) {
		// now it's not tied to the players death. Just set the cameraShakeTimer;
		if (cameraShakeTimer > 0) {
			u.UsefulMethods.MoveCameraAroundRandomly(camera, 1, 4);
			camera.update();
			cameraShakeTimer -= 1;
		} else {
			camera.position.x = cameraInitX;
			camera.position.y = cameraInitY;
		}
	}

	@Override
	public void show() {
		Gdx.input.setInputProcessor(new InputAdapter() {
			@Override
			public boolean keyDown(int keyCode) {
				if (keyCode == Input.Keys.ESCAPE && !Global.IsPaused) {
					if (!Global.SetVolumeToZero)
						enter.play(2f);
					Global.IsPaused = true;
				} else if (keyCode == Input.Keys.ESCAPE && Global.IsPaused && Global.IsKeyBindings && Global.IsSetKey) {
					if (!Global.SetVolumeToZero)
						enter2.play(2f);
					Global.IsSetKey = false;
				} else if (keyCode == Input.Keys.ESCAPE && Global.IsPaused && Global.IsKeyBindings) {
					if (!Global.SetVolumeToZero)
						enter2.play(2f);
					Global.IsKeyBindings = false;
					pp.IsSwitchingToKeyBindings = true;
				} else if (keyCode == Input.Keys.ESCAPE && Global.IsPaused) {
					if (!Global.SetVolumeToZero)
						enter2.play(2f);
					Global.IsPaused = false;
				}
				if (Global.IsSetKey)
					Global.KeycodeSet = keyCode;
				return true;
			}

			@Override
			public boolean touchDown(int x, int y, int pointer, int button) {// this is for capturing mouse clicks
				if (Global.IsSetKey && Global.IsPaused)
					Global.KeycodeSet = button;
				return true;
			}

		});
	}

	@Override
	public void render(float delta) {
		// bind the fbo (lighting)
		// fbo.begin();
		Gdx.gl.glClearColor(0f, 0f, 0f, 0f);// lighting
		Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
		// this is going to be my background, depending on what scene or area you are in. Trust me, this is intentional.
		ScreenUtils.clear(.09f, .02f, .01f, 1);// Brown (is this going to get in the way?)
		// ScreenUtils.clear(.2f, .5f, .2f, 1);// green.
		game.batch.setProjectionMatrix(camera.combined);
		if (!isCameraPositionInitialized) {
			cameraInitX = Gdx.graphics.getWidth() * .5f;
			cameraInitY = Gdx.graphics.getHeight() * .5f;
			isCameraPositionInitialized = true;
		}
		game.batch.begin();// start the batch. (should be already clear...)
		// System.out.println("game batch begin has been called. " + game.batch + " see? ");
		if (Global.IsPaused) {
			ScreenUtils.clear(0, 0, 0, 1);// black
			camera.position.x = Gdx.graphics.getWidth() * .5f;
			camera.position.y = Gdx.graphics.getHeight() * .5f;
			camera.update();
			// System.out.println("cameraX: " + camera.position.x + " cameraY: " + camera.position.y);
			pp.RenderEntirePauseMenu(delta, game, game.font, levelMusic, camera);
			// DebugRenderer.DrawDebugRectangle(pp.playerSelectLeftRect, Color.RED, camera.combined);// if you want to use this, don't forget to comment out some
			// code in the main render loop below...
		} else {
			// System.out.println("this should run before level.render");
			if (!isEverythingLoaded) {
				// lets load everything in pieces, while it's loading everything lets render stuff to the screen that represents the load state.
				game.font.setColor(Color.GRAY);
				game.font.draw(game.batch, whatIsLoading, camera.position.x - ddd.MW / 2 + 420, camera.position.y + ddd.MH / 2 - 247);// shadow
				game.font.setColor(Color.DARK_GRAY);
				game.font.draw(game.batch, whatIsLoading, camera.position.x - ddd.MW / 2 + 418, camera.position.y + ddd.MH / 2 - 245);
				if (!isLevelAdded && delayTimer <= 0) {
					System.out.println("doing the level");
					whatIsLoading = "Loading: there is aboslutely something here. Lets find out what it is";
					for (int x = 0; x < 100; x++) {// trying 5 of them.
						FireParticle firep = torch.obtain();
						firep.rect.x = Global.P.x;
						firep.rect.y = Global.P.y;
						fireParticles.add(firep);
					}
					System.out.println("down into the depths, *scuse me* here's your sign. Like anyone wouldn't be able to figure that out. Into the tunnel we go");
					for (int x = 0; x < 2000; x++) {// trying 5 of them.
						Dirt dirt = tunnel.obtain();
						dirt.rect.x = ddd.MW / 2;
						dirt.rect.y = ddd.MH / 2;
						dirts.add(dirt);
					}
					System.out.println("add ruby gems, no, not that rubygems (rails) ;-)");
					for (int x = 0; x < MathUtils.random(20, 40); x++) {// trying 5 of them.
						Ruby ruby = rubies.obtain();
						ruby.rect.x = ddd.MW / 2;
						ruby.rect.y = ddd.MH / 2;
						rubyGems.add(ruby);
					}
					System.out.println("add ameth amethys a crap uh ... a-meth-yst there got it.");
					for (int x = 0; x < MathUtils.random(40, 80); x++) {// trying 5 of them.
						Amethyst amethyst = amethysts.obtain();
						amethyst.rect.x = ddd.MW / 2;
						amethyst.rect.y = ddd.MH / 2;
						amethystGems.add(amethyst);
					}
					System.out.println("add sapphire gems, blueeee blew blast blueberries?");
					for (int x = 0; x < MathUtils.random(40, 60); x++) {// trying 5 of them.
						Sapphire sapphire = sapphires.obtain();
						sapphire.rect.x = ddd.MW / 2;
						sapphire.rect.y = ddd.MH / 2;
						sapphireGems.add(sapphire);
					}
					System.out.println("add copper metal, like a penny that we lose money to make, much like my mind when I made this game.");
					for (int x = 0; x < MathUtils.random(40, 120); x++) {// trying 5 of them.
						Copper copper = coppers.obtain();
						copper.rect.x = ddd.MW / 2;
						copper.rect.y = ddd.MH / 2;
						copperMetals.add(copper);
					}
					System.out.println("add diamond gems ping ping ping");
					for (int x = 0; x < MathUtils.random(4, 20); x++) {// trying 5 of them.
						Diamond diamond = diamonds.obtain();
						diamond.rect.x = ddd.MW / 2;
						diamond.rect.y = ddd.MH / 2;
						diamondGems.add(diamond);
					}
					System.out.println("add food because we all need it, ships? yeah, the ships too");
					for (int x = 0; x < MathUtils.random(40, 80); x++) {// trying 5 of them.
						Food food = foods.obtain();
						food.rect.x = ddd.MW / 2;
						food.rect.y = ddd.MH / 2;
						foodHealth.add(food);
					}
					System.out.println("add gold because it's so heavy we wont be able to move an inch");
					for (int x = 0; x < MathUtils.random(8, 32); x++) {// trying 5 of them.
						Gold gold = golds.obtain();
						gold.rect.x = ddd.MW / 2;
						gold.rect.y = ddd.MH / 2;
						goldMetals.add(gold);
					}
					System.out.println("add platinum because it's even heavier than gold. Who would be stupid enought to grab this stuff?? *cough* Luffy");
					for (int x = 0; x < MathUtils.random(4, 8); x++) {// trying 5 of them.
						Platinum platinum = platinums.obtain();
						platinum.rect.x = ddd.MW / 2;
						platinum.rect.y = ddd.MH / 2;
						platinumMetals.add(platinum);
					}
					System.out.println("add sliver idiot, it's silver, because it is the best of both worlds in weight and value");
					for (int x = 0; x < MathUtils.random(40, 80); x++) {// trying 5 of them.
						Silver silver = silvers.obtain();
						silver.rect.x = ddd.MW / 2;
						silver.rect.y = ddd.MH / 2;
						silverMetals.add(silver);
					}
					System.out.println(
							"another gem? What on earth man, you had type and create all these things by hand. Just move on we want to play the game already!");
					for (int x = 0; x < MathUtils.random(40, 110); x++) {// trying 5 of them.
						Topaz topaz = topazs.obtain();
						topaz.rect.x = ddd.MW / 2;
						topaz.rect.y = ddd.MH / 2;
						topazGems.add(topaz);
					}
					System.out.println("boom, boom, boom! fireworks!");
					for (int x = 0; x < 500; x++) {// trying 500 of them. this really works! xD yay ( i think) xD
						Explosion explosion = fireworks.obtain();
						explosion.rect.x = ddd.MW / 2;
						explosion.rect.y = ddd.MH / 2;
						explosions.add(explosion);
					}
					System.out.println("down into the dirtTunnel? This one is Chunky");
					for (int x = 0; x < 1300; x++) {// trying 5 of them.
						DirtChunk dirtChunk = dirtTunnel.obtain();
						dirtChunk.rect.x = ddd.MW / 2;
						dirtChunk.rect.y = ddd.MH / 2;
						dirtChunks.add(dirtChunk);
					}
					System.out.println("some dirt? behind, well not really, i mean, well yeah YEAH take the dirt");
					isLevelAdded = true;
					delayTimer = DTSpd;
				} else if (!isPlayerAdded && delayTimer <= 0) {
					System.out.println("doing the Players");
					whatIsLoading = "Loading: Constructing player";
					player = new Player(ddd.MW / 4, ddd.MH / 2);// to the left of center!
//					player2 = new Player2(ddd.MW / 4 - 20, ddd.MH / 2 - 20);// to the left of center!
//					player3 = new Player3(ddd.MW / 4 - 40, ddd.MH / 2 - 20);// to the left of center!
//					player4 = new Player4(ddd.MW / 4 - 60, ddd.MH / 2 + 20);// to the left of center!
//					player5 = new Player5(ddd.MW / 4 - 50, ddd.MH / 2 + 30);// to the left of center!
//					player6 = new Player6(ddd.MW / 4 + 20, ddd.MH / 2 - 10);// to the left of center!
					delayTimer = DTSpd;
					isPlayerAdded = true;
					evilShipLoop = true;
				} else if (!isEvilShipsAdded && delayTimer <= 0) {
					System.out.println("doing the evilShips");
					if (evilShipLoop && delayTimer <= 0) {
						whatIsLoading = "Loading: we've got other ship(s) looking for treasure!";
						System.out.println("harrr harrr harr harr harrrrrr! Gather up all the crew!");
						evilShips = new Array<EvilShip>();
						for (int x = 0; x < 100; x++) {// was 500 yeah, and now it's ONE haha (going to be fun with lots)
							evilShips.add(new EvilShip(MathUtils.random(1650, 1750), MathUtils.random(42, 814)));
							if (x + 1 == 1) {// end of loop
								isEvilShipsAdded = true;
								delayTimer = DTSpd;
							}
						}
						isEvilShipsAdded = true;
					}
				}
				if (isEvilShipsAdded && delayTimer <= 0) {
					System.out.println("now everything is done");
					isEverythingLoaded = true;
				}
				if (delayTimer > 0)
					delayTimer--;
				game.batch.end();
				// fbo.end();
			} else {
				// draw level
				if (evilShips.size <= 0)
					storeIcon.render(game, camera, delta);
				// draw the dirt
				for (int d = 0; d < dirts.size; d++) {
					if (!dirts.get(d).isDead) {
						dirts.get(d).render(game, camera, delta);
					}
				}
				// draw dirt Chunks
				for (int dc = 0; dc < dirtChunks.size; dc++) {
					if (!dirtChunks.get(dc).isDead) {
						dirtChunks.get(dc).render(game, camera, delta);
					}
				}
				// draw gems and metals
				for (int d = 0; d < rubyGems.size; d++) {
					if (!rubyGems.get(d).isDead) {
						rubyGems.get(d).render(game, camera, delta);
					}
				}
				for (int d = 0; d < amethystGems.size; d++) {
					if (!amethystGems.get(d).isDead) {
						amethystGems.get(d).render(game, camera, delta);
					}
				}
				for (int d = 0; d < sapphireGems.size; d++) {
					if (!sapphireGems.get(d).isDead) {
						sapphireGems.get(d).render(game, camera, delta);
					}
				}
				for (int d = 0; d < copperMetals.size; d++) {
					if (!copperMetals.get(d).isDead) {
						copperMetals.get(d).render(game, camera, delta);
					}
				}
				for (int d = 0; d < diamondGems.size; d++) {
					if (!diamondGems.get(d).isDead) {
						diamondGems.get(d).render(game, camera, delta);
					}
				}
				for (int d = 0; d < foodHealth.size; d++) {
					if (!foodHealth.get(d).isDead) {
						foodHealth.get(d).render(game, camera, delta);
					}
				}
				for (int d = 0; d < goldMetals.size; d++) {
					if (!goldMetals.get(d).isDead) {
						goldMetals.get(d).render(game, camera, delta);
					}
				}
				for (int d = 0; d < platinumMetals.size; d++) {
					if (!platinumMetals.get(d).isDead) {
						platinumMetals.get(d).render(game, camera, delta);
					}
				}
				for (int d = 0; d < silverMetals.size; d++) {
					if (!silverMetals.get(d).isDead) {
						silverMetals.get(d).render(game, camera, delta);
					}
				}
				for (int d = 0; d < topazGems.size; d++) {
					if (!topazGems.get(d).isDead) {
						topazGems.get(d).render(game, camera, delta);
					}
				}
				// draw ship
				shipv1.render(game, camera, delta);
				if (!engine.isBroken)
					engine.render(game, camera, delta);
				if (!drill.isBroken)
					drill.render(game, camera, delta);
				if (!gun.isBroken)
					gun.render(game, camera, delta, evilShips);
				// draw engine particles
				if (!engine.isBroken) {
					for (int fp = 0; fp < fireParticles.size; fp++) {
						if (!fireParticles.get(fp).isDead) {
							fireParticles.get(fp).render(game, camera, delta, engine);
						}
					}
				}
				// draw player
				game.batch.setColor(player.color);// set color before you draw
				// DebugRenderer.DrawDebugRectangle(player.rect, Color.RED, camera.combined);// there were a lot more of these heheeh
				// pos23 = camera.unproject(new Vector3(Gdx.input.getX(), Gdx.input.getY(), 0));
				game.batch.draw(player.getFrame(delta, camera), player.rect.x - 15, player.rect.y - 4);// this must be the offset
//				// draw player2
//				game.batch.setColor(player2.color);
//				game.batch.draw(player2.getFrame(delta, camera), player2.rect.x - 24, player2.rect.y - 4);
//				// draw player3
//				game.batch.setColor(player3.color);
//				game.batch.draw(player3.getFrame(delta, camera), player3.rect.x - 24, player3.rect.y - 4);
//				// draw player4
//				game.batch.setColor(player4.color);
//				game.batch.draw(player4.getFrame(delta, camera), player4.rect.x - 24, player4.rect.y - 4);
//				// draw player5
//				game.batch.setColor(player5.color);
//				game.batch.draw(player5.getFrame(delta, camera), player5.rect.x - 24, player5.rect.y - 4);
//				// draw player6
//				game.batch.setColor(player6.color);
//				game.batch.draw(player6.getFrame(delta, camera), player6.rect.x - 24, player6.rect.y - 4);
				// p1 text
//				game.font.getData().setScale(.4f);
//				game.font.setColor(Color.WHITE);
//				game.font.draw(game.batch, "P1", player.rect.x, player.rect.y - 1);// shadow
//				game.font.setColor(Color.ORANGE);// set color before you draw
//				game.font.draw(game.batch, "P1", player.rect.x, player.rect.y);
//				game.font.getData().setScale(1f);
//				// p2 text
//				game.font.getData().setScale(.4f);
//				game.font.setColor(Color.WHITE);
//				game.font.draw(game.batch, "P2", player2.rect.x, player2.rect.y - 1);// shadow
//				game.font.setColor(Color.BLUE);// set color before you draw
//				game.font.draw(game.batch, "P2", player2.rect.x, player2.rect.y);
//				game.font.getData().setScale(1f);
//				// p3 text
//				game.font.getData().setScale(.4f);
//				game.font.setColor(Color.WHITE);
//				game.font.draw(game.batch, "P3", player3.rect.x, player3.rect.y - 1);// shadow
//				game.font.setColor(Color.PURPLE);// set color before you draw
//				game.font.draw(game.batch, "P3", player3.rect.x, player3.rect.y);
//				game.font.getData().setScale(1f);
//				// p4 text
//				game.font.getData().setScale(.4f);
//				game.font.setColor(Color.WHITE);
//				game.font.draw(game.batch, "P4", player4.rect.x, player4.rect.y - 1);// shadow
//				game.font.setColor(Color.GREEN);// set color before you draw
//				game.font.draw(game.batch, "P4", player4.rect.x, player4.rect.y);
//				game.font.getData().setScale(1f);
//				// p5 text
//				game.font.getData().setScale(.4f);
//				game.font.setColor(Color.WHITE);
//				game.font.draw(game.batch, "P5", player5.rect.x, player5.rect.y - 1);// shadow
//				game.font.setColor(Color.RED);// set color before you draw
//				game.font.draw(game.batch, "P5", player5.rect.x, player5.rect.y);
//				game.font.getData().setScale(1f);
//				// p6 text
//				game.font.getData().setScale(.4f);
//				game.font.setColor(Color.WHITE);
//				game.font.draw(game.batch, "P6", player6.rect.x, player6.rect.y - 1);// shadow
//				game.font.setColor(Color.TEAL);// set color before you draw
//				game.font.draw(game.batch, "P6", player6.rect.x, player6.rect.y);
				game.font.getData().setScale(1f);
				// all player healthbars
				if (!shipv1.isBroken) {
					game.batch.setColor(shipv1.healthBar.color);
					shipv1.healthBar.render(game, camera, delta, shipv1.rect.x + 10f, shipv1.rect.y - 50f, Global.shipv1Health, Global.shipv1HealthMax);
				}
				if (!engine.isBroken) {
					game.batch.setColor(engine.healthBar.color);
					engine.healthBar.render(game, camera, delta, engine.rect.x + 10f, engine.rect.y - 50f, Global.engineHealth, Global.engineHealthMax);
				}
				if (!drill.isBroken) {
					game.batch.setColor(drill.healthBar.color);
					drill.healthBar.render(game, camera, delta, drill.rect.x + 10f, drill.rect.y - 50f, Global.drillHealth, Global.drillHealthMax);
				}
				if (!gun.isBroken) {
					game.batch.setColor(gun.healthBar.color);
					gun.healthBar.render(game, camera, delta, gun.rect.x + 10f, gun.rect.y - 50f, Global.gunHealth, Global.gunHealthMax);
				}
				// draw the evilShips healthbars and all
				for (int d = 0; d < evilShips.size; d++) {
					if (!evilShips.get(d).isDead) {
						// render the enemy ships (ships first)
						game.batch.setColor(evilShips.get(d).color);
						// DebugRenderer.DrawDebugRectangle(evilShips.get(d).rect, Color.YELLOW, camera.combined);
						evilShips.get(d).render(game, camera, delta, amethystGems, copperMetals, diamondGems, foodHealth, goldMetals, platinumMetals, rubyGems,
								sapphireGems, silverMetals, topazGems);
						// evil ship healthbar
						game.batch.setColor(evilShips.get(d).healthBar.color);
						evilShips.get(d).healthBar.render(game, camera, delta, evilShips.get(d).rect.x + 10f, evilShips.get(d).rect.y - 50f, evilShips.get(d).health,
								evilShips.get(d).healthMax);
						// evil ship enemy engine healthbar
						game.batch.setColor(evilShips.get(d).enemyEngine.healthBar.color);
						evilShips.get(d).enemyEngine.healthBar.render(game, camera, delta, evilShips.get(d).enemyEngine.rect.x + 10f,
								evilShips.get(d).enemyEngine.rect.y - 50f, evilShips.get(d).enemyEngine.health, evilShips.get(d).enemyEngine.healthMax);
						// render the enemy engine
						evilShips.get(d).enemyEngine.render(game, camera, delta);
						// evil ship enemy gun healthbar
						game.batch.setColor(evilShips.get(d).enemyGun.healthBar.color);
						evilShips.get(d).enemyGun.healthBar.render(game, camera, delta, evilShips.get(d).enemyGun.rect.x + 10f,
								evilShips.get(d).enemyGun.rect.y - 50f, evilShips.get(d).enemyGun.health, evilShips.get(d).enemyGun.healthMax);
						// render the enemy gun
						evilShips.get(d).enemyGun.render(game, camera, delta, shipv1, engine, gun, drill);
						// render the enemy ship's enemy gun's balls, and those ball's explosions.
						for (int eg = 0; eg < evilShips.get(d).enemyGun.balls.size; eg++) {
							if (!evilShips.get(d).enemyGun.balls.get(eg).isDead) {
								game.batch.setColor(evilShips.get(d).enemyGun.balls.get(eg).color);
								game.batch.draw(evilShips.get(d).enemyGun.balls.get(eg).getFrame(camera, delta), evilShips.get(d).enemyGun.balls.get(eg).rect.x,
										evilShips.get(d).enemyGun.balls.get(eg).rect.y);
							} else if (!evilShips.get(d).enemyGun.balls.get(eg).explosion.isDead) {
								game.batch.setColor(evilShips.get(d).enemyGun.balls.get(eg).explosion.getColor());
								game.batch.draw(evilShips.get(d).enemyGun.balls.get(eg).explosion.getFrame(camera, delta),
										evilShips.get(d).enemyGun.balls.get(eg).explosion.rect.x, evilShips.get(d).enemyGun.balls.get(eg).explosion.rect.y);
							}
						}
					}
				}

				// player.powerBar.render(game, camera, delta, player.rect, player.powerBarNumber, player.powerBarMax);
				// draw player 1 balls
				for (int d = 0; d < player.balls.size; d++) {
					if (!player.balls.get(d).isDead) {
						// game.font.draw(game.batch, "" + player.balls.size, player.rect.x, player.rect.y);
						game.batch.setColor(player.balls.get(d).color);
						game.batch.draw(player.balls.get(d).getFrame(camera, delta), player.balls.get(d).rect.x, player.balls.get(d).rect.y);
					} else if (!player.balls.get(d).explosion.isDead) {
						game.batch.setColor(player.balls.get(d).explosion.getColor());
						game.batch.draw(player.balls.get(d).explosion.getFrame(camera, delta), player.balls.get(d).explosion.rect.x,
								player.balls.get(d).explosion.rect.y);
					}
				}
				// draw explosions?
				for (int d = 0; d < explosions.size; d++) {
					if (!explosions.get(d).isDead) {
						explosions.get(d).render(game, camera, delta);
					}
				}
//				// player 2 healthbars
//				game.batch.setColor(player2.healthBar.color);
//				player2.healthBar.render(game, camera, delta, player2.rect, Player2.health, Player2.healthMax);
//				player2.powerBar.render(game, camera, delta, player2.rect, player2.powerBarNumber, player2.powerBarMax);
//				// player 3 healthbars
//				game.batch.setColor(player3.healthBar.color);
//				player3.healthBar.render(game, camera, delta, player3.rect, Player3.health, Player3.healthMax);
//				player3.powerBar.render(game, camera, delta, player3.rect, player3.powerBarNumber, player3.powerBarMax);
//				// player 4 healthbars
//				game.batch.setColor(player4.healthBar.color);
//				player4.healthBar.render(game, camera, delta, player4.rect, Player4.health, Player4.healthMax);
//				player4.powerBar.render(game, camera, delta, player4.rect, player4.powerBarNumber, player4.powerBarMax);
//				// player 5 healthbars
//				game.batch.setColor(player5.healthBar.color);
//				player5.healthBar.render(game, camera, delta, player5.rect, Player5.health, Player5.healthMax);
//				player5.powerBar.render(game, camera, delta, player5.rect, player5.powerBarNumber, player5.powerBarMax);
//				// player 6 healthbars
//				game.batch.setColor(player6.healthBar.color);
//				player6.healthBar.render(game, camera, delta, player6.rect, Player6.health, Player6.healthMax);
//				player6.powerBar.render(game, camera, delta, player6.rect, player6.powerBarNumber, player6.powerBarMax);
				// draw gun balls
				for (int d = 0; d < gun.balls.size; d++) {
					if (!gun.balls.get(d).isDead) {
						// game.font.draw(game.batch, "" + player.balls.size, player.rect.x, player.rect.y);
						game.batch.setColor(gun.balls.get(d).color);
						game.batch.draw(gun.balls.get(d).getFrame(camera, delta), gun.balls.get(d).rect.x, gun.balls.get(d).rect.y);
					} else if (!gun.balls.get(d).explosion.isDead) {
						game.batch.setColor(gun.balls.get(d).explosion.getColor());
						game.batch.draw(gun.balls.get(d).explosion.getFrame(camera, delta), gun.balls.get(d).explosion.rect.x, gun.balls.get(d).explosion.rect.y);
					}
				}
				// icons:
				game.font.setColor(Color.WHITE);// set color before you draw
				game.batch.setColor(Color.WHITE);// reset batch color
				// draw gem/metal hud
				game.font.getData().setScale(.7f);
				amethystHUD.render(game, camera, delta, shipv1.rect.x, shipv1.rect.y - 25f);
				game.font.setColor(Color.PURPLE);
				game.font.draw(game.batch, "" + Global.p1AmethystStockpile, shipv1.rect.x + 34f, shipv1.rect.y - 14f);// shadow
				game.font.setColor(Color.WHITE);
				game.font.draw(game.batch, "" + Global.p1AmethystStockpile, shipv1.rect.x + 33f, shipv1.rect.y - 13f);
				topazHUD.render(game, camera, delta, shipv1.rect.x, shipv1.rect.y - 45f);
				game.font.setColor(Color.GOLD);
				game.font.draw(game.batch, "" + Global.p1TopazStockpile, shipv1.rect.x + 34f, shipv1.rect.y - 34f);// shadow
				game.font.setColor(Color.WHITE);
				game.font.draw(game.batch, "" + Global.p1TopazStockpile, shipv1.rect.x + 33f, shipv1.rect.y - 33f);
				sapphireHUD.render(game, camera, delta, shipv1.rect.x, shipv1.rect.y - 65f);
				game.font.setColor(Color.BLUE);
				game.font.draw(game.batch, "" + Global.p1SapphireStockpile, shipv1.rect.x + 34f, shipv1.rect.y - 54f);// shadow
				game.font.setColor(Color.WHITE);
				game.font.draw(game.batch, "" + Global.p1SapphireStockpile, shipv1.rect.x + 33f, shipv1.rect.y - 53f);
				rubyHUD.render(game, camera, delta, shipv1.rect.x, shipv1.rect.y - 85f);
				game.font.setColor(Color.RED);
				game.font.draw(game.batch, "" + Global.p1RubyStockpile, shipv1.rect.x + 34f, shipv1.rect.y - 74f);// shadow
				game.font.setColor(Color.WHITE);
				game.font.draw(game.batch, "" + Global.p1RubyStockpile, shipv1.rect.x + 33f, shipv1.rect.y - 73f);
				diamondHUD.render(game, camera, delta, shipv1.rect.x, shipv1.rect.y - 105f);
				game.font.setColor(Color.CYAN);
				game.font.draw(game.batch, "" + Global.p1DiamondStockpile, shipv1.rect.x + 34f, shipv1.rect.y - 94f);// shadow
				game.font.setColor(Color.WHITE);
				game.font.draw(game.batch, "" + Global.p1DiamondStockpile, shipv1.rect.x + 33f, shipv1.rect.y - 93f);
				copperHUD.render(game, camera, delta, shipv1.rect.x + 60f, shipv1.rect.y - 30f);
				game.font.setColor(Color.SALMON);
				game.font.draw(game.batch, "" + Global.p1CopperStockpile, shipv1.rect.x + 101f, shipv1.rect.y - 16f);// shadow
				game.font.setColor(Color.WHITE);
				game.font.draw(game.batch, "" + Global.p1CopperStockpile, shipv1.rect.x + 100f, shipv1.rect.y - 15f);
				silverHUD.render(game, camera, delta, shipv1.rect.x + 60f, shipv1.rect.y - 55f);
				game.font.setColor(Color.GRAY);
				game.font.draw(game.batch, "" + Global.p1SilverStockpile, shipv1.rect.x + 101f, shipv1.rect.y - 41f);// shadow
				game.font.setColor(Color.WHITE);
				game.font.draw(game.batch, "" + Global.p1SilverStockpile, shipv1.rect.x + 100f, shipv1.rect.y - 40f);
				goldHUD.render(game, camera, delta, shipv1.rect.x + 60f, shipv1.rect.y - 80f);
				game.font.setColor(Color.YELLOW);
				game.font.draw(game.batch, "" + Global.p1GoldStockpile, shipv1.rect.x + 101f, shipv1.rect.y - 66f);// shadow
				game.font.setColor(Color.WHITE);
				game.font.draw(game.batch, "" + Global.p1GoldStockpile, shipv1.rect.x + 100f, shipv1.rect.y - 65f);
				platinumHUD.render(game, camera, delta, shipv1.rect.x + 60f, shipv1.rect.y - 105f);
				game.font.setColor(Color.WHITE);
				game.font.draw(game.batch, "" + Global.p1PlatinumStockpile, shipv1.rect.x + 101f, shipv1.rect.y - 91f);// shadow
				game.font.setColor(Color.WHITE);
				game.font.draw(game.batch, "" + Global.p1PlatinumStockpile, shipv1.rect.x + 100f, shipv1.rect.y - 90f);
				// draw HUD
				game.font.getData().setScale(1f);
				game.font.setColor(Color.WHITE);
				game.font.draw(game.batch, player.p1displayScore, 12, ddd.MH - 12);// shadow
				game.font.setColor(Color.ORANGE);// set color before you draw
				game.font.draw(game.batch, player.p1displayScore, 13, ddd.MH - 11);
//				game.font.setColor(Color.WHITE);
//				game.font.draw(game.batch, "P2: " + Player2.score, 12 + 150, ddd.MH - 12);// shadow
//				game.font.setColor(Color.BLUE);// set color before you draw
//				game.font.draw(game.batch, "P2: " + Player2.score, 13 + 150, ddd.MH - 11);
//				game.font.setColor(Color.WHITE);
//				game.font.draw(game.batch, "P3: " + Player3.score, 12 + 160 * 2, ddd.MH - 12);// shadow
//				game.font.setColor(Color.PURPLE);// set color before you draw
//				game.font.draw(game.batch, "P3: " + Player3.score, 13 + 160 * 2, ddd.MH - 11);
//				game.font.setColor(Color.WHITE);
//				game.font.draw(game.batch, "P4: " + Player4.score, 12 + 160 * 3, ddd.MH - 12);// shadow
//				game.font.setColor(Color.GREEN);// set color before you draw
//				game.font.draw(game.batch, "P4: " + Player4.score, 13 + 160 * 3, ddd.MH - 11);
//				game.font.setColor(Color.WHITE);
//				game.font.draw(game.batch, "P5: " + Player5.score, 12 + 160 * 4, ddd.MH - 12);// shadow
//				game.font.setColor(Color.RED);// set color before you draw
//				game.font.draw(game.batch, "P5: " + Player5.score, 13 + 160 * 4, ddd.MH - 11);
//				game.font.setColor(Color.WHITE);
//				game.font.draw(game.batch, "P6: " + Player6.score, 12 + 160 * 5, ddd.MH - 12);// shadow
//				game.font.setColor(Color.TEAL);// set color before you draw
//				game.font.draw(game.batch, "P6: " + Player6.score, 13 + 160 * 5, ddd.MH - 11);

				game.font.setColor(Color.BROWN);
				game.font.draw(game.batch, "Digging! Can't get store until: " + ddd.TruckArriveTimer, Gdx.graphics.getWidth() / 2 - 300, ddd.MH - 12);// shadow
				game.font.setColor(Color.ORANGE);// set color before you draw
				game.font.draw(game.batch, "Digging! Can't get store until: " + ddd.TruckArriveTimer, Gdx.graphics.getWidth() / 2 - 300, ddd.MH - 11);

				game.font.setColor(Color.BROWN);
				game.font.draw(game.batch, "Dig Down Dude!", ddd.MW - 240, ddd.MH - 16);// shadows
				game.font.setColor(Color.WHITE);
				game.font.draw(game.batch, "Dig Down Dude!", ddd.MW - 239, ddd.MH - 15);
				game.font.setColor(Color.BLACK);
				// UI
				game.font.getData().setScale(1f);
				// debug info:
				// game.font.setColor(Color.BLACK);
				// game.font.draw(game.batch, "FPS: " + Gdx.graphics.getFramesPerSecond(), ddd.MW - 156, 36);// shadow
				// game.font.setColor(Color.WHITE);
				// game.font.draw(game.batch, "FPS: " + Gdx.graphics.getFramesPerSecond(), ddd.MW - 157, 37);
				// game.font.setColor(Color.BLACK);
//				game.font.draw(game.batch, "JavaMem: " + Gdx.app.getJavaHeap(), camera.position.x + 320, camera.position.y - 297);// SL
//				game.font.setColor(Color.WHITE);
//				game.font.draw(game.batch, "JavaMem: " + Gdx.app.getJavaHeap(), camera.position.x + 328, camera.position.y - 295);
//				game.font.setColor(Color.BLACK);
//				game.font.draw(game.batch, "NativMem: " + Gdx.app.getNativeHeap(), camera.position.x + 320, camera.position.y - 267);// SL
//				game.font.setColor(Color.WHITE);
//				game.font.draw(game.batch, "NativMem: " + Gdx.app.getNativeHeap(), camera.position.x + 328, camera.position.y - 265);
//				game.font.draw(game.batch, "NativMem: " + Gdx.app.getNativeHeap(), camera.position.x + 328, camera.position.y - 265);
//				game.font.setColor(Color.BLACK);
				// end debug info
				// timer till extraction
				/*
				 * game.font.setColor(Color.CYAN); game.font.draw(game.batch, "Time till stop: " + ddd.ExtractionTimer, camera.position.x - 300,
				 * camera.position.y + 340); game.font.setColor(Color.WHITE); game.font.draw(game.batch, "Time till Extraction: " + ddd.ExtractionTimer,
				 * camera.position.x - 301, camera.position.y + 342);
				 */
				// separate render loop for shadows.
				game.batch.end();

				// debug drawing section: this IS important. I'm glad this is starting to make sense. It's handled on a different batch render call.
				// DrawDebugLine(posV2, mousePosV2, 2, Color.CORAL, camera.combined);
				// if (balls.size > 0)
				// u.DebugRenderer.DrawDebugRectangle(balls.get(0).rect, Color.BLUE, camera.combined);
				// if (plants.size > 1)
				// u.DebugRenderer.DrawDebugRectangle(bench.rect, Color.YELLOW, camera.combined);
				// u.DebugRenderer.DrawDebugRectangle(giantFoot.rect, Color.RED, camera.combined);
//				for (int i = 0; i < wallTiles.size; i++) {
//					// System.out.println("rect?: " + wallTiles.get(i).getRect());
//					u.DebugRenderer.DrawDebugRectangle(wallTiles.get(i).getRect(), Color.RED, camera.combined);
//				}
				// music check, the show box wasn't working
				if (!Global.IsMusicPaused)
					levelMusic.play();
				// collisions
				checkEvilShipCollisions(evilShips, shipv1);
				checkAmethystCollisions(amethystGems);
				checkCopperCollisions(copperMetals);
				checkDiamondCollisions(diamondGems);
				checkFoodCollisions(foodHealth);
				checkGoldCollisions(goldMetals);
				checkPlatinumCollisions(platinumMetals);
				checkRubyCollisions(rubyGems);
				checkSapphireCollisions(sapphireGems);
				checkSilverCollisions(silverMetals);
				checkTopazCollisions(topazGems);
				checkPlayerShipCollisions();
				// ui collisions

				if (Gdx.input.isKeyJustPressed(Input.Keys.Q)) {// reset map or screen
					System.out.println("\r\r\r\r\r\r\r");
					dispose();// hee hee i figured out how to reset the level. xD (dispose of the level and reload it. ;-) )
					Global.resetPlayersStats();
					onlyGoThroughLevelEndOnce = false;
					// camera.position.y = 0;
					// camera.position.x = 0;
					// camera.update();
					game.setScreen(new LevelThree(game));
				}
				if (player.dead) {// if you die
					System.out.println("you are a terrible player. Feel insulted?");
					camera.position.y = 0;
					camera.position.x = 0;
					camera.update();
					dispose();
					game.setScreen(new LoseScreen(game, "You died!? Don't run into their shiPs!"));
				}
				if (Global.shipv1Health <= 0) {// if your ship dies
					System.out.println("ppffttt you let your shiP die. looking at those rubies huh?");
					camera.position.y = 0;
					camera.position.x = 0;
					camera.update();
					dispose();
					game.setScreen(new LoseScreen(game, "you let your shiP be destroyed. This is one of the ways to lose."));
				}

				if (Player.health <= 0 && isDeadTimer > 0) {
					isDeadTimer--;
					if (!Global.SetVolumeToZero && !onetime) {
						onetime = true;
						death.play();
					}
					player.isDying = true;
				}
				if (ddd.TruckArriveTimer <= 0 && storeIcon.canHit && !player.isDying && Player.health >= 0 && !onlyGoThroughLevelEndOnce) {
					onlyGoThroughLevelEndOnce = true;

					Player.score += amethystGems.size;
					Player.score += rubyGems.size;
					Player.score += topazGems.size;
					Player.score += sapphireGems.size;
					Player.score += diamondGems.size * 2;
					Player.score *= copperMetals.size * 2;
					Player.score *= silverMetals.size * 4;
					Player.score *= goldMetals.size * 6;
					Player.score *= platinumMetals.size * 8;
					player.updatep1ScoreDisplay();
					// Player2.score *= kittens.size;
					// Player3.score *= kittens.size;
					Global.WhatLevel = 1;
					ddd.GameSettings.putInteger("whatLevel", 1);
					ddd.GameSettings.flush();
					if (!Global.SetVolumeToZero && !playSoundOnce) {
						playSoundOnce = true;
						reverseSlide.play();
					} // TODO: remove this comment when ready to win the game (but i'd rather kill all the ships to win. We'll see if i have time)
					camera.position.y = 0;
					camera.position.x = 0;
					camera.update();
					dispose();
					game.setScreen(new WinScreen(game));
				}
				if (ddd.TruckArriveTimer > 0)
					ddd.TruckArriveTimer--;
				update(delta);// going to set camera position to last. :-)
			}

		}

	}// end of render (or update)

	private void checkPlayerShipCollisions() {
		if (shipv1.rect.overlaps(storeIcon.rect) && evilShips.size <= 0) {
			storeIcon.canHit = true;// activate the store!
		}
	}

	private void checkTopazCollisions(Array<Topaz> topazGems) {
		for (Iterator<Topaz> iter = topazGems.iterator(); iter.hasNext();) {
			Topaz d = iter.next();
			// collding with a single object: (Shipv1)
			if (d.rect.overlaps(shipv1.rect)) {
				if (!Global.SetVolumeToZero)
					player.playRandomKickSound(6);// TODO: add a sound of picking up gems
				Player.score += 3;// testing score
				Global.p1TopazStockpile++;
				d.isDead = true;
				topazGems.removeValue(d, true);// TODO: make sure this doesn't need the pooling to be freed too. I can't find it atm.
			}
			// collding with a group: (EnemyShips!)
			for (Iterator<EvilShip> iter2 = evilShips.iterator(); iter2.hasNext();) {
				EvilShip es = iter2.next();
				if (es.rect.overlaps(d.rect)) {
					if (!Global.SetVolumeToZero)
						player.playRandomKickSound(6);// TODO: add a sound of picking up gems
					Player.score -= 3;// testing score
					es.topazStockpile++;
					d.isDead = true;
					topazGems.removeValue(d, true);// TODO: make sure this doesn't need the pooling to be freed too. I can't find it atm.
				}
			}
		}

	}

	private void checkSilverCollisions(Array<Silver> silverMetals) {
		for (Iterator<Silver> iter = silverMetals.iterator(); iter.hasNext();) {
			Silver d = iter.next();
			// collding with a single object: (Shipv1)
			if (d.rect.overlaps(shipv1.rect)) {
				if (!Global.SetVolumeToZero)
					player.playRandomKickSound(6);// TODO: add a sound of picking up gems
				Player.score += 8;// testing score
				Global.p1SilverStockpile++;
				d.isDead = true;
				silverMetals.removeValue(d, true);// TODO: make sure this doesn't need the pooling to be freed too. I can't find it atm.
			}
			// collding with a group: (EnemyShips!)
			for (Iterator<EvilShip> iter2 = evilShips.iterator(); iter2.hasNext();) {
				EvilShip es = iter2.next();
				if (es.rect.overlaps(d.rect)) {
					if (!Global.SetVolumeToZero)
						player.playRandomKickSound(6);// TODO: add a sound of picking up gems
					Player.score -= 8;// testing score
					es.silverStockpile++;
					d.isDead = true;
					silverMetals.removeValue(d, true);// TODO: make sure this doesn't need the pooling to be freed too. I can't find it atm.
				}
			}
		}

	}

	private void checkSapphireCollisions(Array<Sapphire> sapphireGems) {
		for (Iterator<Sapphire> iter = sapphireGems.iterator(); iter.hasNext();) {
			Sapphire d = iter.next();
			// collding with a single object: (Shipv1)
			if (d.rect.overlaps(shipv1.rect)) {
				if (!Global.SetVolumeToZero)
					player.playRandomKickSound(6);// TODO: add a sound of picking up gems
				Player.score += 6;// testing score
				Global.p1SapphireStockpile++;
				d.isDead = true;
				sapphireGems.removeValue(d, true);// TODO: make sure this doesn't need the pooling to be freed too. I can't find it atm.
			}
			// collding with a group: (EnemyShips!)
			for (Iterator<EvilShip> iter2 = evilShips.iterator(); iter2.hasNext();) {
				EvilShip es = iter2.next();
				if (es.rect.overlaps(d.rect)) {
					if (!Global.SetVolumeToZero)
						player.playRandomKickSound(6);// TODO: add a sound of picking up gems
					Player.score -= 6;// testing score
					es.sapphireStockpile++;
					d.isDead = true;
					sapphireGems.removeValue(d, true);// TODO: make sure this doesn't need the pooling to be freed too. I can't find it atm.
				}
			}
		}

	}

	private void checkRubyCollisions(Array<Ruby> rubyGems) {
		for (Iterator<Ruby> iter = rubyGems.iterator(); iter.hasNext();) {
			Ruby d = iter.next();
			// collding with a single object: (Shipv1)
			if (d.rect.overlaps(shipv1.rect)) {
				if (!Global.SetVolumeToZero)
					player.playRandomKickSound(6);// TODO: add a sound of picking up gems
				Player.score += 7;// testing score
				Global.p1RubyStockpile++;
				d.isDead = true;
				rubyGems.removeValue(d, true);// TODO: make sure this doesn't need the pooling to be freed too. I can't find it atm.
			}
			// collding with a group: (EnemyShips!)
			for (Iterator<EvilShip> iter2 = evilShips.iterator(); iter2.hasNext();) {
				EvilShip es = iter2.next();
				if (es.rect.overlaps(d.rect)) {
					if (!Global.SetVolumeToZero)
						player.playRandomKickSound(6);// TODO: add a sound of picking up gems
					Player.score -= 7;// testing score
					es.rubyStockpile++;
					d.isDead = true;
					rubyGems.removeValue(d, true);// TODO: make sure this doesn't need the pooling to be freed too. I can't find it atm.
				}
			}
		}

	}

	private void checkPlatinumCollisions(Array<Platinum> platinumMetals) {
		for (Iterator<Platinum> iter = platinumMetals.iterator(); iter.hasNext();) {
			Platinum d = iter.next();
			// collding with a single object: (Shipv1)
			if (d.rect.overlaps(shipv1.rect)) {
				if (!Global.SetVolumeToZero)
					player.playRandomKickSound(6);// TODO: add a sound of picking up gems
				Player.score += 25;// testing score
				Global.p1PlatinumStockpile++;
				d.isDead = true;
				platinumMetals.removeValue(d, true);// TODO: make sure this doesn't need the pooling to be freed too. I can't find it atm.
			}
			// collding with a group: (EnemyShips!)
			for (Iterator<EvilShip> iter2 = evilShips.iterator(); iter2.hasNext();) {
				EvilShip es = iter2.next();
				if (es.rect.overlaps(d.rect)) {
					if (!Global.SetVolumeToZero)
						player.playRandomKickSound(6);// TODO: add a sound of picking up gems
					Player.score -= 25;// testing score
					es.platinumStockpile++;
					d.isDead = true;
					platinumMetals.removeValue(d, true);// TODO: make sure this doesn't need the pooling to be freed too. I can't find it atm.
				}
			}
		}

	}

	private void checkGoldCollisions(Array<Gold> goldMetals) {
		for (Iterator<Gold> iter = goldMetals.iterator(); iter.hasNext();) {
			Gold d = iter.next();
			// collding with a single object: (Shipv1)
			if (d.rect.overlaps(shipv1.rect)) {
				if (!Global.SetVolumeToZero)
					player.playRandomKickSound(6);// TODO: add a sound of picking up gems
				Player.score += 15;// testing score
				Global.p1GoldStockpile++;
				d.isDead = true;
				goldMetals.removeValue(d, true);// TODO: make sure this doesn't need the pooling to be freed too. I can't find it atm.
			}
			// collding with a group: (EnemyShips!)
			for (Iterator<EvilShip> iter2 = evilShips.iterator(); iter2.hasNext();) {
				EvilShip es = iter2.next();
				if (es.rect.overlaps(d.rect)) {
					if (!Global.SetVolumeToZero)
						player.playRandomKickSound(6);// TODO: add a sound of picking up gems
					Player.score -= 15;// testing score
					es.goldStockpile++;
					d.isDead = true;
					goldMetals.removeValue(d, true);// TODO: make sure this doesn't need the pooling to be freed too. I can't find it atm.
				}
			}
		}

	}

	private void checkFoodCollisions(Array<Food> foodHealth) {
		for (Iterator<Food> iter = foodHealth.iterator(); iter.hasNext();) {
			Food d = iter.next();
			// collding with a single object: (Shipv1)
			if (d.rect.overlaps(shipv1.rect)) {
				if (!Global.SetVolumeToZero)
					player.playRandomKickSound(6);// TODO: add a sound of healing
				Player.score += 1;// testing score
				if (Player.health <= Player.healthMax)
					Player.health += 30;
				else if (Player.health >= Player.healthMax)
					Player.health = Player.healthMax;
				d.isDead = true;
				foodHealth.removeValue(d, true);// TODO: make sure this doesn't need the pooling to be freed too. I can't find it atm.
			}
			// collding with a group: (EnemyShips!)
			for (Iterator<EvilShip> iter2 = evilShips.iterator(); iter2.hasNext();) {
				EvilShip es = iter2.next();
				if (es.rect.overlaps(d.rect)) {
					if (!Global.SetVolumeToZero)
						player.playRandomKickSound(6);// TODO: add a sound of healing
					Player.score -= 1;// testing score
					if (es.health <= es.healthMax)
						es.health += 20;
					else if (es.health >= es.healthMax)
						es.health = es.healthMax;
					d.isDead = true;
					foodHealth.removeValue(d, true);// TODO: make sure this doesn't need the pooling to be freed too. I can't find it atm.
				}
			}
		}

	}

	private void checkDiamondCollisions(Array<Diamond> diamondGems) {
		for (Iterator<Diamond> iter = diamondGems.iterator(); iter.hasNext();) {
			Diamond d = iter.next();
			// collding with a single object: (Shipv1)
			if (d.rect.overlaps(shipv1.rect)) {
				if (!Global.SetVolumeToZero)
					player.playRandomKickSound(6);// TODO: add a sound of picking up gems
				Player.score += 13;// testing score
				Global.p1DiamondStockpile++;
				d.isDead = true;
				diamondGems.removeValue(d, true);// TODO: make sure this doesn't need the pooling to be freed too. I can't find it atm.
			}
			// collding with a group: (EnemyShips!)
			for (Iterator<EvilShip> iter2 = evilShips.iterator(); iter2.hasNext();) {
				EvilShip es = iter2.next();
				if (es.rect.overlaps(d.rect)) {
					if (!Global.SetVolumeToZero)
						player.playRandomKickSound(6);// TODO: add a sound of picking up gems
					Player.score -= 13;// testing score
					es.diamondStockpile++;
					d.isDead = true;
					diamondGems.removeValue(d, true);// TODO: make sure this doesn't need the pooling to be freed too. I can't find it atm.
				}
			}
		}

	}

	private void checkCopperCollisions(Array<Copper> copperMetals) {
		for (Iterator<Copper> iter = copperMetals.iterator(); iter.hasNext();) {
			Copper d = iter.next();
			// collding with a single object: (Shipv1)
			if (d.rect.overlaps(shipv1.rect)) {
				if (!Global.SetVolumeToZero)
					player.playRandomKickSound(6);// TODO: add a sound of picking up gems
				Player.score += 1;// testing score
				Global.p1CopperStockpile++;
				d.isDead = true;
				copperMetals.removeValue(d, true);// TODO: make sure this doesn't need the pooling to be freed too. I can't find it atm.
			}
			// collding with a group: (EnemyShips!)
			for (Iterator<EvilShip> iter2 = evilShips.iterator(); iter2.hasNext();) {
				EvilShip es = iter2.next();
				if (es.rect.overlaps(d.rect)) {
					if (!Global.SetVolumeToZero)
						player.playRandomKickSound(6);// TODO: add a sound of picking up gems
					Player.score--;// testing score
					es.copperStockpile++;
					d.isDead = true;
					copperMetals.removeValue(d, true);// TODO: make sure this doesn't need the pooling to be freed too. I can't find it atm.
				}
			}
		}

	}

	private void checkAmethystCollisions(Array<Amethyst> amethystGems) {
		for (Iterator<Amethyst> iter = amethystGems.iterator(); iter.hasNext();) {
			Amethyst d = iter.next();
			// collding with a single object: (Shipv1)
			if (d.rect.overlaps(shipv1.rect)) {
				if (!Global.SetVolumeToZero)
					player.playRandomKickSound(6);// TODO: add a sound of picking up gems
				Player.score += 1;// testing score
				Global.p1AmethystStockpile++;
				d.isDead = true;
				amethystGems.removeValue(d, true);// TODO: make sure this doesn't need the pooling to be freed too. I can't find it atm.
			}
			// collding with a group: (EnemyShips!)
			for (Iterator<EvilShip> iter2 = evilShips.iterator(); iter2.hasNext();) {
				EvilShip es = iter2.next();
				if (es.rect.overlaps(d.rect)) {
					if (!Global.SetVolumeToZero)
						player.playRandomKickSound(6);// TODO: add a sound of picking up gems
					Player.score--;// testing score
					es.amethystStockpile++;
					d.isDead = true;
					amethystGems.removeValue(d, true);// TODO: make sure this doesn't need the pooling to be freed too. I can't find it atm.
				}
			}
		}

	}

//	private void setCorrectScreenCoords(int x, int y, int z) {
//		tempCoords.x = x;
//		tempCoords.y = y;
//		tempCoords.z = z;
//		mousePos = camera.unproject(tempCoords);
//	}

	public void checkEvilShipCollisions(Array<EvilShip> evilShips, Shipv1 shipv1) {
		for (Iterator<EvilShip> iter = evilShips.iterator(); iter.hasNext();) {
			EvilShip d = iter.next();
			if (!d.isDead) {
				// collding with a single object: (Player)
				if (Player.health > 0 && d.rect.overlaps(player.rect) && d.canHit && !d.isDying) {
					d.canHit = false;
					Player.health -= 50;
					if (!Global.SetVolumeToZero)
						player.playRandomHurtSound(6);
					Player.score -= 2;// testing score (remove this!)
					if (!player.isDying && Player.health <= 0) {
						Player.score -= 100;
						if (!Global.SetVolumeToZero)
							click.play();
						player.isDying = true;
					}
				} else
					d.canHit = true;
				// enemy ship ball collisions
				for (Iterator<Ball> iter2 = d.enemyGun.balls.iterator(); iter2.hasNext();) {
					Ball b = iter2.next();
					// colliding with a single object: (player 1's shipv1)
					if (Global.shipv1Health > 0 && b.rect.overlaps(shipv1.rect) && b.canHit && !b.isDead) {
						b.canHit = false;
						b.ballLife = 0;
						Global.shipv1Health -= getDamageBasedOnHowManyShipsThereAre(evilShips);
						if (!Global.SetVolumeToZero)// TODO: add a sound of it actually being hit (clank or what not)
							player.playRandomHurtSound(6);
						Player.score--;
						if (!shipv1.isBroken && Global.shipv1Health <= 0) {
							Player.score -= 100;
							if (!Global.SetVolumeToZero)
								click.play();// TODO: why is this a click? isn't your ship blowing up?
							shipv1.isBroken = true;
						}
					}
					// colliding with a single object: (player 1's gun)
					if (Global.gunHealth > 0 && b.rect.overlaps(gun.rect) && b.canHit && !b.isDead) {
						b.canHit = false;
						b.ballLife = 0;
						Global.gunHealth -= getDamageBasedOnHowManyShipsThereAre(evilShips);
						if (!Global.SetVolumeToZero)// TODO: add a sound of it actually being hit (clank or what not)
							player.playRandomHurtSound(6);
						Player.score--;
						if (!gun.isBroken && Global.gunHealth <= 0) {
							Player.score -= 100;
							if (!Global.SetVolumeToZero)
								click.play();// TODO: why is this a click? isn't your ship blowing up?
							gun.isBroken = true;
						}
					}
					// colliding with a single object: (player 1's engine)
					if (Global.engineHealth > 0 && b.rect.overlaps(engine.rect) && b.canHit && !b.isDead) {
						b.canHit = false;
						b.ballLife = 0;
						Global.engineHealth -= getDamageBasedOnHowManyShipsThereAre(evilShips);
						if (!Global.SetVolumeToZero)// TODO: add a sound of it actually being hit (clank or what not)
							player.playRandomHurtSound(6);
						Player.score--;
						if (!engine.isBroken && Global.engineHealth <= 0) {
							Player.score -= 100;
							if (!Global.SetVolumeToZero)
								click.play();// TODO: why is this a click? isn't your ship blowing up?
							engine.isBroken = true;
							player.hasEngines = false;
						}
					}
					// colliding with a single object: (player 1's drill)
					if (Global.drillHealth > 0 && b.rect.overlaps(drill.rect) && b.canHit && !b.isDead) {
						b.canHit = false;
						b.ballLife = 0;
						Global.drillHealth -= getDamageBasedOnHowManyShipsThereAre(evilShips);
						if (!Global.SetVolumeToZero)// TODO: add a sound of it actually being hit (clank or what not)
							player.playRandomHurtSound(6);
						Player.score--;
						if (!drill.isBroken && Global.drillHealth <= 0) {
							Player.score -= 100;
							if (!Global.SetVolumeToZero)
								click.play();// TODO: why is this a click? isn't your ship blowing up?
							drill.isBroken = true;
						}
					}
				}
				// enemy ship player's gun ball
				for (Iterator<Ball> iter2 = gun.balls.iterator(); iter2.hasNext();) {
					Ball b = iter2.next();
					// colliding with a single object: (enemy ship)
					if (d.health > 0 && b.rect.overlaps(d.rect) && b.canHit && !b.isDead) {
						b.canHit = false;
						b.ballLife = 0;
						d.health -= getDamageBasedOnHowManyEnemyShipsThereAre(evilShips);
						if (!Global.SetVolumeToZero)// TODO: add a sound of it actually being hit (clank or what not)
							click.play();
						Player.score++;
						if (!d.isDead && d.health <= 0) {
							Player.score += 100;// yay
							if (!Global.SetVolumeToZero)
								click.play();// TODO: why is this a click? isn't your ship blowing up?
							d.isDead = true;
							// add explosions?
							for (int x = 0; x < explosions.size; x++) {
								explosions.get(x).rect.x = d.rect.x + MathUtils.random(-100f, 100f);
								explosions.get(x).rect.y = d.rect.y + MathUtils.random(-100f, 100f);
								explosions.get(x).isDead = false;
								explosions.get(x).isResetAnimation = false;
							}
							// spawn any gems and money you were carrying.
							if (d.amethystStockpile > 0) {
								for (int x = 0; x < d.amethystStockpile; x++) {
									Amethyst amethyst = amethysts.obtain();
									amethyst.rect.x = ddd.MW / 2;
									amethyst.rect.y = ddd.MH / 2;
									amethystGems.add(amethyst);
								}
							}
							if (d.copperStockpile > 0) {
								for (int x = 0; x < d.copperStockpile; x++) {
									Copper copper = coppers.obtain();
									copper.rect.x = ddd.MW / 2;
									copper.rect.y = ddd.MH / 2;
									copperMetals.add(copper);
								}
							}
							if (d.diamondStockpile > 0) {
								for (int x = 0; x < d.diamondStockpile; x++) {
									Diamond diamond = diamonds.obtain();
									diamond.rect.x = ddd.MW / 2;
									diamond.rect.y = ddd.MH / 2;
									diamondGems.add(diamond);
								}
							}
							if (d.goldStockpile > 0) {
								for (int x = 0; x < d.goldStockpile; x++) {
									Gold gold = golds.obtain();
									gold.rect.x = ddd.MW / 2;
									gold.rect.y = ddd.MH / 2;
									goldMetals.add(gold);
								}
							}
							if (d.platinumStockpile > 0) {
								for (int x = 0; x < d.platinumStockpile; x++) {
									Platinum platinum = platinums.obtain();
									platinum.rect.x = ddd.MW / 2;
									platinum.rect.y = ddd.MH / 2;
									platinumMetals.add(platinum);
								}
							}
							if (d.rubyStockpile > 0) {
								for (int x = 0; x < d.rubyStockpile; x++) {
									Ruby ruby = rubies.obtain();
									ruby.rect.x = ddd.MW / 2;
									ruby.rect.y = ddd.MH / 2;
									rubyGems.add(ruby);
								}
							}
							if (d.sapphireStockpile > 0) {
								for (int x = 0; x < d.sapphireStockpile; x++) {
									Sapphire sapphire = sapphires.obtain();
									sapphire.rect.x = ddd.MW / 2;
									sapphire.rect.y = ddd.MH / 2;
									sapphireGems.add(sapphire);
								}
							}
							if (d.silverStockpile > 0) {
								for (int x = 0; x < d.silverStockpile; x++) {
									Silver silver = silvers.obtain();
									silver.rect.x = ddd.MW / 2;
									silver.rect.y = ddd.MH / 2;
									silverMetals.add(silver);
								}
							}
							if (d.topazStockpile > 0) {
								for (int x = 0; x < d.topazStockpile; x++) {
									Topaz topaz = topazs.obtain();
									topaz.rect.x = ddd.MW / 2;
									topaz.rect.y = ddd.MH / 2;
									topazGems.add(topaz);
								}
							}
							evilShips.removeValue(d, true);
						}
					}
					// colliding with a single object: (enemy's gun)
					if (d.enemyGun.health > 0 && b.rect.overlaps(d.enemyGun.rect) && b.canHit && !b.isDead) {
						System.out.println("collidng with the gun!");
						b.canHit = false;
						b.ballLife = 0;
						d.enemyGun.health -= getDamageBasedOnHowManyEnemyShipsThereAre(evilShips);
						if (!Global.SetVolumeToZero)// TODO: add a sound of it actually being hit (clank or what not)
							player.playRandomHurtSound(6);
						Player.score++;
						if (!d.enemyGun.isBroken && d.enemyGun.health <= 0) {
							Player.score += 100;
							if (!Global.SetVolumeToZero)
								click.play();// TODO: why is this a click? isn't your ship blowing up?
							d.enemyGun.isBroken = true;
						}
					}
					// colliding with a single object: (Enemy's engine)
					if (d.enemyEngine.health > 0 && b.rect.overlaps(d.enemyEngine.rect) && b.canHit && !b.isDead) {
						System.out.println("collidng with the engine!");
						b.canHit = false;
						b.ballLife = 0;
						d.enemyEngine.health -= getDamageBasedOnHowManyEnemyShipsThereAre(evilShips);
						if (!Global.SetVolumeToZero)// TODO: add a sound of it actually being hit (clank or what not)
							player.playRandomHurtSound(6);
						Player.score--;
						if (!d.enemyEngine.isBroken && d.enemyEngine.health <= 0) {
							Player.score -= 100;
							if (!Global.SetVolumeToZero)
								click.play();// TODO: why is this a click? isn't your ship blowing up?
							d.enemyEngine.isBroken = true;
							d.speed = 0f;
						}
					}
				}
//			// collding with a single object: (Player2)
//			if (Player2.health > 0 && d.rect.overlaps(player2.rect) && !player2.isJumping && !player2.isKicking && !player2.isBlocked && d.canHit && !d.isDying) {
//				d.canHit = false;
//				Player2.health--;
//				if (!Global.SetVolumeToZero)
//					player2.playRandomHurtSound(6);
//				Player2.score--;// testing score (remove this!)
//				if (!player2.isDying && !d.isEating && !d.isFat) {
//					Player2.score -= 100;
//					if (!Global.SetVolumeToZero)
//						click.play();
//					player2.isDying = true;
//					d.isEating = true;
//					d.isJumping = false;
//				}
//			} else
//				d.canHit = true;
//			// collding with a single object:
//			if (Player2.health > 0 && d.rect.overlaps(player2.rect) && player2.isBlocked) {
//				if (!d.isDying) {// now it only hits you once and sounds once. and negatives your score once.
//					if (!Global.SetVolumeToZero)
//						player2.playRandomHurtSound(6);
//					Player2.score += 4;// testing score (remove this!)
//					d.isDying = true;
//				}
//			}
//			// collding with a single object:
//			if (Player2.health > 0 && d.rect.overlaps(player2.rect) && player2.isKicking) {
//				if (!d.isDying) {// now it only hits you once and sounds once. and negatives your score once.
//					if (!Global.SetVolumeToZero)
//						player2.playRandomHurtSound(6);
//					Player2.score += 505;// testing score (remove this!)
//					d.isDying = true;
//				}
//			}
//			// collding with a single object: (Player3)
//			if (Player3.health > 0 && d.rect.overlaps(player3.rect) && !player3.isJumping && !player3.isKicking && !player3.isBlocked && d.canHit && !d.isDying) {
//				d.canHit = false;
//				Player3.health--;
//				if (!Global.SetVolumeToZero)
//					player3.playRandomHurtSound(6);
//				Player3.score--;// testing score (remove this!)
//				if (!player3.isDying && !d.isEating && !d.isFat) {
//					Player3.score -= 100;
//					if (!Global.SetVolumeToZero)
//						click.play();
//					player3.isDying = true;
//					d.isEating = true;
//					d.isJumping = false;
//				}
//			} else
//				d.canHit = true;
//			// collding with a single object:
//			if (Player3.health > 0 && d.rect.overlaps(player3.rect) && player3.isBlocked) {
//				if (!d.isDying) {// now it only hits you once and sounds once. and negatives your score once.
//					if (!Global.SetVolumeToZero)
//						player3.playRandomHurtSound(6);
//					Player3.score += 4;// testing score (remove this!)
//					d.isDying = true;
//				}
//			}
//			// collding with a single object:
//			if (Player3.health > 0 && d.rect.overlaps(player3.rect) && player3.isKicking) {
//				if (!d.isDying) {// now it only hits you once and sounds once. and negatives your score once.
//					if (!Global.SetVolumeToZero)
//						player3.playRandomHurtSound(6);
//					Player3.score += 505;// testing score (remove this!)
//					d.isDying = true;
//				}
//			}
//			// collding with a single object: (Player4)
//			if (Player4.health > 0 && d.rect.overlaps(player4.rect) && !player4.isJumping && !player4.isKicking && !player4.isBlocked && d.canHit && !d.isDying) {
//				d.canHit = false;
//				Player4.health--;
//				if (!Global.SetVolumeToZero)
//					player4.playRandomHurtSound(6);
//				Player4.score--;// testing score (remove this!)
//				if (!player4.isDying && !d.isEating && !d.isFat) {
//					Player4.score -= 100;
//					if (!Global.SetVolumeToZero)
//						click.play();
//					player4.isDying = true;
//					d.isEating = true;
//					d.isJumping = false;
//				}
//			} else
//				d.canHit = true;
//			// collding with a single object:
//			if (Player4.health > 0 && d.rect.overlaps(player4.rect) && player4.isBlocked) {
//				if (!d.isDying) {// now it only hits you once and sounds once. and negatives your score once.
//					if (!Global.SetVolumeToZero)
//						player4.playRandomHurtSound(6);
//					Player4.score += 4;// testing score (remove this!)
//					d.isDying = true;
//				}
//			}
//			// collding with a single object:
//			if (Player4.health > 0 && d.rect.overlaps(player4.rect) && player4.isKicking) {
//				if (!d.isDying) {// now it only hits you once and sounds once. and negatives your score once.
//					if (!Global.SetVolumeToZero)
//						player4.playRandomHurtSound(6);
//					Player4.score += 505;// testing score (remove this!)
//					d.isDying = true;
//				}
//			}
//			// collding with a single object: (Player5)
//			if (Player5.health > 0 && d.rect.overlaps(player5.rect) && !player5.isJumping && !player5.isKicking && !player5.isBlocked && d.canHit && !d.isDying) {
//				d.canHit = false;
//				Player5.health--;
//				if (!Global.SetVolumeToZero)
//					player5.playRandomHurtSound(6);
//				Player5.score--;// testing score (remove this!)
//				if (!player5.isDying && !d.isEating && !d.isFat) {
//					Player5.score -= 100;
//					if (!Global.SetVolumeToZero)
//						click.play();
//					player5.isDying = true;
//					d.isEating = true;
//					d.isJumping = false;
//				}
//			} else
//				d.canHit = true;
//			// collding with a single object:
//			if (Player5.health > 0 && d.rect.overlaps(player5.rect) && player5.isBlocked) {
//				if (!d.isDying) {// now it only hits you once and sounds once. and negatives your score once.
//					if (!Global.SetVolumeToZero)
//						player5.playRandomHurtSound(6);
//					Player5.score += 4;// testing score (remove this!)
//					d.isDying = true;
//				}
//			}
//			// collding with a single object:
//			if (Player5.health > 0 && d.rect.overlaps(player5.rect) && player5.isKicking) {
//				if (!d.isDying) {// now it only hits you once and sounds once. and negatives your score once.
//					if (!Global.SetVolumeToZero)
//						player5.playRandomHurtSound(6);
//					Player5.score += 505;// testing score (remove this!)
//					d.isDying = true;
//				}
//			}
//			// collding with a single object: (Player6)
//			if (Player6.health > 0 && d.rect.overlaps(player6.rect) && !player6.isJumping && !player6.isKicking && !player6.isBlocked && d.canHit && !d.isDying) {
//				d.canHit = false;
//				Player6.health--;
//				if (!Global.SetVolumeToZero)
//					player6.playRandomHurtSound(6);
//				Player6.score--;// testing score (remove this!)
//				if (!player6.isDying && !d.isEating && !d.isFat) {
//					Player6.score -= 100;
//					if (!Global.SetVolumeToZero)
//						click.play();
//					player6.isDying = true;
//					d.isEating = true;
//					d.isJumping = false;
//				}
//			} else
//				d.canHit = true;
//			// collding with a single object:
//			if (Player6.health > 0 && d.rect.overlaps(player6.rect) && player6.isBlocked) {
//				if (!d.isDying) {// now it only hits you once and sounds once. and negatives your score once.
//					if (!Global.SetVolumeToZero)
//						player6.playRandomHurtSound(6);
//					Player6.score += 4;// testing score (remove this!)
//					d.isDying = true;
//				}
//			}
//			// collding with a single object:
//			if (Player6.health > 0 && d.rect.overlaps(player6.rect) && player6.isKicking) {
//				if (!d.isDying) {// now it only hits you once and sounds once. and negatives your score once.
//					if (!Global.SetVolumeToZero)
//						player6.playRandomHurtSound(6);
//					Player6.score += 505;// testing score (remove this!)
//					d.isDying = true;
//				}
//			}
			}
		}
	}

	private int getDamageBasedOnHowManyShipsThereAre(Array<EvilShip> evilShips) {
		int s = evilShips.size;
		if (s <= 1)
			return 30;
		else if (s == 2 && s == 3)
			return 20;
		else if (s == 4 && s == 5)
			return 10;
		else if (s == 6 && s == 7)
			return 5;
		else if (s == 8 && s == 9)
			return 3;
		else if (s == 10 && s == 11)
			return 2;
		else
			return 1;
	}

	private int getDamageBasedOnHowManyEnemyShipsThereAre(Array<EvilShip> evilShips) {
		int s = evilShips.size;
		if (s <= 1)
			return 10;
		else if (s == 2 && s == 3)
			return 12;
		else if (s == 4 && s == 5)
			return 14;
		else if (s == 6 && s == 7)
			return 16;
		else if (s == 8 && s == 9)
			return 18;
		else if (s == 10 && s == 11)
			return 20;
		else
			return 30;
	}

	/**
	 * plays one through 6 sounds set numberOfSounds to 7 to randomly use one of all of them. xD
	 */
	public void playRandomClickSound(int numberOfSounds) {
		int randomSound = MathUtils.random(1, numberOfSounds);
		if (!Global.SetVolumeToZero) {
			if (randomSound == 1)
				click.play();
			else if (randomSound == 2)
				click2.play();
			else if (randomSound == 3)
				click4.play();
			else if (randomSound == 4)
				click5.play();
			else if (randomSound == 5)
				click6.play();
			else if (randomSound == 6)
				click7.play();
		}
	}

	@Override
	public void dispose() {
		enter.dispose();
		enter2.dispose();
		levelMusic.dispose();
		player.dispose();// for disposing the sound effects... because i'm not sure what needs disposed yet. I don't even know if this is needed. lol
//		player2.dispose();
//		player3.dispose();
//		player4.dispose();
//		player5.dispose();
		click.dispose();
		click2.dispose();
		click3.dispose();
		click4.dispose();
		click5.dispose();
		click6.dispose();
		click7.dispose();
		boom.dispose();
		death.dispose();
		reverseSlide.dispose();
	}

	@Override
	public void resize(int width, int height) {
		vport.update(width, height, true);
		// camera.setToOrtho(false, width / 32f / 2f, height / 32f / 2f);
		if (!levelMusic.isPlaying() && !Global.IsMusicPaused) {
			levelMusic.play();
		}
	}

	@Override
	public void hide() {
		if (levelMusic.isPlaying() && !Global.IsMusicPaused) {
			levelMusic.pause();
		}
	}

	@Override
	public void pause() {
		if (levelMusic.isPlaying() && !Global.IsMusicPaused) {
			levelMusic.pause();
		}
	}

	@Override
	public void resume() {
		if (!levelMusic.isPlaying() && !Global.IsMusicPaused) {
			levelMusic.play();
		}
	}

}
