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.

SpaceOddysy: Chapter 1

Now that we have decided the way our game looks, we need to design and make the major coding decisions.

A 2-d game like ours is based on sprites. A sprite is some object of the game visible on the screen. BTW the game uses polymorphism heavily. So if you have any problems with that, it might be a good time to review it. So we need to implement the sprite class. In fact, I have broken up the sprite class in two parts. A sprite is something which has a position and can be drawn. Corresponding to them, we have two interfaces.
1. Artifact and 2. Drawable
Any thing in the game which has a position must implement Artifact and anything which wants to be drawn must implement Drawable.

This is what Artifact.java basically is.
public interface Artifact {
int size=5;
public int getSize();
public abstract double getXPos();
public abstract void setXPos(double pos);
public abstract double getYPos();
public Point2D getCentre();
public abstract void setYPos(double pos);
public boolean isAlive();
public void setAlive(boolean a);
public boolean collision(Artifact a);
}

And Drawable just has one method
public interface Drawable {
public void draw(Graphics g);//draw itself
}


It also makes sense. A drwable thing just needs to know how to draw Itself on the screen. An artifact must know its postion, centre etc.

Next Chapter>>>>>