#include <qafRoom.h>
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.
Public Member Functions | |
int | getPixelWidth () |
| |
int | getPixelHeight () |
| |
int | getScreenPixelWidth () |
| |
int | getScreenPixelHeight () |
| |
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< ObstacleBlock > | obstacleLayer |
The room's obstacle matrix. | |
Friends | |
class | Environment |
bool qaf::Room::pointCollision | ( | float | x, | |
float | y | |||
) |
Tests the collision of a single point against the obstacle layer.
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.
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.
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 Container
s will be emptied by invoking their removeAll()
method before any parameters are inserted.
const int qaf::Room::blockSize |
This room's obstacle block size, in pixels.
The room's background layers; the frontmost layer is stored at index 0.
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.
The room's obstacle matrix.
Each cell represents a "block."