qafRoom.h

00001 /* 
00002 ** Qaf Framework 1.2
00003 ** June 2006
00004 ** 
00005 ** Pedro Luchini de Moraes, Public Domain - Free Lunch Code
00006 */
00007 
00008 #ifndef ROOM_H
00009 #define ROOM_H
00010 
00011 #include "qafBGLayer.h"
00012 #include "qafutil/qafContainer.h"
00013 #include "qafutil/qafGeom.h"
00014 #include "qafutil/qafMatrix.h"
00015 
00016 
00017 namespace qaf {
00018     
00023     enum ObstacleBlock {
00031         QAFBLK_EMPTY         = -1,
00032         
00040         QAFBLK_SE_BLOCK      = 0,
00041         
00049         QAFBLK_W_E_BOTTOM    = 1,
00050         
00058         QAFBLK_SW_BLOCK      = 2,
00059         
00067         QAFBLK_NW_MISSING    = 3,
00068         
00076         QAFBLK_NE_MISSING    = 4,
00077         
00085         QAFBLK_SW_NE_BOTTOM  = 5,
00086         
00094         QAFBLK_NW_SE_BOTTOM  = 6,
00095         
00103         QAFBLK_SW_E_BOTTOM   = 7,
00104         
00112         QAFBLK_W_NE_BOTTOM   = 8,
00113         
00121         QAFBLK_NW_E_BOTTOM   = 9,
00122         
00130         QAFBLK_W_SE_BOTTOM   = 10,
00131         
00132         
00140         QAFBLK_N_S_RIGHT     = 11,
00141         
00149         QAFBLK_FULL          = 12,
00150         
00158         QAFBLK_N_S_LEFT      = 13,
00159         
00167         QAFBLK_SW_MISSING    = 14,
00168         
00176         QAFBLK_SE_MISSING    = 15,
00177         
00185         QAFBLK_NW_SE_TOP     = 16,
00186         
00194         QAFBLK_SW_NE_TOP     = 17,
00195         
00203         QAFBLK_NW_E_TOP      = 18,
00204         
00212         QAFBLK_W_SE_TOP      = 19,
00213         
00221         QAFBLK_SW_E_TOP      = 20,  
00222         
00230         QAFBLK_W_NE_TOP      = 21,
00231         
00232         
00240         QAFBLK_NE_BLOCK      = 22,
00241         
00249         QAFBLK_W_E_TOP       = 23,
00250         
00258         QAFBLK_NW_BLOCK      = 24,
00259         
00267         QAFBLK_S_E_BOTTOM    = 25,
00268         
00276         QAFBLK_W_N_BOTTOM    = 26,
00277         
00285         QAFBLK_N_E_BOTTOM    = 27,
00286         
00294         QAFBLK_W_S_BOTTOM    = 28,
00295         
00303         QAFBLK_N_E_TOP       = 29,
00304         
00312         QAFBLK_W_S_TOP       = 30,
00313         
00321         QAFBLK_S_E_TOP       = 31,
00322         
00330         QAFBLK_W_N_TOP       = 32,
00331         
00339         QAFBLK_THINFLOOR_HI  = 33,
00340         
00348         QAFBLK_THINFLOOR_MID = 34,
00349         
00357         QAFBLK_THINFLOOR_LO = 35
00358         
00359     };
00360     
00361     
00362     
00363     
00364     #ifndef QAF_ENVIRONMENT_H
00365     class Environment;
00366     #endif
00367     
00379     class Room {
00380     public:
00382         const int blockSize;
00383         
00385         const int screenWidth, screenHeight;
00386         
00388         const int roomWidth, roomHeight;
00389         
00392         Container<BGLayer *> bgLayers;
00393         
00398         int waterLevel;
00399         
00402         const int defaultObjLayer;
00403         
00406         Matrix<ObstacleBlock> obstacleLayer;
00407         
00408         
00412         inline int getPixelWidth () {
00413             return obstacleLayer.columns * blockSize;
00414         }
00415 
00419         inline int getPixelHeight () {
00420             return obstacleLayer.rows * blockSize;
00421         }
00422         
00426         inline int getScreenPixelWidth () {
00427             return screenWidth * blockSize;
00428         }
00429         
00433         inline int getScreenPixelHeight () {
00434             return screenHeight * blockSize;
00435         }
00436         
00437         
00446         bool pointCollision ( float x, float y );
00447         
00463         bool pointCollision ( float x1, float y1, float x2, float y2, bool touchThinFloor,
00464                               Vector2D * contact, Vector2D * normal );
00465         
00466         
00476         bool segmentCollision ( float x1, float y1, float x2, float y2, bool touchThinFloor );
00477         
00505         bool segmentCollision ( float x1, float y1, float x2, float y2, float dx, float dy, bool touchThinFloor,
00506                                 Container<Vector2D> * contacts, Container<Vector2D> * normals, Vector2D * validDisplacement );
00507             
00508         
00509     private:
00510         friend class Environment;
00511         
00512         // Constructor: Creates an empty room.
00513         // Water level is placed right below the room's lower border; object layer
00514         // position is set to 0.
00515         //
00516         Room ( int blockSize, int screenWidth, int screenHeight, int roomWidth, int roomHeight, int waterLevel, int defaultObjLayer );
00517         
00518         // Destructor: Deletes all BGLayers in this room.
00519         virtual ~Room ();
00520         
00521     };
00522 
00523 }
00524 
00525 
00526 #endif

Generated on Sun Mar 25 12:32:12 2007 for Qaf Framework by  doxygen 1.5.1-p1