View Single Post
  #7   Spotlight this post!  
Unread 03-03-2010, 23:27
Lord_Jeremy's Avatar
Lord_Jeremy Lord_Jeremy is offline
Lord_Jeremy the Procrastinator
AKA: Jeremy Agostino
FRC #1546 (Chaos Inc.)
Team Role: Electrical
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Baldwin, New York
Posts: 45
Lord_Jeremy is an unknown quantity at this point
Send a message via ICQ to Lord_Jeremy Send a message via AIM to Lord_Jeremy Send a message via MSN to Lord_Jeremy Send a message via Yahoo to Lord_Jeremy
Re: How complex is your code?

I actually recently started work on a Java project of my own. I'm attempting to write an RTS game engine from the ground up. Although it's primarily a learning experience, I do intend to bring it to completion. Naturally, I'm fleshing out a beautifully complex inheritance tree, the majority of which is centered around objects.

It all starts with class Dependent, which is the base of all the objects in the game. In the objects package, there are a bunch of interfaces and an abstract class. The interfaces each represent a different functional element. For instance there is an EquipableObject and a MoveableObject and a DamageableObject and etc. They all extend GameObject, which contains some methods common to all objects. There is also the BaseObject abstract class, which extends Dependent and implements a few of the interfaces, containing method implementations generally common to all the types of objects in the game world. At the next level, there is the Unit abstract class, which implements just about all the interfaces and extends BaseObject. This is where most of the actual functionality specific to units gets flushed out. There's also Equipment, Prop, Projectile, and possibly more. They each implement different sets of interfaces. The other half of my tree is the default stats system. It starts with interface Info, which is empty. Then, for each object type interface, there's an object info interface. There's MoveableObjectInfo for MoveableObject and so on. they all extend Info. In each functionality interface (MoveableObject, etc), there's a method GetInfo which returns the Info subtype specific to that interface. Of course, there is the UnitInfo interface, which extends the info interfaces for all the interfaces Unit implements. Then in the Unit class, there is method GetInfo which returns a UnitInfo. Because of the way Java's typing works, that returned UnitInfo can be automatically casted to whatever it needs to be. So if DamageableObjectInfo contains a static float flStartingHP I can do unitInstance.GetInfo().flStartingHP.
__________________
Compiling...
Compiling...
Reply With Quote