Navigation

News

Theory and documentation

Version history and plans

Screenshots

Download

About


Javadoc

SourceForge homepage

SourceForge.net Logo

Last updated: 2004-02-27

The object/item framework

    Status: Beta
    Introduced in: 0.0
    Refactorings: 2
    Developed by: Treefinger
    Latest iteration in: 0.2
    Latest iteration by: Treefinger

Overview

The object/item hierarchy work in two layers. The first layer is the object hierarchy, containing basic functionality for graphics and movement. The second layer defines items and flyweights for using these.

The object hierarchy

The object hierarchy is only composed of two general classes:

  • GraphicalObject
    The graphical object is the mother of all graphical objects in the game. Each object can have (but is not bound to have) an associated Sprite. All objects also has a weight and a dimension. This allows for some "physics" to be declared for all objects.
  • MoveableGraphicalObject
    The Moveable graphical object is simly an object with the added functionality to allow moves and actions. It has a location, a facing and a heading. This object is also responsible for updating its own position. This is to allow for different movement schemes (how a car moves in contrast to how a character moves).

The item hierarchy

The item hierarchy is somewhat special, it contains "general" objects and then specialized "flyweights". This is because one can divide items into "classes" and then just make minor adjustments to this "class" to gain a specific item. Thus, a general class defines all common attributes for an item; graphics, name, description, attributes etc. The Item and respectively the Clothes class are instantiations of this class of item in the world. An item can also be a container and then contain other items.

  • GeneralItem
    Defines combat attributes and container attributes. Each instance of this class denotes not just an item, but a class of items. For example: short swords, lamps, etc...
  • GeneralClothes
    This is a class of items that someone can wear if they have certain body parts. This includes armour. For example: Trousers, chainmail, etc...
  • Item
    An instance of a class of items.
  • Clothes
    An instance of a class of items that can be worn.
  • Containing
    An interface to define that this class can contain something else.
  • Container
    A convenience class that keeps track of weight and volume of an item that can contain something else. Only items that are defined in the general class contains a container class.