scg/ch01/MeteorShower

From FANG

Jump to: navigation, search

01 package scg.ch01;
02 
03 import scg.ch01.spacesprites.*; // get all space sprites
04 import fang2.core.Game;
05 
06 /** Asteroids-clone game */
07 public class MeteorShower
08   extends Game {
09   private Ship playersShip; // Ship = component type for game
10   private Meteor rockA; // Meteor = component type for game
11   private Meteor rockB; // Meteor = component type for game
12   private Meteor rockC; // Meteor = component type for game
13 
14   //Called (automatically) by FANG before the game starts 
15   @Override
16   public void setup() {
17     playersShip = new Ship(this)// get new component from system
18     playersShip.setLocation(0.20.8)// id.command(parameters) 
19     // what to shoot, what to run into 
20     playersShip.setTarget(Meteor.class);
21     playersShip.addCollision(Meteor.class);
22     // show the score and remaining life counter 
23     playersShip.showLives();
24     playersShip.showScore();
25     addSprite(playersShip)// add ship to game
26 
27     rockA = new Meteor(this4)// get new component
28     rockA.setLocation(0.80.2)// position 
29     addSprite(rockA)// add rock to game    
30 
31     rockB = new Meteor(this2)// get new component
32     rockB.setColor(getColor("yellow"));
33     rockB.setLocation(0.20.2)// position 
34     addSprite(rockB)// add rock to game    
35 
36     rockC = new Meteor(this)// get new component
37     rockC.setColor(getColor("misty rose"));
38     rockC.setLocation(0.80.8)// position 
39     addSprite(rockC)// add rock to game    
40   }
41 }
42 
43 //Uploaded on Mon Mar 29 21:40:48 EDT 2010


Download/View scg/ch01/MeteorShower.java





Views
Personal tools
Add to 
del.icio.usAdd to 
diggAdd to 
FacebookAdd to 
favoritesAdd to 
GoogleAdd to 
MySpaceAdd to 
PrintAdd to 
SlashdotAdd to 
StumbleUponAdd to 
Twitter

Games
Games