Star Charge

 

Star Charge is a top down 2D Java-based space shooter. I use the project to experiment with implementations for problems that I find interesting or that I have stumbeld upon while working on other projects.

 

While the game itself does not feature much gameplay, besides the ability to travel through the solar system and shoting at asteroids, it contains implementations for a resource management system, GUI-Elements and the position management of GameObjects that I am quite proud of.

Images

Transform

The Transform class is inspired by Unity3Ds Transform class. It contains position, direction and rotation data for the space of the world and for the local space of the parent if it is attached to another Transform.

 

Each StarShip consists out of the the ship and its components. Each component has a Transform which is attached to the Transform of the StarShip, so that each transformation of the position, rotation or direction of the StarShip is automatically applied to all components. Using this layout it is possible to render the apperance of the engine at the position in the image of the StarShip using the local position and creating a projectile at the position of the actual weapon that is firing it, using the global position.

GUIElement

Similar to the Transform, a GUIElement can be attached to another GUIElement. Each change in position of the parent is automatically applied to the children.

 

The structure allows to use GUIElements within other GUIElements. The parent element uses the local position to render the child element and the child element uses the global position the process mouse events.

RessourceArchive

I am always interested in making a game run smoother and more stable. One of the problems is when to load resources and how to manage missing resources. Resources can either be loaded in advance of playing, or during playing.

 

The ResourceArchive loads the information of avaible resource in adavnce to playing but waits with the actual loading of the resource until the resource in required. To ensure that the games runs smoothly while resources are loaded the ResourceArchive provides a ProxyObject that references a standard resource until the required resource is loaded using Threads. It also retuns a reference to a ProxyObject of the same type if the required resource is missing. This allows the game to run smoothly without error while resources are loaded or are missing.

 

In case of the current implementation each graphic that is not loaded or is missing is shown as a element out of pink and black rectangles.

Download

Star Charge - source
StarCharge_0.001.zip
Compressed Archive in ZIP Format 2.8 MB