#include <thing.h>
Inheritance diagram for CThing::
Constructors/destructors | |
CThing () | |
Constructor. | |
CThing (int x, int y, int xsmall, bool bxsmall) | |
Constructor. | |
virtual | ~CThing () |
Destructor. | |
Overridables | |
virtual int | Tick () |
Called per frame to update this thing. Returning THING_DIE indicates that this "thing" should be deleted from the world. | |
virtual void | Draw () |
Called to draw this thing. Note that this does not get called if thing does not get drawn (i.e. if clipped out of visible viewport). Use Tick() for updating things that must be updated each frame. | |
virtual int | Action () |
Called when the user presses the action key while within the "action area" (bounds) of the thing. This function should return to the game information on what action to perform. This function *may* be superceded by the one below it. | |
virtual void | HeroEnter () |
Called when the hero enters the bounds of this thing. Derived implementations should call parent implementation. | |
virtual void | HeroLeave () |
Called when the hero leaves the bounds of this thing. Derived implementations should call parent implementation. | |
virtual int | HeroOverlaps () |
Called each frame that hero is touching the action box. | |
virtual void | Initialize (int b0, int b1) |
Called just before added to world, to be used for custom initialization. May supercede OnAdded. (fixme). | |
virtual void | OnAdded () |
Called when thing is first added to world. Can be used for initialisation. | |
virtual int | OnHeroShot () |
Called when thing is shot by hero. m_bShootable must be set. | |
virtual bool | OnInventoryClear () |
Called on an object in the inventory when inventory is cleared at end of level. Return false if object should remain in inventory (e.g. objects that persist throughout the game such as powerboots, as opposed to objects that disappear after each level, such as keys). | |
virtual void | DrawActionBounds (const djColor &Color) |
Draw action bounds. This is purely for debugging/development. | |
bool | m_bHeroInside |
Attributes | |
int | GetTypeID () const |
Return the type ID of this thing. | |
bool | IsShootable () const |
Return true if thing is shootable by hero (i.e. m_bShootable is set). | |
Protected members | |
int | m_iType |
bool | m_bShootable |
Public Methods | |
bool | IsHeroInside () const |
Returns true if hero is currently inside the bounding area of this thing. This function does not physically check, but gets set/unset in HeroEnter() and HeroLeave(). | |
void | SetLocation (int ix, int iy, int xoffset, int yoffset, int width, int height) |
Set position as well as xoffset, yoffset and width, height (????). | |
void | SetPosition (int x, int y) |
Set position of thing. This is in level block units, e.g. on a 128x100 block level. | |
void | SetSprite (int a, int b) |
Set main spriteset and sprite index for graphics. | |
void | SetActionBounds (int x1, int y1, int x2, int y2) |
Set action bounding area. This is in pixels, relative to object position in world (e.g. 0,0,15,15 is one level block). | |
void | SetSolidBounds (int x1, int y1, int x2, int y2) |
Set area which is solid. This is in pixels, relative to object position in world (e.g. 0,0,15,15 is one level block). | |
void | SetShootBounds (int x1, int y1, int x2, int y2) |
Set area which is shootable. This is in pixels, relative to object position in world (e.g. 0,0,15,15 is one level block). | |
void | SetVisibleBounds (int x1, int y1, int x2, int y2) |
Set area which is drawn on screen. This is in pixels, relative to object position in world. The default is (0,0,15,15). This is used to clip things to the view when redrawing the screen. | |
bool | IsInView () |
Test if thing is visible (i.e. if visiblebounds are overlapping the view). | |
bool | Falls () |
void | SetID (int i) |
int | ID () |
bool | InBounds (int x, int y) |
Test if hero is completely inside the box. | |
virtual bool | OverlapsBounds (int x, int y) |
Test if hero is at least partially inside the box. By default this just uses the action bounds; override this for things that have irregular shapes that cannot be described by a single rectangle. | |
bool | OverlapsBounds (int x1, int y1, int x2, int y2) |
Test if given rectangle (in pixel coordinates) overlaps action rectangle (fixme, make virtual). | |
bool | OverlapsShootArea (int x1, int y1, int x2, int y2) |
Test if given rectangle (in pixel coordinates) overlaps shoot rectangle. | |
EdjLayer | Layer () |
int | Width () |
int | Height () |
int | OffsetX () |
int | OffsetY () |
void | SetType (int iType) |
void | SetLayer (EdjLayer l) |
Public Attributes | |
int | m_a |
int | m_b |
int | m_x |
int | m_y |
int | m_xsmall |
bool | m_bxsmall |
bool | m_bFalls |
bool | m_bSolid |
int | m_iSolidX1 |
int | m_iSolidY1 |
int | m_iSolidX2 |
int | m_iSolidY2 |
int | m_iShootX1 |
int | m_iShootY1 |
int | m_iShootX2 |
int | m_iShootY2 |
int | m_iID |
int | m_xoffset |
int | m_yoffset |
int | m_width |
int | m_height |
int | m_iActionX1 |
int | m_iActionY1 |
int | m_iActionX2 |
int | m_iActionY2 |
EdjLayer | m_eLayer |
int | m_iVisibleX1 |
int | m_iVisibleY1 |
int | m_iVisibleX2 |
int | m_iVisibleY2 |
Some collectables and other stuff are not derived from this, but are hardcoded in the game. This is simply because its old C code that still needs to be converted to use this stuff.
A CThing has bounds, which should indicate the "action area", which is the area in the level in which the thing "has effect". Note that this need not be the same as the area which a thing draws itself, for example the action area for the lift is just *above* the lift, as the action is performed when the hero stands on top of the lift. If the hero is within the bounds of the thing and the player presses the action key, the game calls the virtual function Action(), which should return a value indicating the action that should be taken, e.g. the CTeleporter class would return ACTION_TELEPORT.
Pressing 'D' during the game enables the showing of debug information. This will display the action areas of things as yellow boxes. This appears as a single pixel if the action area is not defined (that is, not applicable), e.g. for floating scores. When the hero enters the bounding box, the box turns white.
http://www.scorpioncity.com/djgame.html Copyright (C) David Joffe. Generated: 15 Jul 2001 |