qaf::Room Class Reference

#include <qafRoom.h>

List of all members.


Detailed Description

Represents the game's static environment -- obstacles and backgrounds.

Room sizes are measured in "screens" (one screen corresponds to the game window's dimensions).

The best way to undertands a Room's attributes is to use Qaf's Room Editor.

See also:
Environment::loadRoom()


Public Member Functions

int getPixelWidth ()
 
Returns:
This room's width, in pixels.

int getPixelHeight ()
 
Returns:
This room's height, in pixels.

int getScreenPixelWidth ()
 
Returns:
The width of one screen in this room, in pixels.

int getScreenPixelHeight ()
 
Returns:
The height of one screen in this room, in pixels.

bool pointCollision (float x, float y)
 Tests the collision of a single point against the obstacle layer.
bool pointCollision (float x1, float y1, float x2, float y2, bool touchThinFloor, Vector2D *contact, Vector2D *normal)
 Tests the collision of a moving point against the obstacle layer.
bool segmentCollision (float x1, float y1, float x2, float y2, bool touchThinFloor)
 Tests the collision of a static segment against the obstacle layer.
bool segmentCollision (float x1, float y1, float x2, float y2, float dx, float dy, bool touchThinFloor, Container< Vector2D > *contacts, Container< Vector2D > *normals, Vector2D *validDisplacement)
 Tests the collision of a moving segment against the obstacle layer.

Public Attributes

const int blockSize
 This room's obstacle block size, in pixels.
const int screenWidth
 This room's screen size, in "blocks.".
const int screenHeight
const int roomWidth
 This room's size, in "screens.".
const int roomHeight
Container< BGLayer * > bgLayers
 The room's background layers; the frontmost layer is stored at index 0.
int waterLevel
 The room's water level, measured in pixels from the room's top.
const int defaultObjLayer
 The default layer where objects are inserted upon creation.
Matrix< ObstacleBlockobstacleLayer
 The room's obstacle matrix.

Friends

class Environment


Member Function Documentation

bool qaf::Room::pointCollision ( float  x,
float  y 
)

Tests the collision of a single point against the obstacle layer.

Returns:
true if the specified point is colliding against the obstacle layer. The collision of a single point against "thin floors" is undefined, and therefore is not detected by this method.

bool qaf::Room::pointCollision ( float  x1,
float  y1,
float  x2,
float  y2,
bool  touchThinFloor,
Vector2D contact,
Vector2D normal 
)

Tests the collision of a moving point against the obstacle layer.

Thus, (x1, y1) is the point's previous position, and (x2, y2) is the point's current position.

If a collision is detected between point1 and point2, its parameters will be stored in the pointers contact (representing where the point touched the obstacle layer) and normal (a unit vector pointing away from the collision surface).

If touchThinFloor is false, thin floors will be ignored.

Returns:
true if a collision occurred between point1 and point2.

bool qaf::Room::segmentCollision ( float  x1,
float  y1,
float  x2,
float  y2,
bool  touchThinFloor 
)

Tests the collision of a static segment against the obstacle layer.

The touchThinFloor parameter indicates whether "thin-floor" blocks should be tested.

Returns:
true If the segment is colliding is touching the obstacle layer.

bool qaf::Room::segmentCollision ( float  x1,
float  y1,
float  x2,
float  y2,
float  dx,
float  dy,
bool  touchThinFloor,
Container< Vector2D > *  contacts,
Container< Vector2D > *  normals,
Vector2D validDisplacement 
)

Tests the collision of a moving segment against the obstacle layer.

The segment is specified by the pair of points ((x1, y1), (x2, y2)), and is considered to have moved in the direction of the vector defined by (dx, dy).

If touchThinFloor is false, any collisions against "thin floors" will be ignored.

Should a collision be detected in the movement, several parameters are "returned" in the pointers:

Any of those may be NULL, indicating there is no need to store it. (All of them will be calculated, however, as this is needed for the method's execution.)

The Containers will be emptied by invoking their removeAll() method before any parameters are inserted.

Returns:
true if a collision was detected.


Member Data Documentation

const int qaf::Room::blockSize

This room's obstacle block size, in pixels.

Container<BGLayer *> qaf::Room::bgLayers

The room's background layers; the frontmost layer is stored at index 0.

int qaf::Room::waterLevel

The room's water level, measured in pixels from the room's top.

A water level greater than the room's pixel height indicates no water at all; a negative water level indicates the entire room is filled with water.

const int qaf::Room::defaultObjLayer

The default layer where objects are inserted upon creation.

Index 0 indicates they will be inserted in front of BG layer 0, and so on.

Matrix<ObstacleBlock> qaf::Room::obstacleLayer

The room's obstacle matrix.

Each cell represents a "block."


The documentation for this class was generated from the following file:
Generated on Sun Mar 25 12:32:14 2007 for Qaf Framework by  doxygen 1.5.1-p1