Ejemplo n.º 1
0
  // keeps track of time, and calls methods that need to be called every drop
  public static void timeKeeping() {
    // random place stuff
    int rantime = 0;
    // the startTime helps keep track of how much time has passed since the loop started, which
    // keeps the computer's performance from effecting game speed
    long startTime = System.currentTimeMillis();
    Main.display.repaint();
    sleep(startTime);

    // a loop that calls methods after every drop
    while (Main.gameOn) {
      startTime = System.currentTimeMillis();

      Physics.clearLineCheck();
      Physics.dropCall();
      Square.neighborFindCall();
      Main.display.repaint();

      sleep(startTime);

      // random place stuff
      rantime++;
      if (rantime > 3) {
        Square.randomPlace();
        rantime = 0;
      }
    }
  }