package com.ld57.game;

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.math.Rectangle;
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.FireParticle;
import effects.Torch;
import entities.EvilShip;
import entities.PausePerson;
import entities.Player;
import levelElements.Drill;
import levelElements.Engine;
import levelElements.Exit;
import levelElements.Gun;
import levelElements.Shipv1;
import u.UsefulMethods;
import unearthables.AmethystHUD;
import unearthables.CopperHUD;
import unearthables.DiamondHUD;
import unearthables.GoldHUD;
import unearthables.PlatinumHUD;
import unearthables.RubyHUD;
import unearthables.SapphireHUD;
import unearthables.SilverHUD;
import unearthables.TopazHUD;

public class Store 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 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 isEvilShipsAdded;
	private Torch torch;
	public Array<FireParticle> fireParticles;
	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 Exit exit;
	private Array<EvilShip> evilShips;
	private Rectangle defenseRect;
	private Rectangle maxHealthRect;
	private Rectangle movementSpeedRect;
	private Rectangle turretRect;
	private Rectangle drillRect;
	private Rectangle attackRangeRect;
	private Rectangle fireRateRect;
	private Rectangle unlockPersonalGunRect;

	/*
	 * what do i need to do with this store?
	 * defense(health),
	 * movement speed (engines),
	 * attack (guns),
	 * drills (speeds up the rate of digging things out of the earth for points? rate of timer decrease speed?)
	 * 
	 * how do I even present this?
	 * what is the best way to do this? Judging amount of time i have for implementation (just a few hours)
	 * I need to do it in the easiest manner possible. I can use a mouse you just click on stuff...
	 * 
	 * ok after that disaster of implementation of just ending a screen and it wasn't "actually hidden" like bother
	 * Your ship. your gems (in their current amounts...)
	 * somewhere to puchase additional upgrades on the screen. Buy those things above!
	 * 
	 * 
	 */
	public Store(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, Gdx.graphics.getHeight() / 2);
		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. ;-)
		torch = new Torch();
		fireParticles = new Array<FireParticle>();
		// 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);
		// evil ship just to have an empty array (because it needs something correct to target)
		evilShips = new Array<EvilShip>();
		if (ddd.TruckArriveTimer < 500)
			ddd.TruckArriveTimer += 500;
		// level stuff
		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);
		exit = new Exit(200, 200);

		// selection rectangles
		defenseRect = new Rectangle(ddd.MW / 2 - 150, ddd.MH - 340, 600, 50);
		maxHealthRect = new Rectangle(ddd.MW / 2 - 150, ddd.MH - 392, 600, 50);
		movementSpeedRect = new Rectangle(ddd.MW / 2 - 150, ddd.MH - 444, 600, 50);
		turretRect = new Rectangle(ddd.MW / 2 - 150, ddd.MH - 496, 600, 50);
		drillRect = new Rectangle(ddd.MW / 2 - 150, ddd.MH - 548, 600, 50);
		attackRangeRect = new Rectangle(ddd.MW / 2 - 150, ddd.MH - 600, 600, 50);
		fireRateRect = new Rectangle(ddd.MW / 2 - 150, ddd.MH - 652, 600, 50);
		unlockPersonalGunRect = new Rectangle(ddd.MW / 2 - 150, ddd.MH - 704, 600, 50);

		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(.05f, .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("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;
					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
				exit.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);
				}

				// 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);
					}
				}
//				// 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);

				// draw costs hud
				game.font.getData().setScale(.7f);
				// turret
				amethystHUD.render(game, camera, delta, 700, 530);
				game.font.setColor(Color.PURPLE);
				game.font.draw(game.batch, "30", 721, 541);// shadow
				game.font.setColor(Color.WHITE);
				game.font.draw(game.batch, "30", 720, 540);
				// max health
				topazHUD.render(game, camera, delta, 700, 640);
				game.font.setColor(Color.GOLD);
				game.font.draw(game.batch, "10", 721, 651);// shadow
				game.font.setColor(Color.WHITE);
				game.font.draw(game.batch, "10", 720, 650);
				copperHUD.render(game, camera, delta, 755, 635);
				game.font.setColor(Color.SALMON);
				game.font.draw(game.batch, "10", 777, 651);// shadow
				game.font.setColor(Color.WHITE);
				game.font.draw(game.batch, "10", 776, 650);
				silverHUD.render(game, camera, delta, 635, 635);
				game.font.setColor(Color.GRAY);
				game.font.draw(game.batch, "5", 666, 651);// shadow
				game.font.setColor(Color.WHITE);
				game.font.draw(game.batch, "5", 665, 650);
				goldHUD.render(game, camera, delta, 580, 635);
				game.font.setColor(Color.YELLOW);
				game.font.draw(game.batch, "1", 605, 651);// shadow
				game.font.setColor(Color.WHITE);
				game.font.draw(game.batch, "1", 604, 650);
				// movement speed
				topazHUD.render(game, camera, delta, 700, 585);
				game.font.setColor(Color.GOLD);
				game.font.draw(game.batch, "10", 721, 595);// shadow
				game.font.setColor(Color.WHITE);
				game.font.draw(game.batch, "10", 720, 594);
				// Drill
				sapphireHUD.render(game, camera, delta, 700, 480);
				game.font.setColor(Color.BLUE);
				game.font.draw(game.batch, "20", 721, 491);// shadow
				game.font.setColor(Color.WHITE);
				game.font.draw(game.batch, "20", 720, 490);
				goldHUD.render(game, camera, delta, 755, 480);
				game.font.setColor(Color.YELLOW);
				game.font.draw(game.batch, "10", 777, 491);// shadow
				game.font.setColor(Color.WHITE);
				game.font.draw(game.batch, "10", 776, 490);
				// Fire Rate
				sapphireHUD.render(game, camera, delta, 700, 380);
				game.font.setColor(Color.BLUE);
				game.font.draw(game.batch, "13", 721, 391);// shadow
				game.font.setColor(Color.WHITE);
				game.font.draw(game.batch, "13", 720, 390);
				// defense
				rubyHUD.render(game, camera, delta, 700, 690);
				game.font.setColor(Color.RED);
				game.font.draw(game.batch, "10", 721, 701);// shadow
				game.font.setColor(Color.WHITE);
				game.font.draw(game.batch, "10", 720, 700);
				// attack Range
				diamondHUD.render(game, camera, delta, 700, 430);
				game.font.setColor(Color.CYAN);
				game.font.draw(game.batch, "3", 721, 441);// shadow
				game.font.setColor(Color.WHITE);
				game.font.draw(game.batch, "3", 720, 440);
				// unlock personal gun
				copperHUD.render(game, camera, delta, 755, 320);
				game.font.setColor(Color.SALMON);
				game.font.draw(game.batch, "99", 777, 333);// shadow
				game.font.setColor(Color.WHITE);
				game.font.draw(game.batch, "99", 776, 334);
				silverHUD.render(game, camera, delta, 700, 320);
				game.font.setColor(Color.GRAY);
				game.font.draw(game.batch, "60", 723, 333);// shadow
				game.font.setColor(Color.WHITE);
				game.font.draw(game.batch, "60", 722, 332);
				goldHUD.render(game, camera, delta, 650, 320);
				game.font.setColor(Color.YELLOW);
				game.font.draw(game.batch, "50", 671, 333);// shadow
				game.font.setColor(Color.WHITE);
				game.font.draw(game.batch, "50", 670, 332);
				platinumHUD.render(game, camera, delta, 600, 320);
				game.font.setColor(Color.WHITE);
				game.font.draw(game.batch, "10", 621, 333);// shadow
				game.font.setColor(Color.WHITE);
				game.font.draw(game.batch, "10", 620, 332);
				sapphireHUD.render(game, camera, delta, 500, 320);
				game.font.setColor(Color.BLUE);
				game.font.draw(game.batch, "40", 521, 332);// shadow
				game.font.setColor(Color.WHITE);
				game.font.draw(game.batch, "40", 520, 331);
				diamondHUD.render(game, camera, delta, 550, 320);
				game.font.setColor(Color.CYAN);
				game.font.draw(game.batch, "30", 565, 331);// shadow
				game.font.setColor(Color.WHITE);
				game.font.draw(game.batch, "30", 564, 330);
				// add upgrade options here:
				// 17) upgrade shop, defense(health), movement speed (engines), attack (guns), drills (speeds up the rate of digging things out of the earth for
				// points)
				int ofx = 100;
				int ofy = 200;
				game.font.getData().setScale(2f);
				game.font.setColor(Color.WHITE);
				game.font.draw(game.batch, "Welcome to the Store", ddd.MW / 2 - 301 - ofx, ddd.MH + 101 - ofy);// shadow
				game.font.setColor(Color.BROWN);// set color before you draw
				game.font.draw(game.batch, "Welcome to the Store", ddd.MW / 2 - 300 - ofx, ddd.MH + 100 - ofy);
				game.font.getData().setScale(1f);
				game.font.setColor(Color.WHITE);
				game.font.draw(game.batch, "Use the mouse to select which one you'd like and just press them.", ddd.MW / 2 - 351 - ofx, ddd.MH + 31 - ofy);// shadow
				game.font.setColor(Color.ORANGE);// set color before you draw
				game.font.draw(game.batch, "Use the mouse to select which one you'd like and just press them.", ddd.MW / 2 - 350 - ofx, ddd.MH + 30 - ofy);
				game.font.getData().setScale(.8f);
				game.font.setColor(Color.WHITE);
				game.font.draw(game.batch, "When done go out the exit, like move your SHIP out to it.", ddd.MW / 2 - 351 - ofx, ddd.MH - ofy);// shadow
				game.font.setColor(Color.GREEN);// set color before you draw
				game.font.draw(game.batch, "When done go out the exit, like move your SHIP out to it.", ddd.MW / 2 - 350 - ofx, ddd.MH - ofy);
				game.font.getData().setScale(1f);
				// do the options below
				game.font.setColor(Color.WHITE);
				game.font.draw(game.batch, "DEFENSE + 1", ddd.MW / 2 + 1 - ofx, ddd.MH - 112 - ofy);// shadow
				game.font.setColor(Color.RED);// set color before you draw
				game.font.draw(game.batch, "DEFENSE + 1", ddd.MW / 2 - ofx, ddd.MH - 111 - ofy);
				game.font.setColor(Color.WHITE);
				game.font.draw(game.batch, "MAX HEALTH X 2", ddd.MW / 2 + 1 - ofx, ddd.MH - 162 - ofy);// shadow
				game.font.setColor(Color.SALMON);// set color before you draw
				game.font.draw(game.batch, "MAX HEALTH X 2", ddd.MW / 2 - ofx, ddd.MH - 161 - ofy);
				game.font.setColor(Color.WHITE);
				game.font.draw(game.batch, "MOVEMENT SPEED + 30", ddd.MW / 2 + 1 - ofx, ddd.MH - 212 - ofy);// shadow
				game.font.setColor(Color.ORANGE);// set color before you draw
				game.font.draw(game.batch, "MOVEMENT SPEED + 30", ddd.MW / 2 - ofx, ddd.MH - 211 - ofy);
				game.font.setColor(Color.WHITE);
				game.font.draw(game.batch, "TURRET + 1", ddd.MW / 2 + 1 - ofx, ddd.MH - 262 - ofy);// shadow
				game.font.setColor(Color.PURPLE);// set color before you draw
				game.font.draw(game.batch, "TURRET + 1", ddd.MW / 2 - ofx, ddd.MH - 261 - ofy);
				game.font.setColor(Color.WHITE);
				game.font.draw(game.batch, "DRILL + 1", ddd.MW / 2 + 1 - ofx, ddd.MH - 314 - ofy);// shadow
				game.font.setColor(Color.GREEN);// set color before you draw
				game.font.draw(game.batch, "DRILL + 1", ddd.MW / 2 - ofx, ddd.MH - 313 - ofy);
				game.font.setColor(Color.WHITE);
				game.font.draw(game.batch, "ATTACK RANGE + 20", ddd.MW / 2 + 1 - ofx, ddd.MH - 366 - ofy);// shadow
				game.font.setColor(Color.YELLOW);// set color before you draw
				game.font.draw(game.batch, "ATTACK RANGE + 20", ddd.MW / 2 - ofx, ddd.MH - 365 - ofy);
				game.font.setColor(Color.WHITE);
				game.font.draw(game.batch, "RATE OF FIRE - 1", ddd.MW / 2 + 1 - ofx, ddd.MH - 422 - ofy);// shadow
				game.font.setColor(Color.BLUE);// set color before you draw
				game.font.draw(game.batch, "RATE OF FIRE - 1", ddd.MW / 2 - ofx, ddd.MH - 421 - ofy);
				game.font.setColor(Color.WHITE);
				game.font.draw(game.batch, "UNLOCK PERSONAL GUN", ddd.MW / 2 + 1 - ofx, ddd.MH - 472 - ofy);// shadow
				game.font.setColor(Color.GOLD);// set color before you draw
				game.font.draw(game.batch, "UNLOCK PERSONAL GUN", ddd.MW / 2 - ofx, ddd.MH - 471 - ofy);
//				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(defenseRect, Color.RED, camera.combined);
				u.DebugRenderer.DrawDebugRectangle(maxHealthRect, Color.SALMON, camera.combined);
				u.DebugRenderer.DrawDebugRectangle(movementSpeedRect, Color.ORANGE, camera.combined);
				u.DebugRenderer.DrawDebugRectangle(turretRect, Color.PURPLE, camera.combined);
				u.DebugRenderer.DrawDebugRectangle(drillRect, Color.GREEN, camera.combined);
				u.DebugRenderer.DrawDebugRectangle(attackRangeRect, Color.YELLOW, camera.combined);
				u.DebugRenderer.DrawDebugRectangle(fireRateRect, Color.BLUE, camera.combined);
				u.DebugRenderer.DrawDebugRectangle(unlockPersonalGunRect, Color.GOLD, 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);
//				}
				// test for whether you are clicking on things
				if (Gdx.input.isButtonJustPressed(Input.Buttons.LEFT) && UsefulMethods.IsMouseInsideRectangle(defenseRect, camera)) {
					if (Global.p1RubyStockpile >= 10) {
						Global.p1RubyStockpile -= 10;
						Global.p1Defense++;
						Player.score += 2000;
					} else {
						if (!Global.SetVolumeToZero)
							click.play();
					}
				}
				if (Gdx.input.isButtonJustPressed(Input.Buttons.LEFT) && UsefulMethods.IsMouseInsideRectangle(maxHealthRect, camera)) {
					if (Global.p1CopperStockpile >= 10 && Global.p1TopazStockpile >= 10 && Global.p1SilverStockpile >= 5 && Global.p1GoldStockpile >= 1) {
						Global.p1CopperStockpile -= 10;
						Global.p1TopazStockpile -= 10;
						Global.p1SilverStockpile -= 5;
						Global.p1GoldStockpile--;
						Global.engineHealthMax *= 2;
						Global.drillHealthMax *= 2;
						Global.shipv1HealthMax *= 2;
						Global.gunHealthMax *= 2;
						Player.score += 4000;
					} else {
						if (!Global.SetVolumeToZero)
							click.play();
					}
				}
				if (Gdx.input.isButtonJustPressed(Input.Buttons.LEFT) && UsefulMethods.IsMouseInsideRectangle(movementSpeedRect, camera)) {
					if (Global.p1TopazStockpile >= 10) {
						Global.p1TopazStockpile -= 10;
						Global.p1Speed += 100f;
						Player.score += 1000;
					} else {
						if (!Global.SetVolumeToZero)
							click.play();
					}
				}
				if (Gdx.input.isButtonJustPressed(Input.Buttons.LEFT) && UsefulMethods.IsMouseInsideRectangle(turretRect, camera)) {
					if (Global.p1AmethystStockpile >= 30) {
						Global.p1AmethystStockpile -= 30;
						Global.isTurretV2 = true;
						Player.score += 5000;
					} else {
						if (!Global.SetVolumeToZero)
							click.play();
					}
				}
				if (Gdx.input.isButtonJustPressed(Input.Buttons.LEFT) && UsefulMethods.IsMouseInsideRectangle(drillRect, camera)) {
					if (Global.p1SapphireStockpile >= 20 && Global.p1GoldStockpile >= 10) {
						Global.p1SapphireStockpile -= 20;
						Global.p1GoldStockpile -= 10;
						Global.isDrillV2 = true;
						Player.score += 5000;
					} else {
						if (!Global.SetVolumeToZero)
							click.play();
					}
				}
				if (Gdx.input.isButtonJustPressed(Input.Buttons.LEFT) && UsefulMethods.IsMouseInsideRectangle(attackRangeRect, camera)) {
					if (Global.p1DiamondStockpile >= 3) {
						Global.p1DiamondStockpile -= 3;
						Global.gunFiringDistance += 50f;
						Player.score += 1000;
					} else {
						if (!Global.SetVolumeToZero)
							click.play();
					}
				}
				if (Gdx.input.isButtonJustPressed(Input.Buttons.LEFT) && UsefulMethods.IsMouseInsideRectangle(fireRateRect, camera)) {
					if (Global.p1SapphireStockpile >= 13) {
						Global.p1SapphireStockpile -= 13;
						if (Global.fireDelay >= 30)
							Global.fireDelay -= 30;
						else
							Global.fireDelay = 0;
						Player.score += 1000;
					} else {
						if (!Global.SetVolumeToZero)
							click.play();
					}
				}
				if (Gdx.input.isButtonJustPressed(Input.Buttons.LEFT) && UsefulMethods.IsMouseInsideRectangle(unlockPersonalGunRect, camera)) {
					if (Global.p1DiamondStockpile >= 30 && Global.p1PlatinumStockpile >= 10 && Global.p1SapphireStockpile >= 40 && Global.p1GoldStockpile >= 50
							&& Global.p1SilverStockpile >= 60 && Global.p1CopperStockpile >= 99) {
						Global.p1DiamondStockpile -= 30;
						Global.p1PlatinumStockpile -= 10;
						Global.p1SapphireStockpile -= 40;
						Global.p1GoldStockpile -= 50;
						Global.p1SilverStockpile -= 60;
						Global.p1CopperStockpile -= 99;
						Global.isPersonalGunUnlocked = true;
						Player.score += 10000;
					} else {
						if (!Global.SetVolumeToZero)
							click.play();
					}
				}
				// music check, the show box wasn't working
				if (!Global.IsMusicPaused)
					levelMusic.play();
				// collisions
				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();
					// camera.position.y = 0;
					// camera.position.x = 0;
					// camera.update();
					game.setScreen(new Store(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 && exit.isClicked && !player.isDying && Player.health >= 0 && !onlyGoThroughLevelEndOnce) {
					onlyGoThroughLevelEndOnce = true;

					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 LevelTwo(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(exit.rect)) {
			System.out.println("clicked the exit");
			exit.isClicked = true;// activate the exit!
		}
	}

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

	/**
	 * 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();
		}
	}

}
