Make your own free website on Tripod.com

Java Gaming for the desktop.

SpaceOddysy BIT, Mesra Middle-Earth SCJP Java Gaming Blog My Personal Blog

 !   Space Oddysy: A java shoot-em-up game.

Space Oddysy: Chapter 3

Lets have a look at the Ship class.

public abstract class Ship implements Artifact, Moving,Serializable {
boolean alive;
int value=1;//this value represents how valuable a ship is. Better ships have higher value.

double xPos,yPos;//position
double xSpeed,ySpeed;//speed
double health;//health
double armour;//armour of the ship
double fuel;
boolean right,up;

.......................... (Code continues with getters and setters for these variables).

A ship has postion, speed, direction, health and armour. (Health and armour are not currently used, but lets have them for future). But we donot have enough information to tell about the size of the ship which is required by the Artifact interface. So we have to make the Ship class abstract.

We will subclass the ship to get the different types of ships:
1. HeroShip, the ship the player commands
2. HelperShip, the ships which help the hero
3. EnemyShip, the ships which attack the hero.

Since in our game, the player's ship is only of one type, we donot need to subclass the HeroShip. But the HelperShips and EnemyShips are of various types so we subclass them as needed.

Next Chapter>>>>>