home *** CD-ROM | disk | FTP | other *** search
- import com.next.gt.BonusHandler;
- import com.next.gt.Gamelication;
- import com.next.gt.ImageManager;
- import com.next.gt.ScoreManager;
- import com.next.gt.WindowDestroyer;
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.Frame;
- import java.awt.Label;
- import java.awt.Rectangle;
- import java.awt.Window;
- import java.awt.event.KeyEvent;
- import java.awt.event.KeyListener;
-
- public class Boinkaroids extends Gamelication implements BonusHandler, KeyListener {
- public Ship player;
- public int numShips;
- private int badGuyCount;
- public int level;
- public boolean createNewPlayer = true;
- private Label myLabel;
- private int SAFETY_ZONE_WIDTH = 128;
- private int SAFETY_ZONE_HEIGHT = 128;
-
- public void init() {
- super.init(500, 400, "./");
- Frame var1 = new Frame("Boinkaroids");
- ((Component)var1).setSize(500, 500);
- this.myLabel = new Label("Score: 00000000 Ships: " + this.numShips + " Level: " + this.level);
- ((Container)var1).add("South", this.myLabel);
- ((Container)var1).add("Center", this);
- ((Window)var1).addWindowListener(new WindowDestroyer(var1, this));
- var1.setResizable(false);
- super.scoreManager = new ScoreManager();
- super.scoreManager.registerForBonusNotification(this, 20000);
- ((Window)var1).show();
- new ImageManager(this);
- this.myLabel.addKeyListener(this);
- this.newGame();
- super.displayManager.setBackgroundTile(((Gamelication)this).getImage(((Gamelication)this).getCodeBase(), "images/background.gif"));
- ((Gamelication)this).start();
- ((Gamelication)this).run();
- }
-
- public void newGame() {
- super.scoreManager.setScore(0);
- this.numShips = 3;
- this.badGuyCount = 0;
- this.level = 0;
- this.removePlayer();
- super.actorManager.removeAllActors();
- this.createActors();
- }
-
- public void newLevel() {
- ++this.level;
- super.actorManager.removeAllActors();
- this.createActors();
- }
-
- public void createActors() {
- for(int var1 = 0; var1 < 2 * this.level; ++var1) {
- super.actorManager.addActor(new Asteroid(this, (Asteroid)null, "gumball", 2));
- this.addOneBadGuy();
- }
-
- for(int var2 = 0; (double)var2 < (double)0.5F * (double)this.level; ++var2) {
- super.actorManager.addActor(new Bigoobie(this));
- this.addOneBadGuy();
- }
-
- this.createPlayer();
- }
-
- public void removeOneBadGuy() {
- --this.badGuyCount;
- }
-
- public void addOneBadGuy() {
- ++this.badGuyCount;
- }
-
- public void createPlayer() {
- this.removePlayer();
- this.player = new Ship(this);
- this.myLabel.addKeyListener(this.player);
- super.actorManager.addActor(this.player);
- this.createNewPlayer = false;
- }
-
- public void removePlayer() {
- if (this.player != null) {
- super.actorManager.removeActor(this.player);
- this.myLabel.removeKeyListener(this.player);
- this.player = null;
- }
-
- }
-
- public void tick() {
- super.tick();
- this.myLabel.setText("Score: " + super.scoreManager.score + " Ships: " + this.numShips + " Level: " + this.level);
- if (this.badGuyCount <= 0) {
- this.newLevel();
- }
-
- if (this.createNewPlayer) {
- Rectangle var1 = new Rectangle(((Component)this).getSize().width / 2 - this.SAFETY_ZONE_WIDTH / 2, ((Component)this).getSize().height / 2 - this.SAFETY_ZONE_HEIGHT / 2, this.SAFETY_ZONE_WIDTH, this.SAFETY_ZONE_HEIGHT);
- if (!super.actorManager.isActorIn(var1)) {
- this.createNewPlayer = false;
- this.createPlayer();
- }
- }
-
- }
-
- public void keyPressed(KeyEvent var1) {
- if (var1.getKeyCode() == 112) {
- this.newGame();
- }
-
- }
-
- public void keyReleased(KeyEvent var1) {
- }
-
- public void keyTyped(KeyEvent var1) {
- }
-
- public void didAchieveBonus() {
- ++this.numShips;
- }
-
- public void decrementShipCount() {
- if (this.numShips-- > 0) {
- this.createNewPlayer = true;
- this.removePlayer();
- }
-
- }
-
- public static void main(String[] var0) {
- Boinkaroids var1 = new Boinkaroids();
- var1.init();
- }
- }
-