home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1997 October / PCO1097.ISO / FilesBBS / FREI / MCII.EXE / Controls.class (.txt) < prev    next >
Encoding:
Java Class File  |  1996-10-03  |  1.6 KB  |  60 lines

  1. import java.awt.Button;
  2. import java.awt.Container;
  3. import java.awt.Event;
  4. import java.awt.FlowLayout;
  5. import java.awt.Panel;
  6.  
  7. class Controls extends Panel {
  8.    MissileCommando parent;
  9.    Button playButton;
  10.    Button suspendButton;
  11.    Button soundButton;
  12.  
  13.    public Controls(MissileCommando var1) {
  14.       this.parent = var1;
  15.       ((Container)this).setLayout(new FlowLayout());
  16.       this.playButton = new Button("Start");
  17.       this.suspendButton = new Button("Suspend");
  18.       this.soundButton = new Button("Sound Off");
  19.       ((Container)this).add(this.playButton);
  20.       ((Container)this).add(this.suspendButton);
  21.       ((Container)this).add(this.soundButton);
  22.    }
  23.  
  24.    public boolean action(Event var1, Object var2) {
  25.       if (var1.target instanceof Button) {
  26.          if ("Start".equals(var2)) {
  27.             if (!this.parent.playing) {
  28.                this.parent.startGame();
  29.                this.playButton.setLabel("Quit");
  30.             }
  31.          } else if ("Quit".equals(var2)) {
  32.             if (this.parent.playing) {
  33.                this.parent.quitGame();
  34.                this.playButton.setLabel("Start");
  35.             }
  36.          } else if ("Suspend".equals(var2)) {
  37.             if (this.parent.playing) {
  38.                this.parent.suspendGame();
  39.                this.suspendButton.setLabel("Resume");
  40.             }
  41.          } else if ("Resume".equals(var2)) {
  42.             if (this.parent.paused) {
  43.                this.parent.resumeGame();
  44.                this.suspendButton.setLabel("Suspend");
  45.             }
  46.          } else if ("Sound Off".equals(var2)) {
  47.             this.parent.disableSound();
  48.             this.soundButton.setLabel("Sound On");
  49.          } else if ("Sound On".equals(var2)) {
  50.             this.parent.enableSound();
  51.             this.soundButton.setLabel("Sound Off");
  52.          }
  53.  
  54.          return true;
  55.       } else {
  56.          return false;
  57.       }
  58.    }
  59. }
  60.