@Override
	public void run() {
		// Main game loop
		
		while (true) {
			//Sprite logic
			switch(playerSpriteType){
			case 0:
				currentSprite = characterSpriteIdle;
				break;
			case 1:
				currentSprite = characterJumpedSprite;
				break;
			case 2:
				currentSprite = characterDownSprite;
				break;
			default:
				currentSprite = characterSpriteIdle;
				break;
			}
			
			//updates sprites
			player.update();
			heliboy1.update();
			heliboy2.update();
			bg1.update();
			bg2.update();
			
			//Update the projectiles
			ArrayList<Projectile> projectiles = player.getProjectiles();
			for (int i = 0; i < projectiles.size(); i++) {
				Projectile p = (Projectile) projectiles.get(i);
				if (p.isVisible() == true) {
					p.update();
				} else {
					projectiles.remove(i);
				}
			}
			
			//Built in function that calls the paint method
			repaint();
			
			try {
				Thread.sleep(17); // 17 ms is 60 fps
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}