コード例 #1
0
  public void stomp(BulletBill bill) {

    if (world.verbose > 5) System.out.println("Simstomping Bullet Bill!");
    if (deathTime > 0 || world.paused) return;
    float targetY = bill.y - bill.height / 2;
    move(0, targetY - y);
    if (world.verbose > 0)
      System.out.println(
          "STOMP! targetY: " + targetY + " enemyy: " + bill.y + " height: " + bill.height);

    xJumpSpeed = 0;
    yJumpSpeed = -1.9f;
    jumpTime = 8;
    ya = jumpTime * yJumpSpeed;
    onGround = false;
    sliding = false;
    invulnerableTime = 1;
    world.enemiesJumpedOn++;
  }
コード例 #2
0
  public void stomp(Enemy enemy) {
    if (world.verbose > 0) System.out.println("Prestomp!");
    if (deathTime > 0 || world.paused) return;

    float targetY = enemy.y - enemy.height / 2;
    if (world.verbose > 0)
      System.out.println(
          "STOMP! targetY: " + targetY + " enemyy: " + enemy.y + " height: " + enemy.height);
    move(0, targetY - y);

    xJumpSpeed = 0;
    yJumpSpeed = -1.9f;
    jumpTime = 8;
    ya = jumpTime * yJumpSpeed;
    if (world.verbose > 0) System.out.println("Stomp ya: " + ya + " marioY: " + this.y);
    onGround = false;
    sliding = false;
    invulnerableTime = 1;
    world.enemiesJumpedOn++;
  }
コード例 #3
0
  public void stomp(Shell shell) {
    if (deathTime > 0 || world.paused) return;

    if (keys[KEY_SPEED] && shell.facing == 0) {
      carried = shell;
      shell.carried = true;
      world.otherTricks += 2;
    } else {
      float targetY = shell.y - shell.height / 2;
      move(0, targetY - y);

      xJumpSpeed = 0;
      yJumpSpeed = -1.9f;
      jumpTime = 8;
      ya = jumpTime * yJumpSpeed;
      onGround = false;
      sliding = false;
      invulnerableTime = 1;
      world.otherTricks++;
    }
  }
コード例 #4
0
  public void move() {
    if (winTime > 0) {
      winTime++;

      xa = 0;
      ya = 0;
      return;
    }

    if (deathTime > 0) {
      deathTime++;
      if (deathTime < 11) {
        xa = 0;
        ya = 0;
      } else if (deathTime == 11) {
        ya = -15;
      } else {
        ya += 2;
      }
      x += xa;
      y += ya;
      return;
    }

    // if (world.paused)
    //	System.out.println("Sim World Paused!");
    if (powerUpTime != 0) {
      if (powerUpTime > 0) {
        powerUpTime--;
      } else {
        powerUpTime++;
      }

      if (powerUpTime == 0) {
        if (world.paused) System.out.println("Sim World Unpaused!");
        world.paused = false;
      }
      return;
    }

    if (invulnerableTime > 0) invulnerableTime--;
    wasOnGround = onGround;
    float sideWaysSpeed = keys[KEY_SPEED] ? 1.2f : 0.6f;
    //        float sideWaysSpeed = onGround ? 2.5f : 1.2f;

    if (onGround) {
      if (keys[KEY_DOWN] && large) {
        ducking = true;
      } else {
        ducking = false;
      }
    }

    if (xa > 2) {
      facing = 1;
    }
    if (xa < -2) {
      facing = -1;
    }

    if (keys[KEY_JUMP] || (jumpTime < 0 && !onGround && !sliding)) {
      if (jumpTime < 0) {
        xa = xJumpSpeed;
        ya = -jumpTime * yJumpSpeed;
        jumpTime++;
      } else if (onGround && mayJump) {
        xJumpSpeed = 0;
        yJumpSpeed = -1.9f;
        jumpTime = 7;
        ya = jumpTime * yJumpSpeed;
        onGround = false;
        sliding = false;
      } else if (sliding && mayJump) {
        xJumpSpeed = -facing * 6.0f;
        yJumpSpeed = -2.0f;
        jumpTime = -6;
        xa = xJumpSpeed;
        ya = -jumpTime * yJumpSpeed;
        onGround = false;
        sliding = false;
        facing = -facing;
      } else if (jumpTime > 0) {
        xa += xJumpSpeed;
        ya = jumpTime * yJumpSpeed;
        jumpTime--;
      }
    } else {
      jumpTime = 0;
    }

    if (keys[KEY_LEFT] && !ducking) {
      if (facing == 1) sliding = false;
      xa -= sideWaysSpeed;
      if (jumpTime >= 0) facing = -1;
    }

    if (keys[KEY_RIGHT] && !ducking) {
      if (facing == -1) sliding = false;
      xa += sideWaysSpeed;
      if (jumpTime >= 0) facing = 1;
    }

    if ((!keys[KEY_LEFT] && !keys[KEY_RIGHT]) || ducking || ya < 0 || onGround) {
      sliding = false;
    }

    if (keys[KEY_SPEED] && canShoot && this.fire && world.fireballsOnScreen < 2) {
      // System.out.println("Adding fireball!");
      world.addSprite(new Fireball(world, x + facing * 6, y - 20, facing));
    }

    world.paused = GlobalOptions.pauseWorld;
    canShoot = !keys[KEY_SPEED];

    mayJump = (onGround || sliding) && !keys[KEY_JUMP];

    runTime += (Math.abs(xa)) + 5;
    if (Math.abs(xa) < 0.5f) {
      runTime = 0;
      xa = 0;
    }

    if (sliding) {
      ya *= 0.5f;
    }

    onGround = false;
    move(xa, 0);
    move(0, ya);

    // System.out.println("Mario Sim Speed: "+xa);
    if (y > world.level.height * 16 + 16) {
      die();
    }

    if (x < 0) {
      x = 0;
      xa = 0;
    }

    if (x > world.level.xExit * 16) {
      win();
    }

    if (x > world.level.width * 16) {
      x = world.level.width * 16;
      xa = 0;
    }

    ya *= 0.85f;
    if (onGround) {
      xa *= GROUND_INERTIA;
    } else {
      xa *= AIR_INERTIA;
    }

    if (!onGround) {
      ya += 3;
    }

    if (carried != null) {
      carried.x = x + facing * 8;
      carried.y = y - 2;
      if (!keys[KEY_SPEED]) {
        // System.out.println("Releasing shell!");
        carried.release(this);
        carried = null;
      }
    }
    // System.out.println("Mariopos: "+x+" "+y);
  }