Beispiel #1
0
 public void startGame() {
   config.gamelost = false;
   config.running = true;
   board.poistaKaikki();
   pistelaskuri.setScore(0);
   config.waitFor = config.waitFor_init;
   config.level = 1;
   ilmoittaja.nollaa();
   this.shuffleBlock();
   this.shuffleShape();
 }
Beispiel #2
0
  /** Peliä 1 aikayksikkö eteenpäin */
  public void step() {
    if (!config.running) {
      return;
    }
    ilmoittaja.tick();

    if (pistelaskuri.getScore() - scoreCounter > config.scoreToLevel) {
      scoreCounter += config.scoreToLevel;
      config.scoreToLevel *= config.multiplierGrowX;
      pistelaskuri.multiplier *= config.multiplierGrowX;
      config.level++;
      if (config.waitFor > 0) {
        config.waitFor -= config.gameHardensBy;
      }
    }

    if (!board.onkoLiikkuvia()) {
      boolean[] taydetRivit = new boolean[korkeus];
      for (int j = 0; j < korkeus; j++) {
        taydetRivit[j] = board.riviOnTaysi(j);
        if (taydetRivit[j]) {
          ilmoittaja.ilmoita("OHYEAUGOTRIVI#" + j, 15);
          pistelaskuri.add(config.scoreFromRow);
          board.tyhjennaRivi(j);
          if (config.clearingMakesMovables) board.teeRivitLiikkuviksi(j);
        }
      }
      for (int j = korkeus - 1; j >= 0; j--) {
        if (taydetRivit[j] && !config.clearingMakesMovables) {
          board.poistaRivi(j);
        }
      }
    }

    if (board.onkoLiikkuvia()) {
      if (cycle < config.waitFor) {
        cycle++;
      } else {
        cycle = 0;
      }
      if (cycle == 0 && !board.shiftBlocks(config.gravShift)) {
        if (config.fallPast) {
          board.pysaytaRivi(config.lowestRow);
          board.recursingUnMover();
          cycle = -1;
        } else {
          board.pysaytaKaikki();
        }
      }
    } else {
      if (!board.lisaaMuoto(nextBlockShape, config.nextBlockX, config.nextBlockY, nextBlockType)) {
        // jos uusi muoto ei mahdu, seuraa häviö
        config.running = false;
        config.gamelost = true;
        return;
      }
      this.shuffleBlock();
      this.shuffleShape();
      if (config.ghostshapes) {
        board.clearGhosts();
        board.lisaaHaamuMuoto(nextBlockShape, config.nextBlockX, config.nextBlockY);
      }
      miniboard.poistaKaikki();
      miniboard.lisaaMuoto(
          nextBlockShape, miniboard.getLeveys() - 1, miniboard.getKorkeus() - 1, nextBlockType);
      pistelaskuri.add(config.scoreFromBlock);
    }
  }
Beispiel #3
0
 public void stop() {
   if (config.canStopMidFlight) {
     board.pysaytaKaikki();
   }
 }
Beispiel #4
0
 public void flip() {
   board.flipBlock();
 }
Beispiel #5
0
 public void down() {
   if (!board.shiftBlocks(config.downShift)) {
     cycle = -1;
   }
 }
Beispiel #6
0
 public void up() {
   board.shiftBlocks(config.upShift);
 }
Beispiel #7
0
 public void right() {
   boolean foo = board.shiftBlocks(config.rightShift);
   if (foo && config.gliding) {
     glide();
   }
 }