home *** CD-ROM | disk | FTP | other *** search
- head 1.11;
- access;
- symbols;
- locks; strict;
- comment @# @;
-
-
- 1.11
- date 98.04.22.19.59.10; author mds1274; state Exp;
- branches;
- next 1.10;
-
- 1.10
- date 98.04.20.21.19.54; author mds1274; state Exp;
- branches;
- next 1.9;
-
- 1.9
- date 98.04.19.17.36.50; author mds1274; state Exp;
- branches;
- next 1.8;
-
- 1.8
- date 98.04.15.16.04.47; author mds1274; state Exp;
- branches;
- next 1.7;
-
- 1.7
- date 98.04.15.15.57.57; author mds1274; state Exp;
- branches;
- next 1.6;
-
- 1.6
- date 98.04.15.15.34.20; author mds1274; state Exp;
- branches;
- next 1.5;
-
- 1.5
- date 98.04.15.15.32.57; author mds1274; state Exp;
- branches;
- next 1.4;
-
- 1.4
- date 98.04.14.16.33.47; author jgh8962; state Exp;
- branches;
- next 1.3;
-
- 1.3
- date 98.04.11.16.20.09; author jgh8962; state Exp;
- branches;
- next 1.2;
-
- 1.2
- date 98.04.10.18.25.57; author jgh8962; state Exp;
- branches;
- next 1.1;
-
- 1.1
- date 98.04.10.17.53.49; author jgh8962; state Exp;
- branches;
- next ;
-
-
- desc
- @@
-
-
- 1.11
- log
- @*** empty log message ***
- @
- text
- @/**
- *
- * Boinkaroids.java
- * @@author Mark G. Tacchi (mtacchi@@next.com)
- * @@version 0.8
- * Mar 27/1996
- *
- * Boinkaroids is an Asteroids type game developed for the purpose of showing
- * off the Gamelet Toolkit. It makes use of all of the features within the
- * Gamelet Toolkit.
- *
- */
-
- import java.awt.*;
- import java.io.*;
- import java.awt.event.*;
- import java.util.*;
-
- import com.next.gt.*;
-
- public class Boinkaroids extends Gamelication implements BonusHandler, KeyListener{
-
- //
- // Boinkaroids variables
- //
- public Ship player = null;
- public int numShips;
- private int badGuyCount;
- public int level;
-
- //
- // Should a player be created?
- //
- public boolean createNewPlayer = true;
-
- //
- // Score label.
- //
- private Label myLabel;
-
- //
- // This area that has to be clear for a ship to enter level.
- //
- private int SAFETY_ZONE_WIDTH= 128;
- private int SAFETY_ZONE_HEIGHT= 128;
-
-
- /**
- * Initialize.
- */
- public void init(int x, int y) {
- super.init( x, y, "./" );
- myLabel= new Label("Score: 00000000" + " Ships: " + numShips
- + " Level: "+ level);
- //f.add("South",myLabel);
-
-
- //
- // initialize the score manager
- //
- scoreManager= new ScoreManager();
- scoreManager.registerForBonusNotification(this, 20000);
-
-
- //
- // show the main window
- //
-
- //
- // cache images
- //
- new ImageManager(this);
-
- addKeyListener( this );
-
- this.newGame();
- //
- // paint background image
- //
- displayManager.setBackgroundTile (getImage(getCodeBase(), "images/background.gif"));
-
- start();
- run();
- } /*init*/
-
-
- /**
- * Set up the new game.
- */
- public void newGame() {
- scoreManager.setScore (0);
- numShips= 3;
- badGuyCount= 0;
- level= 0;
- removePlayer();
- actorManager.removeAllActors();
- this.createActors();
- } /*newGame*/
-
-
- /**
- * Advance levels.
- */
- public void newLevel() {
- level++;
- actorManager.removeAllActors();
- this.createActors();
- } /*newLevel*/
-
-
- /**
- * Create the actors for this scene.
- */
- public void createActors() {
- for (int i= 0; i< 2*level; i++) {
- actorManager.addActor (new Asteroid(this, null, "gumball",
- Asteroid.LARGE_SIZE));
- addOneBadGuy();
- } /*nexti*/
- for (int i= 0; i< 0.5*level; i++) {
- actorManager.addActor (new Bigoobie(this));
- addOneBadGuy();
- } /*next_i*/
- this.createPlayer();
- } /*createActors*/
-
- /**
- * Remove one bad guy
- */
- public void removeOneBadGuy(){
- badGuyCount--;
- }
-
- /**
- * Remove one bad guy
- */
- public void addOneBadGuy(){
- badGuyCount++;
- }
-
- /**
- * Create the player object.
- */
- public void createPlayer() {
- removePlayer();
- player = new Ship(this);
- addKeyListener(player);
- actorManager.addActor (player);
- createNewPlayer = false;
- } /*createPlayer*/
-
-
- /**
- * Remove the player object.
- */
- public void removePlayer() {
- if (player!=null) {
- actorManager.removeActor(player);
- removeKeyListener( player );
- player = null;
- } /*endif*/
- } /*createPlayer*/
-
-
- /**
- * Override tick to test for specific game events.
- */
- public void tick() {
- super.tick();
- myLabel.setText("Score: " + scoreManager.score + " Ships: " + numShips
- + " Level: "+ level );
-
- if (badGuyCount <= 0)
- this.newLevel();
-
- if (createNewPlayer) {
- Rectangle myRectangle= new Rectangle((int)this.getSize().width/2 - SAFETY_ZONE_WIDTH/2,
- (int)this.getSize().height/2 - SAFETY_ZONE_HEIGHT/2,
- SAFETY_ZONE_WIDTH,
- SAFETY_ZONE_HEIGHT);
- if (!actorManager.isActorIn(myRectangle)) {
- createNewPlayer = false;
- this.createPlayer();
- } /*endif*/
- } /*endif*/
- } /*tick*/
-
-
- /**
- * Handle keyboard events that control ship.
- */
- public void keyPressed( KeyEvent k ){
- if(k.getKeyCode() == k.VK_F1 )
- this.newGame();
- }
-
- public void keyReleased( KeyEvent k ){
- }
-
- public void keyTyped( KeyEvent k ){
- }
-
-
- /**
- * Give bonus ship for getting a certain score.
- */
- public void didAchieveBonus() {
- numShips++;
- } /*didAchieveBonus*/
-
-
- /**
- * Player must have died, decrement ship count.
- */
- public void decrementShipCount() {
- if (numShips-- > 0) {
- createNewPlayer= true;
- removePlayer();
- } /*endif*/
- } /*decrementShipCount*/
-
-
- /**
- * Static main to begin the application.
- */
- public static void main( String[] args ) {
- Boinkaroids boinkaroids = new Boinkaroids();
- Frame f = new Frame( "Boinkaroids" );
- f.setSize( 500, 500 );
- f.add( "Center",boinkaroids );
- f.addWindowListener( new WindowDestroyer( f, boinkaroids ) );
- f.setResizable( false );
- f.show();
- boinkaroids.init(500,500);
- }
-
- } /*Boinkaroids*/
- @
-
-
- 1.10
- log
- @*** empty log message ***
- @
- text
- @d51 2
- a52 4
- public void init() {
- super.init( 500, 400, "./" );
- Frame f = new Frame( "Boinkaroids" );
- f.setSize( 500, 500 );
- d55 1
- a55 1
- f.add("South",myLabel);
- a56 3
- f.add( "Center",this );
- f.addWindowListener( new WindowDestroyer( f, this ) );
- f.setResizable( false );
- a67 1
- f.show();
- d74 1
- a74 1
- myLabel.addKeyListener( this );
- d147 1
- a147 1
- myLabel.addKeyListener(player);
- d159 1
- a159 1
- myLabel.removeKeyListener( player );
- d228 7
- a234 1
- boinkaroids.init();
- @
-
-
- 1.9
- log
- @*** empty log message ***
- @
- text
- @d28 1
- a28 1
- public int badGuyCount;
- d124 1
- a124 1
- badGuyCount++;
- d128 1
- a128 1
- badGuyCount++;
- d177 2
- a178 1
- + " Level: "+ level ); if (badGuyCount <= 0)
- d181 1
- a181 1
-
- @
-
-
- 1.8
- log
- @*** empty log message ***
- @
- text
- @d133 6
- d141 7
- @
-
-
- 1.7
- log
- @*** empty log message ***
- @
- text
- @d39 1
- a39 1
- public Label myLabel;
- d140 1
- d152 1
- a152 1
- removeKeyListener( player );
- @
-
-
- 1.6
- log
- @*** empty log message ***
- @
- text
- @d39 1
- a39 1
- private Label myLabel;
- d55 4
- d68 1
- a68 3
- myLabel= new Label("Score: 00000000" + " Ships: " + numShips
- + " Level: "+ level);
- f.add("South",myLabel);
- d80 2
- a81 1
- addKeyListener( this );
- @
-
-
- 1.5
- log
- @*** empty log message ***
- @
- text
- @d66 2
- a67 4
- f.add("South",myLabel);
-
- //
- // show the main window
- d69 9
- a77 7
- f.show();
-
- //
- // cache images
- //
- new ImageManager(this);
-
- d118 2
- a119 2
- for (int i= 0; i< 2*level; i++) {
- actorManager.addActor (new Asteroid(this, null, "gumball",
- a128 1
-
- d130 1
- d137 1
- a137 1
- actorManager.addActor (player);
- a139 1
-
- d141 1
- d147 1
- a147 1
- actorManager.removeActor(player);
- d150 1
- a150 1
- } /*endif*/
- d159 1
- a159 1
- myLabel.setText("Score: " + scoreManager.score + " Ships: " + numShips
- d161 2
- a162 2
- if (badGuyCount <= 0)
- this.newLevel();
- d209 4
- a212 4
-
-
- /**
- * Static main to begin the application.
- d219 1
- a219 1
- } /*Boinkaroids*/
- @
-
-
- 1.4
- log
- @*** empty log message ***
- @
- text
- @d23 7
- a29 7
- //
- // Boinkaroids variables
- //
- public Ship player = null;
- public int numShips;
- public int badGuyCount;
- public int level;
- d31 4
- a34 4
- //
- // Should a player be created?
- //
- public boolean createNewPlayer = true;
- d36 4
- a39 4
- //
- // Score label.
- //
- private Label myLabel;
- d41 5
- a45 5
- //
- // This area that has to be clear for a ship to enter level.
- //
- private int SAFETY_ZONE_WIDTH= 128;
- private int SAFETY_ZONE_HEIGHT= 128;
- d52 6
- a57 7
- super.init( 500, 400, "./" );
- Frame f = new Frame( "Boinkaroids" );
- f.setSize( 500, 500 );
- f.add( this );
- f.addWindowListener( new WindowDestroyer( f, this ) );
- f.setResizable( false );
- f.show();
- d59 25
- a83 19
-
-
- //
- // cache images
- //
- new ImageManager(this);
-
- //
- // initialize the score manager
- //
- scoreManager= new ScoreManager();
- scoreManager.registerForBonusNotification(this, 20000);
-
-
- myLabel= new Label("Score: 00000000" + " Ships: " + numShips
- + " Level: "+ level);
- add("South",myLabel);
-
- this.newGame();
- d85 2
- a86 16
- //
- // register for events
- //
- //eventManager.
- // registerForSingleEventNotification(this,Event.KEY_ACTION_RELEASE);
-
- //
- // paint background image
- //
- displayManager.setBackgroundTile (getImage(getCodeBase(), "images/background.gif"));
-
- //f.addKeyListener( this );
-
- start();
- run();
-
- a89 1
-
- d94 7
- a100 7
- scoreManager.setScore (0);
- numShips= 3;
- badGuyCount= 0;
- level= 0;
- removePlayer();
- actorManager.removeAllActors();
- createNewPlayer = true;
- a103 1
-
- d108 3
- a110 5
- level++;
- actorManager.removeAllActors();
- removePlayer();
- this.createActors();
- createNewPlayer = true;
- d118 10
- a127 8
- for (int i= 0; i< 2*level; i++) {
- actorManager.addActor (new Asteroid(this, null, "gumball", Asteroid.LARGE_SIZE));
- badGuyCount++;
- } /*nexti*/
- for (int i= 0; i< 0.5*level; i++) {
- actorManager.addActor (new Bigoobie(this));
- badGuyCount++;
- } /*next_i*/
- d129 1
- a130 2
-
-
- d135 4
- a138 3
- removePlayer();
- player = new Ship(this);
- actorManager.addActor (player);
- d140 1
- d146 6
- a151 7
- if (player!=null) {
- actorManager.removeActor(player);
- removeKeyListener( player );
- player = null;
- createNewPlayer = false;
- } /*endif*/
- } /*removePlayer*/
- a153 1
-
- d158 5
- a162 1
- super.tick();
- d164 10
- a173 16
- myLabel.setText("Score: " + scoreManager.score + " Ships: " + numShips
- + " Level: "+ level );
-
- if (badGuyCount <= 0) {
- this.newLevel();
- } /*endif*/
- if (createNewPlayer) {
- Rectangle myRectangle= new Rectangle((int)this.getSize().width/2 - SAFETY_ZONE_WIDTH/2,
- (int)this.getSize().height/2 - SAFETY_ZONE_HEIGHT/2,
- SAFETY_ZONE_WIDTH,
- SAFETY_ZONE_HEIGHT);
- if (!actorManager.isActorIn(myRectangle)) {
- createNewPlayer = false;
- this.createPlayer();
- } /*endif*/
- } /*endif*/
- a176 1
-
- a192 9
- * Override paint to display score bar.
- */
- public void paint(Graphics g) {
- super.paint(g);
- } /*paint*/
-
-
-
- /**
- d196 1
- a196 1
- numShips++;
- a199 1
-
- d204 4
- a207 4
- if (numShips-- > 0) {
- removePlayer();
- createNewPlayer= true;
- } /*endif*/
- d209 5
- a213 1
-
- d219 1
- a219 9
- /**
- * Pass the event along to the EventManager for handling.
- */
- //public void processEvent (AWTEvent theEvent) {
- // System.out.println( "Boinkaroids processEvent called." );
- // super.processEvent( theEvent );
- //} /*processEvent*/
-
- } /*Boinkaroids*/
- @
-
-
- 1.3
- log
- @*** empty log message ***
- @
- text
- @d74 3
- a76 3
- //myLabel= new Label("Score: 00000000" + " Ships: " + numShips
- // + " Level: "+ level);
- //f.add("South",myLabel);
- a108 1
- //System.gc()
- d110 1
- a110 2
- this.createActors();
- createNewPlayer = false;
- d121 1
- d123 1
- a138 1
- this.createPlayer();
- a146 1
- System.out.println( "Creating a player." );
- a156 1
- System.out.println( "Removing current player." );
- d160 1
- d162 1
- a162 1
- } /*createPlayer*/
- d170 1
- a170 1
- super.tick();
- d172 3
- a211 2
- //myLabel.setText("Score: " + scoreManager.score + " Ships: " + numShips
- // + " Level: "+ level );
- d230 1
- a231 1
- removePlayer();
- @
-
-
- 1.2
- log
- @Blah.
- @
- text
- @d26 1
- a26 1
- public Ship player;
- d91 1
- a91 1
- f.addKeyListener( this );
- d108 2
- a109 1
- player= null;
- d122 1
- d148 10
- d159 1
- d161 2
- a163 2
- player= new Ship(this);
- actorManager.addActor (player);
- d183 2
- a184 2
- createNewPlayer= false;
- this.createPlayer();
- d231 2
- a232 2
- createNewPlayer= true;
- player= null;
- @
-
-
- 1.1
- log
- @Initial revision
- @
- text
- @d16 1
- a16 1
- //import java.net.*;
- d21 1
- a21 1
- public class Boinkaroids extends Gamelication implements BonusHandler, EventHandler{
- d34 1
- a34 1
- private boolean createNewPlayer;
- a56 1
- f.addKeyListener( new KeyboardInput( this ));
- d83 2
- a84 2
- eventManager.
- registerForSingleEventNotification(this,Event.KEY_ACTION_RELEASE);
- d91 2
- d111 1
- d179 1
- a179 1
- * Handle keyboard events to restart game.
- d181 4
- a184 11
- public boolean handleRequestedEvent (Event theEvent) {
- switch(theEvent.id) {
- case Event.KEY_ACTION_RELEASE:
- switch(theEvent.key) {
- case Event.F1:
- this.newGame();
- return true;
- } /*endSwitch*/
- } /*endSwitch*/
- return false;
- } /*handleRequestedEvent8/
- d186 2
- d189 2
- d192 1
- d231 4
- a234 4
- public void processEvent (AWTEvent theEvent) {
- System.out.println( "Boinkaroids processEvent called." );
- super.processEvent( theEvent );
- } /*processEvent*/
- @
-