summaryrefslogtreecommitdiffstats
path: root/matchblox/engine/C_MatchBloxEngine.h
diff options
context:
space:
mode:
Diffstat (limited to 'matchblox/engine/C_MatchBloxEngine.h')
-rw-r--r--matchblox/engine/C_MatchBloxEngine.h68
1 files changed, 44 insertions, 24 deletions
diff --git a/matchblox/engine/C_MatchBloxEngine.h b/matchblox/engine/C_MatchBloxEngine.h
index 9b5bc98..2e38526 100644
--- a/matchblox/engine/C_MatchBloxEngine.h
+++ b/matchblox/engine/C_MatchBloxEngine.h
@@ -6,6 +6,7 @@
#include "message_input.h"
#include "typedefs.h"
#include <list>
+#include "C_Smoother.h"
//#include <pair>
using namespace std;
@@ -17,6 +18,7 @@ class C_Log;
class C_Environment;
class C_Box;
+
typedef enum GameResult
{
GR_FINISHED,
@@ -71,11 +73,9 @@ struct GameSession
*m_puiTurnResult;
int m_iBlocksLeft[4]; //number of blocks per type
BlockType m_CurrentBlockType;
- BoxSize m_BoxSize;
GameSession(int f_iNrOfBlocks, BoxSize f_BS)
- : m_iTotalTurns(f_iNrOfBlocks), m_iCurrentTurn(0),
- m_BoxSize(f_BS)
+ : m_iTotalTurns(f_iNrOfBlocks), m_iCurrentTurn(0)
{
m_puiTurnResult = new unsigned int[f_iNrOfBlocks];
@@ -95,22 +95,36 @@ struct GameSession
{
delete [] m_puiTurnResult;
}
- BlockType StartSession()
- {
- m_uiSessionStart = m_uiTurnStart = glutGet(GLUT_ELAPSED_TIME);
- return GetRandomBlockType();
- }
- BlockType NewTurn()
+
+ bool NextTurn(BlockType &f_NewBlock)
{
unsigned int l_uiTime = glutGet(GLUT_ELAPSED_TIME);
- //save turn result
- m_puiTurnResult[m_iCurrentTurn] = l_uiTime - m_uiTurnStart;
- m_iCurrentTurn++;
- m_uiTurnStart = l_uiTime;
+ if (m_iCurrentTurn == 0)
+ {
+ //session start
+ m_uiSessionStart = m_uiTurnStart = l_uiTime;
+ m_iCurrentTurn++;
+ }
+ else
+ {
+ //next turn -> save turn result
+ m_puiTurnResult[m_iCurrentTurn] = l_uiTime - m_uiTurnStart;
+ m_iCurrentTurn++;
+ m_uiTurnStart = l_uiTime;
+ }
- return GetRandomBlockType();
+ if (m_iCurrentTurn < m_iTotalTurns)
+ {
+ f_NewBlock = GetRandomBlockType();
+ return true;
+ }
+ else
+ {
+ return false;
+ }
}
+
BlockType GetRandomBlockType()
{
int l_iBlockType = rand()%4;
@@ -168,11 +182,9 @@ private:
GameSettings m_GameSettings;
BoxSize m_CurrentBox;
BlockType m_CurrentBlock;
-
- //typedef pair<input_payload_wiimote::dot, input_payload_wiimote::dot> dotpair;
- //list<dotpair> m_DotHist;
- int m_DotHistSize;
-
+ unsigned int m_uiCurrentTime,
+ m_uiLastPosValid;
+ C_Smoother<double> *m_pWorldZSmoother[2]; //2 to smooth the computed world z coordinate
double m_dInitialWiimoteDist; //initial distance of wiimote in mm, this distance is
//mapped to the z=0.0 in world coordinates
BoundingBox_t m_WorldBox; //an invisible box that limits the movement of the
@@ -185,16 +197,24 @@ private:
void LoadTexture(const char* f_BmpName, GLuint &f_uiTexHandle);
//render routines
- void Render_Basics(unsigned int f_uiElapsedTime);
+ void RenderGetReady();
+ void RenderHUD(unsigned int f_uiElapsedTime);
+ void RenderResults();
+ void RenderPointHere();
+ void RenderText(GLint x, GLint y, char *string, struct ColorStruct f_sColor);
//event/input handlers
void CursorMove(Vect3D_t &f_NewCursorPos);
- //bool CursorMove_PutBlock(Vect3D_t &f_CursPos, BoundingBox_t &f_CusrBBox);
- //bool CursorMove_GrabBlock(Vect3D_t &f_CursPos, BoundingBox_t &f_CusrBBox);
+ bool CursorMove_GrabBlock(Vect3D_t &f_NewCursorPos);
+ bool CursorMove_PutBlock(Vect3D_t &f_NewCursorPos);
+ bool Check_PutBlock(Vect3D_t &f_CursPos, BoundingBox_t &f_CusrBBox);
+ //bool Check_GrabBlock(Vect3D_t &f_CursPos, BoundingBox_t &f_CusrBBox);
+ void NewBlock();
+ void GameFinished();
//wiimote functions
- bool FindIRDots(input_payload_wiimote *f_pWiimote, ir_dot_t f_Dot[2]);
- bool CalcWiimoteRelativeCursorPos(input_payload_wiimote *f_pWiimote, Vect3D_t *f_pRelPos);
+ //bool FindIRDots(input_payload_wiimote *f_pWiimote, ir_dot_t f_Dot[2]);
+ //bool CalcWiimoteRelativeCursorPos(input_payload_wiimote *f_pWiimote, Vect3D_t *f_pRelPos);
bool ConvertWiimoteToWorld(input_payload_wiimote *f_pWiimote, Vect3D_t *f_WorldPos);
};