Exemple #1
0
  /** Initialize the game */
  public void run() {

    // Get ready
    getReady();
    vx = 0;
    vy = 0;
    num_brick_left = NUM_BRICK_ROW * NUM_BRICK_COL;

    // Add label at the bottom
    mylabel = new GLabel("Developed by Teng Zhong");
    add(mylabel, (getWidth() - mylabel.getWidth()) / 2, (getHeight() - 300));

    // Start game playing
    while (!gameover()) {
      moveBall();
      checkRebounce();
      pause(DELAY);
    }

    // When game is over
    remove(ball);
    GLabel lab = new GLabel("Game Over!");
    lab.setFont("SansSerif-28");
    lab.setColor(Color.RED);
    add(lab, (getWidth() - lab.getWidth()) / 2, (getHeight() - lab.getHeight()) / 2);
  }
Exemple #2
0
 public void mouseMoved(MouseEvent e) {
   if (label != null) remove(label);
   label = new GLabel("X: " + e.getX() + " Y: " + e.getY());
   add(label, (getWidth() - label.getWidth()) / 2, (getHeight() - label.getHeight()) / 2);
 }