00001 // --------------------------------------------------------------------------- 00002 // PLATFORM: All - 00003 // PRODUCT: Fourplay - 00004 // VISIBILITY: Public - 00005 // --------------------------------------------------------------------------- 00006 // - 00007 // PURPOSE: The grid that the discs will be fired into. - 00008 // - 00009 // --------------------------------------------------------------------------- 00010 00011 #ifndef GRID_H 00012 #define GRID_H 00013 00014 #include "GridColumn.h" 00015 #include "PhysicsObject.h" 00016 #include "RectangleCollider.h" 00017 00022 class Grid 00023 { 00024 00025 public: 00031 Grid(CIwFVec2 position, 00032 int tileSize); 00033 00037 ~Grid(); 00038 00042 void Draw(); 00043 00048 int GetNumberOfColliders(); 00049 00054 int GetNumberOfColumns(); 00055 00061 PhysicsObject* GetTopCollider(int index); 00062 00068 RectangleCollider* GetColumnSideCollider(int index); 00069 00075 PhysicsObject* GetColumnTopCollider(int index); 00076 00082 float GetPositionOfNextEmptySquareInColumn(int index); 00083 00089 int GetIndexOfNextEmptySquareInColumn(int index); 00090 00095 void DecreaseEmptySquaresInColumn(int index); 00096 00103 void SetColumnSquare(int column, 00104 int row, 00105 int colour); 00106 00111 void PreventColumnOverflow(int index); 00112 00118 bool IsColumnFull(int index); 00119 00124 int CheckForWinner(); 00125 00129 void ClearGrid(); 00130 00135 void ToCharArray(char (&arr)[6][7]); 00136 00137 protected: 00139 static const int m_numColumns = 7; 00140 00142 static const int m_numRows = 6; 00143 00145 static const int m_numColliders = 8; 00146 00148 static const int m_numSideColliders = 8; 00149 00151 static const int m_numTopColliders = 7; 00152 00154 CIwFVec2 m_position; 00155 00157 GridColumn *m_columns[m_numColumns]; 00158 00160 PhysicsObject *m_colliders[m_numColliders]; 00161 00163 RectangleCollider *m_columnSideColliders[m_numSideColliders]; 00164 00166 PhysicsObject *m_columnTopColliders[m_numTopColliders]; 00167 00169 float m_colliderRadius; 00170 00172 float m_colliderMass; 00173 00175 enum Result { REDWIN = 1, YELLOWWIN = 2, DRAW = 3 }; 00176 00178 float m_sideColWidth; 00179 00181 float m_sideColHeight; 00182 00184 float m_topColliderRadius; 00185 }; 00186 00187 #endif