summaryrefslogtreecommitdiffstats
path: root/MatchBloxEngine
diff options
context:
space:
mode:
Diffstat (limited to 'MatchBloxEngine')
-rw-r--r--MatchBloxEngine/MatchBloxEngine/C_Box.cpp2
-rw-r--r--MatchBloxEngine/MatchBloxEngine/C_MatchBloxEngine.cpp19
-rw-r--r--MatchBloxEngine/MatchBloxEngine/C_MatchBloxEngine.h11
-rw-r--r--MatchBloxEngine/MatchBloxEngine/typedefs.h16
4 files changed, 28 insertions, 20 deletions
diff --git a/MatchBloxEngine/MatchBloxEngine/C_Box.cpp b/MatchBloxEngine/MatchBloxEngine/C_Box.cpp
index 9bde3ff..343ae98 100644
--- a/MatchBloxEngine/MatchBloxEngine/C_Box.cpp
+++ b/MatchBloxEngine/MatchBloxEngine/C_Box.cpp
@@ -20,7 +20,7 @@ C_Box::C_Box(const char *f_strFileName,
//calculate the tile size (this should be the same
//for all tile types)
BoundingBox_t l_BBox = m_pTiles[0]->GetBoundingBox();
- m_dTileSize = l_BBox.m_dRight - l_BBox.m_dLeft;
+ m_dTileSize = l_BBox.m_Max.x - l_BBox.m_Min.x;
//calculate the lower left tile position (in xz plane)
m_LowLeftTilePos = Vect3D_t(-m_dTileSize * (double)(m_iTilesX-1)/2.0,
diff --git a/MatchBloxEngine/MatchBloxEngine/C_MatchBloxEngine.cpp b/MatchBloxEngine/MatchBloxEngine/C_MatchBloxEngine.cpp
index 80767b8..dafa6a5 100644
--- a/MatchBloxEngine/MatchBloxEngine/C_MatchBloxEngine.cpp
+++ b/MatchBloxEngine/MatchBloxEngine/C_MatchBloxEngine.cpp
@@ -376,7 +376,7 @@ void C_MatchBloxEngine::LoadTexture(const char* f_BmpName, GLuint &f_uiTexHandle
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
}
-void C_MatchBloxEngine::CursorMove(Vect3D_t f_NewCursorPos)
+void C_MatchBloxEngine::CursorMove(Vect3D_t &f_NewCursorPos)
{
//check the state to see what 3d object currently has to be considered to
//be the cursor currently is and which bounding box we need to check for overlap
@@ -436,13 +436,14 @@ void C_MatchBloxEngine::CursorMove(Vect3D_t f_NewCursorPos)
}
-GameResult_t C_MatchBloxEngine::CursorMove_PutBlock(Vect3D_t &f_CursPos, BoundingBox_t &f_CusrBBox)
+bool C_MatchBloxEngine::CursorMove_PutBlock(Vect3D_t &f_CursPos, BoundingBox_t &f_CursBBox)
{
//check if the block is being put in the right hole
//by testing whether the position of the cursor is close
//enough to the center of the correct hole
//note that the hole positions are relative to the position
//of the box
+ bool l_bCollision = false;
Vect3D_t l_AbsHolePos = m_pBox[m_CurrentBox]->GetPos() +
m_pTiles[m_CurrentBlock]->GetPos();
Vect3D_t l_PosDif = l_AbsHolePos - f_CursPos;
@@ -456,27 +457,31 @@ GameResult_t C_MatchBloxEngine::CursorMove_PutBlock(Vect3D_t &f_CursPos, Boundin
//?? would it not be better to check for bounding box intersection with hole?
l_bCollision = !(m_pTiles[m_CurrentBlock]->GetAbsBoundBox() +
- m_pBox[m_CurrentBox]->GetPos())->Overlap(f_CursBBox);
+ m_pBox[m_CurrentBox]->GetPos()).Overlap(f_CursBBox);
//now check if the block is far enough in the hole to count as a point
if (l_PosDif.z > m_GameSettings.m_dHoleDepth)
{
//yipee!! we have got a winner!!
- m_CurrentBlock = m_pGameSession->NewTurn();
+ m_CurrentBlock = m_pCurrentSession->NewTurn();
- m_GameState
+ //m_GameState
}
+
}
+
+ return false;
}
-GameResult_t C_MatchBloxEngine::CursorMove_GrabBlock(Vect3D_t &f_CursPos, BoundingBox_t &f_CusrBBox)
+bool C_MatchBloxEngine::CursorMove_GrabBlock(Vect3D_t &f_CursPos, BoundingBox_t &f_CursBBox)
{
//grabbing a block: just check for bounding box intersection
- if (m_pBlock[(int)m_CurrentBlock)->GetAbsBoundBox().Overlap(f_CursBBox))
+ if (m_pBlock[(int)m_CurrentBlock]->GetAbsBoundBox().Overlap(f_CursBBox))
{
}
+ return true;
}
diff --git a/MatchBloxEngine/MatchBloxEngine/C_MatchBloxEngine.h b/MatchBloxEngine/MatchBloxEngine/C_MatchBloxEngine.h
index 5ef6c5d..48a17b7 100644
--- a/MatchBloxEngine/MatchBloxEngine/C_MatchBloxEngine.h
+++ b/MatchBloxEngine/MatchBloxEngine/C_MatchBloxEngine.h
@@ -3,6 +3,7 @@
#define C_MATCHBLOXENGINE_HEADER_FILE
#include "MessageQueue.h"
+#include "typedefs.h"
class C_3DObject;
class C_Block;
@@ -126,13 +127,13 @@ struct GameSession
m_uiSessionStart += l_uiPauseTime;
m_uiTurnStart += l_uiPauseTime;
}
-}
+};
class C_MatchBloxEngine
{
public:
C_MatchBloxEngine(const char *f_strModelPath,
- const char *f_strLogFile
+ const char *f_strLogFile,
GameSettings f_GameSettings);
~C_MatchBloxEngine();
@@ -160,6 +161,8 @@ private:
EngineState m_State, m_SavedState;
GameSession *m_pCurrentSession;
GameSettings m_GameSettings;
+ BoxSize m_CurrentBox;
+ BlockType m_CurrentBlock;
BoundingBox_t m_WorldBox; //an invisible box that limits the movement of the
//player
@@ -175,8 +178,8 @@ private:
//event/input handlers
void CursorMove(Vect3D_t &f_NewCursorPos);
- GameResult_t CursorMove_PutBlock(Vect3D_t &f_CursPos, BoundingBox_t &f_CusrBBox);
- GameResult_t CursorMove_GrabBlock(Vect3D_t &f_CursPos, BoundingBox_t &f_CusrBBox);
+ bool CursorMove_PutBlock(Vect3D_t &f_CursPos, BoundingBox_t &f_CusrBBox);
+ bool CursorMove_GrabBlock(Vect3D_t &f_CursPos, BoundingBox_t &f_CusrBBox);
};
diff --git a/MatchBloxEngine/MatchBloxEngine/typedefs.h b/MatchBloxEngine/MatchBloxEngine/typedefs.h
index 0b9190c..7acb776 100644
--- a/MatchBloxEngine/MatchBloxEngine/typedefs.h
+++ b/MatchBloxEngine/MatchBloxEngine/typedefs.h
@@ -29,13 +29,13 @@ typedef struct vec3d
inline vec3d& operator*=(const double &scal)
{ x*=scal; y*=scal; z*=scal; return *this; }
- inline const vec3d& operator+(const vec3d &rhs)
+ inline const vec3d& operator+(const vec3d &rhs) const
{ return vec3d(*this) += rhs; }
- inline const vec3d& operator-(const vec3d &rhs)
+ inline const vec3d& operator-(const vec3d &rhs) const
{ return vec3d(*this) -= rhs; }
- inline const vec3d& operator*(const vec3d &rhs)
+ inline const vec3d& operator*(const vec3d &rhs) const
{ return vec3d(*this) *= rhs; }
- inline const vec3d& operator*(const double &scal)
+ inline const vec3d& operator*(const double &scal) const
{ return vec3d(*this) *= scal; }
} Vect3D_t;
@@ -59,7 +59,7 @@ typedef struct bb
//translating a bounding box
inline bb& operator+=(const Vect3D_t &v)
{ m_Min += v; m_Max += v; return *this; }
- inline const bb& operator+(const Vect3D_t &v)
+ inline const bb& operator+(const Vect3D_t &v) const
{ return (bb(*this) += v); }
//update the bounding box min/max coords with vertex v
@@ -74,7 +74,7 @@ typedef struct bb
return *this;
}
- inline bool Contains(const Vect3D_t &v)
+ inline bool Contains(const Vect3D_t &v) const
{
//check if the point is contained in the box
return m_Min.x < v.x && v.x < m_Max.x &&
@@ -82,12 +82,12 @@ typedef struct bb
m_Min.z < v.z && v.z < m_Max.z;
}
- inline bool Contains(const bb& b)
+ inline bool Contains(const bb& b) const
{
return Contains(b.m_Min) && Contains(b.m_Max);
}
- inline bool Overlap(const bb& rhs)
+ inline bool Overlap(const bb& rhs) const
{
//check if the boxes overlap in all three axis
return ( ( m_Min.x < rhs.m_Min.x && rhs.m_Min.x < rhs.m_Max.x) ||