scg/ch01/Meteors

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 Meteors
08   extends Game {
09   private Ship playersShip; // Ship = component type for game
10   private Meteor rock; // Meteor = component type for game
11 
12   //Called (automatically) by FANG before the game starts 
13   @Override
14   public void setup() {
15     playersShip = new Ship(this)// get new component from system
16     playersShip.setColor(getColor("SCG Red"));
17     playersShip.setLocation(0.20.8)// id.command(parameters) 
18     // what to shoot, what to run into 
19     playersShip.setTarget(Meteor.class);
20     playersShip.addCollision(Meteor.class);
21     // show the score and remaining life counter 
22     playersShip.showLives();
23     playersShip.showScore();
24     addSprite(playersShip)// add ship to game
25 
26     rock = new Meteor(this)// get new component
27     rock.setLocation(0.80.8)// position 
28     addSprite(rock)// add rock to game    
29   }
30 }
31 
32 //Uploaded on Mon Mar 29 21:40:22 EDT 2010


Download/View scg/ch01/Meteors.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