@Override
	public void update(GameContainer gc, StateBasedGame game, int delta) throws SlickException {
		//delta calculates frames per second (stay at same speed regardless of framerate)
		super.update(gc, game, delta);
		timer++;
		levelTimer++;
		int randomInt = r.nextInt(550);
		int randomAlien = r.nextInt(550);
		if(levelTimer >= 750) {
			level++;
			levelTimer = 0;
		}
		if(timer >= (lag - (level*20))) {		
			Asteroid a = new Asteroid(randomInt, -50);
			asteroids.add(a);
			a.depth += 1;
			add(a);
			timer = 0;	
		}
		if(level >= 4) {
			alienTimer++;
			if(alienTimer >= (lag - level*30)) {
				Alien alien = new Alien(randomAlien, -50);
				aliens.add(alien);
				add(alien);
				alienTimer = 0;
			}
		}
		for(int i = 0; i < asteroids.size(); i++) {
			asteroids.get(i).setLevel(level);
			if(asteroids.get(i).getY() > ME.world.getHeight()) {
				asteroids.remove(i);
				p.health -=1;
			}
		}
		for(int j = 0; j < aliens.size(); j++) {
			aliens.get(j).setLevel(level);
			if(aliens.get(j).getY() > ME.world.getHeight()) {
				aliens.remove(j);
				p.health -= 1;
			}
		}
		if(p.health == 0) {
			p.destroy();
			game.enterState(2, new FadeOutTransition(), new FadeInTransition());
		}
		
	}