/*
  * Konstruktor s animaci
  */
 public PlayerObject(
     Animation animation,
     Shape collisionShape,
     Vector2f position,
     float mass,
     GameContainer gc,
     int player)
     throws SlickException {
   super(
       animation,
       collisionShape,
       ECollisionType.PLAYER,
       "Player",
       position,
       new Vector2f(0, 0),
       mass,
       100,
       0.01f,
       engine.level.Level.getLevelShape());
   gc.getInput().addKeyListener(this);
   setControls(player);
   init();
   this.animations = new Animations(EFighter.SENTINEL);
   if (animation == null) {
     animation = animations.getStayAnimation(getSide());
   }
 }
 @Override
 public void keyReleased(int i, char c) {
   if (!isAlive) {
     return;
   }
   if (i == controls[3]) {
     setConstantSpeed(0);
     if (animation != null) {
       animation = animations.getStayAnimation(getSide());
     }
   }
   if (i == controls[1]) {
     setConstantSpeed(0);
     if (animation != null) {
       animation = animations.getStayAnimation(getSide());
     }
   }
 }
  /*
   * Aktualizace objektu
   */
  @Override
  public void update(GameContainer gc, StateBasedGame sbg, int delta) {
    super.update(gc, sbg, delta);

    if (!isAlive) {
      if ((System.currentTimeMillis() - timeOfDeath) > spawnInterval) {
        position = new Vector2f(Level.getScreenXToLevelX(100), Level.getScreenYToLevelY(100));
        isAlive = true;
        animation = animations.getStayAnimation(getSide());
        setHealth(100);
      }
    }

    int border = 250;
    float screen_speed = 3f;
    if (position.x < engine.level.Level.getScreenShape().getMinX() + border) {
      if (position.x > engine.level.Level.getLevelShape().getMinX()
          && engine.level.Level.getLevelShape().getMinX()
              < engine.level.Level.getScreenShape().getMinX()) {
        engine.level.Level.moveScreen(screen_speed, 0);
      }
    }
    if (getCollisionShape().getMaxX() > engine.level.Level.getScreenShape().getMaxX() - border) {
      if (position.x < engine.level.Level.getLevelShape().getMaxX()
          && engine.level.Level.getLevelShape().getMaxX()
              > engine.level.Level.getScreenShape().getMaxX()) {
        engine.level.Level.moveScreen(-screen_speed, 0);
      }
    }
    if (position.y < engine.level.Level.getScreenShape().getMinY() + border) {
      if (position.y > engine.level.Level.getLevelShape().getMinY()
          && engine.level.Level.getLevelShape().getMinY()
              < engine.level.Level.getScreenShape().getMinY()) {
        engine.level.Level.moveScreen(0, screen_speed);
      }
    }
    if (getCollisionShape().getMaxY() > engine.level.Level.getScreenShape().getMaxY() - border) {
      if (getCollisionShape().getMaxY() < engine.level.Level.getLevelShape().getMaxY()
          && engine.level.Level.getLevelShape().getMaxY()
              > engine.level.Level.getScreenShape().getMaxY()) {
        engine.level.Level.moveScreen(0, -screen_speed);
      }
    }

    if (position.x < engine.level.Level.getScreenShape().getMinX()) {
      position.x = engine.level.Level.getScreenShape().getMinX();
    }
    if (getCollisionShape().getMaxX() > Level.getScreenShape().getMaxX()) {
      position.x = Level.getScreenShape().getMaxX() - getCollisionShape().getWidth();
    }
    if (position.y < Level.getScreenShape().getMinY()) {
      position.y = Level.getScreenShape().getMinY();
    }
    if (position.y > Level.getLevelShape().getMaxY()) {
      this.deactivate();
    }
  }
 @Override
 protected void doAfterCollision(ICollidableObject entity) {
   if (isAlive) {
     if (animation != null) {
       if (animations.isJumpAnimation(animation)) {
         if (isOnGround() && velocity.x < 0.5 && velocity.x > -0.5) {
           animation = animations.getStayAnimation(getSide());
         }
         if (isOnGround() && velocity.x > 1) {
           animation = animations.getWalkAnimation(getSide());
         } else if (isOnGround() && velocity.x < -1) {
           animation = animations.getWalkAnimation(getSide());
         }
       }
       if (isOnGround() && animations.isDamagedAnimation(animation)) {
         animation = animations.getStayAnimation(getSide());
       }
     }
   }
 }