コード例 #1
0
 private void updateBob(float deltaTime, float accelX) {
   if (local_bob.state != Bob.BOB_STATE_HIT && local_bob.position.y <= 0.5f)
     local_bob.hitPlatform();
   if (local_bob.state != Bob.BOB_STATE_HIT)
     local_bob.velocity.x = -accelX / 10 * Bob.BOB_MOVE_VELOCITY;
   local_bob.update(deltaTime);
   heightSoFar = Math.max(local_bob.position.y, heightSoFar);
 }
コード例 #2
0
  private void checkItemCollisions() {
    int len = coins.size();
    for (int i = 0; i < len; i++) {
      Coin coin = coins.get(i);
      if (local_bob.bounds.overlaps(coin.bounds)) {
        coins.remove(coin);
        len = coins.size();
        listener.coin();
        score += Coin.COIN_SCORE;
      }
    }

    if (local_bob.velocity.y > 0) return;

    len = springs.size();
    for (int i = 0; i < len; i++) {
      Spring spring = springs.get(i);
      if (local_bob.position.y > spring.position.y) {
        if (local_bob.bounds.overlaps(spring.bounds)) {
          local_bob.hitSpring();
          listener.highJump();
        }
      }
    }
  }
コード例 #3
0
 private void checkSquirrelCollisions() {
   int len = squirrels.size();
   for (int i = 0; i < len; i++) {
     Squirrel squirrel = squirrels.get(i);
     if (squirrel.bounds.overlaps(local_bob.bounds)) {
       local_bob.hitSquirrel();
       listener.hit();
     }
   }
 }
コード例 #4
0
  private void checkPlatformCollisions() {
    if (local_bob.velocity.y > 0) return;

    int len = platforms.size();
    for (int i = 0; i < len; i++) {
      Platform platform = platforms.get(i);
      if (local_bob.position.y > platform.position.y) {
        if (local_bob.bounds.overlaps(platform.bounds)) {
          local_bob.hitPlatform();
          listener.jump();
          if (rand.nextFloat() > 0.5f) {
            platform.pulverize();
          }
          break;
        }
      }
    }
  }