示例#1
0
  public void OnUpdate() {
    if (!isAlive()) // Stop when dead
    {
      if (getFlySpeed() > 0) setFlySpeed(getFlySpeed() - 0.0001f * (getFlySpeed() / 2));
    } else {
      timeSinceLastShot +=
          game.getFrame().GetDeltaFrameTime() + getScore() / 45; // TODO: Needs balancing!
      if (Input.IsKeyDown(KeyEvent.VK_A) && pos.x > 0)
        pos.x -= 0.5 * game.getFrame().GetDeltaFrameTime();
      if (Input.IsKeyDown(KeyEvent.VK_D) && pos.x < game.getFrame().getWidth() - size.x)
        pos.x += 0.5 * game.getFrame().GetDeltaFrameTime();
      if (Input.IsKeyDown(KeyEvent.VK_W) && pos.y > 0)
        pos.y -= 0.5 * game.getFrame().GetDeltaFrameTime();
      if (Input.IsKeyDown(KeyEvent.VK_S) && pos.y < game.getFrame().getHeight() - size.y)
        pos.y += 0.5 * game.getFrame().GetDeltaFrameTime();
      if (Input.IsKeyDown(KeyEvent.VK_SPACE) && timeSinceLastShot > shotDelay) {
        fireBullet();
        timeSinceLastShot = 0;
      }

      if (testEnemyCol() >= 0) giveDamage();

      if (getFlySpeed() >= 1.7f
          && game.getAchievements().Unlocked(Achievement.ACHIEVEMENT_DIZZY)) // TODO: Fix this
      game.getAchievements().Unlock(Achievement.ACHIEVEMENT_DIZZY);
      if (getFlySpeed() >= 2.3f && game.getAchievements().Unlocked(Achievement.ACHIEVEMENT_WARP))
        game.getAchievements().Unlock(Achievement.ACHIEVEMENT_WARP);
      if (getFlySpeed() >= 2.7f
          && game.getAchievements().Unlocked(Achievement.ACHIEVEMENT_LIGHTSPEED))
        game.getAchievements().Unlock(Achievement.ACHIEVEMENT_LIGHTSPEED);
    }

    bounding.x = (int) pos.x;
    bounding.y = (int) pos.y;
  }
示例#2
0
 public void setFlySpeed(float speed) {
   game.getBackground().speed = speed;
 }
示例#3
0
 public float getFlySpeed() {
   return game.getBackground().speed;
 }
示例#4
0
 private void die() {
   game.OnDeath();
 }