home *** CD-ROM | disk | FTP | other *** search
- import java.awt.Button;
- import java.awt.Container;
- import java.awt.Event;
- import java.awt.FlowLayout;
- import java.awt.Panel;
-
- class Controls extends Panel {
- MissileCommando parent;
- Button playButton;
- Button suspendButton;
- Button soundButton;
-
- public Controls(MissileCommando var1) {
- this.parent = var1;
- ((Container)this).setLayout(new FlowLayout());
- this.playButton = new Button("Start");
- this.suspendButton = new Button("Suspend");
- this.soundButton = new Button("Sound Off");
- ((Container)this).add(this.playButton);
- ((Container)this).add(this.suspendButton);
- ((Container)this).add(this.soundButton);
- }
-
- public boolean action(Event var1, Object var2) {
- if (var1.target instanceof Button) {
- if ("Start".equals(var2)) {
- if (!this.parent.playing) {
- this.parent.startGame();
- this.playButton.setLabel("Quit");
- }
- } else if ("Quit".equals(var2)) {
- if (this.parent.playing) {
- this.parent.quitGame();
- this.playButton.setLabel("Start");
- }
- } else if ("Suspend".equals(var2)) {
- if (this.parent.playing) {
- this.parent.suspendGame();
- this.suspendButton.setLabel("Resume");
- }
- } else if ("Resume".equals(var2)) {
- if (this.parent.paused) {
- this.parent.resumeGame();
- this.suspendButton.setLabel("Suspend");
- }
- } else if ("Sound Off".equals(var2)) {
- this.parent.disableSound();
- this.soundButton.setLabel("Sound On");
- } else if ("Sound On".equals(var2)) {
- this.parent.enableSound();
- this.soundButton.setLabel("Sound Off");
- }
-
- return true;
- } else {
- return false;
- }
- }
- }
-