예제 #1
0
 private void addButtons(Hud frame) {
   int buttonWidth = 8;
   int buttonHeight = 4;
   int buttonY =
       FRAME_HEIGHT * FRAME_SIZE * HudButton.SIZE
           - (buttonHeight * FRAME_SIZE + 4 * FRAME_SIZE) * HudBox.SIZE;
   int buttonX =
       FRAME_WIDTH * FRAME_SIZE * HudButton.SIZE
           - (buttonWidth * FRAME_SIZE + 1 * FRAME_SIZE) * HudBox.SIZE;
   btnCancel = new HudButton(buttonX, buttonY, buttonWidth, buttonHeight, "Back", FRAME_SIZE);
   btnCancel.setAction(
       new HudAction() {
         public void actionPerformed(HudComponent comp) {
           status = CANCELING;
         }
       });
   frame.add(btnCancel);
   btnGo =
       new HudButton(
           buttonX - buttonWidth * FRAME_SIZE * 4 - 1 * FRAME_SIZE * 4,
           buttonY,
           buttonWidth,
           buttonHeight,
           "Go",
           FRAME_SIZE);
   btnGo.setAction(
       new HudAction() {
         public void actionPerformed(HudComponent comp) {}
       });
   frame.add(btnGo);
 }
예제 #2
0
 public void update() {
   if (status == ENTERING) {
     overlayAlpha += (int) alphaStep;
     y -= (int) yStep;
     if (overlayAlpha >= MAX_OVERLAY_APLHA || y <= FRAME_Y) {
       overlayAlpha = MAX_OVERLAY_APLHA;
       y = FRAME_Y;
       status = DONE_ENTERING;
     }
     overlayColor = new Color(0, 0, 0, overlayAlpha);
   } else if (status == DONE_ENTERING) {
     status = WAITING;
   } else if (status == CANCELING) {
     overlayAlpha -= (int) alphaStep;
     y += (int) yStep;
     if (overlayAlpha <= 0 || y >= References.HEIGHT) {
       overlayAlpha = 0;
       y = References.HEIGHT;
       status = CANCELED;
     }
     overlayColor = new Color(0, 0, 0, overlayAlpha);
   } else if (status == CANCELED) {
     gsm.set(lastState);
   }
   frame.setPosition(x, y);
   frame.update();
 }
예제 #3
0
 public NewGameState(GameStateManager gsm, GameState lastState) {
   super(gsm);
   this.lastState = lastState;
   frame = new Hud();
   overlayColor = new Color(0, 0, 0, 0);
   x = FRAME_X;
   y = References.HEIGHT;
   bgBox = new HudBox(0, 0, FRAME_WIDTH, FRAME_HEIGHT + 1, FRAME_SIZE);
   frame.add(bgBox);
   lblTitle = new HudLabel("NEW GAME", 2 * FRAME_SIZE, 3 * FRAME_SIZE, FRAME_SIZE);
   frame.add(lblTitle);
   addButtons(frame);
   txtInName = new HudTextInput(2 * FRAME_SIZE, 12 * FRAME_SIZE, 20, "", FRAME_SIZE);
   frame.add(txtInName);
   dlDiffuculty =
       new HudDropList(
           2 * FRAME_SIZE, 14 * FRAME_SIZE + txtInName.getHeight() * FRAME_SIZE, 30, FRAME_SIZE);
   dlDiffuculty.setList(Difficulty.values());
   frame.add(dlDiffuculty);
 }
예제 #4
0
 public void handleInput(InputHandler input) {
   frame.handleInput(input);
 }
예제 #5
0
 public void draw(Graphics2D g) {
   lastState.draw(g);
   g.setColor(overlayColor);
   g.fillRect(0, 0, References.WIDTH, References.HEIGHT);
   frame.draw(g);
 }