public void update()
	{
		try
		{
			Thread.sleep(4);
		}
		catch(Exception e){}
		
		if (keys.contains(KeyEvent.VK_ESCAPE))
			PongWars.close();
		
		if (keys.contains(KeyEvent.VK_W))
			left.moveUp();
		if (keys.contains(KeyEvent.VK_S))
			left.moveDown();
		if (keys.contains(KeyEvent.VK_UP))
			right.moveUp();
		if (keys.contains(KeyEvent.VK_DOWN))
			right.moveDown();
			
		if (keys.contains(KeyEvent.VK_SPACE))
			left.space++;
		if (keys.contains(KeyEvent.VK_ENTER))
			right.enter++;
		if(keys.contains(KeyEvent.VK_BACK_SLASH))
			right.slash++;
		if(keys.contains(KeyEvent.VK_V))
			left.vv++;
		
		if (left.space >= 20 && left.ammo > 0)
		{	
			LaserShot newLaserShot = left.shoot(3);
			l.add(newLaserShot);
			left.space = 0;
			count1++;
		}
		if (right.enter >= 20 && right.ammo > 0)
		{
			LaserShot newLaserShot2 = right.shoot(-3);
			l.add(newLaserShot2);
			right.enter = 0;
			count2++;
		}
		if(left.vv >= 20 && left.missileAmmo > 0)
		{
			Missile newMissile = left.shootM(1);
			mm.add(newMissile);
			left.vv = 0;
			count3++;
		}
		if(right.slash >= 20 && right.missileAmmo > 0)
		{
			Missile newMissile2 = right.shootM(-1);
			mm.add(newMissile2);
			right.slash = 0;
			count4++;
		}
		for (int i = 0; i < l.size(); i++)
		{
			l.get(i).move();
			if (l.get(i).rect.intersects(left.rect) && l.get(i).xVel < 0)
			{
				left.HP -= 2;
				l.get(i).kill();
				l.remove(i);
				i--;
				continue;
			}
			if (l.get(i).rect.intersects(right.rect) && l.get(i).xVel > 0)
			{
				right.HP -= 2;
				l.get(i).kill();
				l.remove(i);
				i--;
				continue;
			}
			if (l.get(i).x > PongScreen.width)
			{
				l.get(i).kill();
				l.remove(i);
				i--;
				continue;
			}
			if (l.get(i).x < 0)
			{
				l.get(i).kill();
				l.remove(i);
				i--;
				continue;
			}
		}
		for (int i = 0; i < mm.size(); i++)
		{
			mm.get(i).move();
			if (mm.get(i).rect.intersects(left.rect) && mm.get(i).xVel < 0)
			{
				left.HP-=10;
				mm.get(i).kill();
				mm.remove(i);
				i--;
				continue;
			}
			if (mm.get(i).rect.intersects(right.rect) && mm.get(i).xVel > 0)
			{
				right.HP-=10;
				mm.get(i).kill();
				mm.remove(i);
				i--;
				continue;
			}
			if (mm.get(i).x > PongScreen.width - 5)
			{
				mm.get(i).kill();
				mm.remove(i);
				i--;
				continue;
			}
			if (mm.get(i).x < -5)
			{
				mm.get(i).kill();
				mm.remove(i);
				i--;
				continue;
			}
		}
		
		ball.update();
		if (ball.rect.intersects(right.rect) && ball.xVel > 0)
		{
			ball.bounceX(right);
			right.ammo += 25;
			right.missileAmmo += 5;
		}
		if (ball.rect.intersects(left.rect) && ball.xVel < 0)
		{
			ball.bounceX(left);
			left.ammo += 25;
			left.missileAmmo += 5;
		}
		if (ball.x + ball.r * 2 < 0)
		{
			right.score++;
			ball.reset();
			right.HP = 100;
			left.HP = 100;
			right.ammo += 100;
			left.ammo += 0;
			right.missileAmmo += 10;
			left.missileAmmo += 0;
			try
			{
				Thread.sleep(10);
			}
			catch(Exception e){}
		}
		if (ball.x > PongScreen.width)
		{
			left.score++;
			ball.reset();
			right.HP = 100;
			left.HP = 100;
			right.ammo += 0;
			left.ammo += 100;
			right.missileAmmo += 0;
			left.missileAmmo += 10;
			try
			{
				Thread.sleep(10);
			}
			catch(Exception e){}
		}
		if (left.HP <= 0)
		{
			right.score++;
			ball.reset();
			right.HP = 100;
			left.HP = 100;
			right.ammo += 100;
			left.ammo += 0;
			right.missileAmmo += 10;
			left.missileAmmo += 0;
			try
			{
				Thread.sleep(10);
			}
			catch(Exception e){}
		}
		if (right.HP <= 0)
		{
			left.score++;
			ball.reset();
			right.HP = 100;
			left.HP = 100;
			right.ammo += 0;
			left.ammo += 100;
			right.missileAmmo += 0;
			left.missileAmmo += 10;
			try
			{
				Thread.sleep(10);
			}
			catch(Exception e){}
		}
	}