summaryrefslogtreecommitdiffstats
path: root/MatchBloxEngine/MatchBloxEngine/C_MatchBloxEngine.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'MatchBloxEngine/MatchBloxEngine/C_MatchBloxEngine.cpp')
-rw-r--r--MatchBloxEngine/MatchBloxEngine/C_MatchBloxEngine.cpp84
1 files changed, 80 insertions, 4 deletions
diff --git a/MatchBloxEngine/MatchBloxEngine/C_MatchBloxEngine.cpp b/MatchBloxEngine/MatchBloxEngine/C_MatchBloxEngine.cpp
index a0ad65e..7e17b1b 100644
--- a/MatchBloxEngine/MatchBloxEngine/C_MatchBloxEngine.cpp
+++ b/MatchBloxEngine/MatchBloxEngine/C_MatchBloxEngine.cpp
@@ -1,4 +1,7 @@
#include <GL/glut.h>
+
+#include <time.h>
+#include <string>
#include <iostream>
#include "C_MatchBloxEngine.h"
@@ -23,11 +26,30 @@ C_MatchBloxEngine::C_MatchBloxEngine(const char *f_strModelPath,
//set state to initialised;
m_State = ES_INITIALISED;
}
+ else
+ {
+ m_State = ES_ERROR;
+ }
+
+ //initialise a random seed
+ srand ( time(NULL) );
+
+ //init vars
+ m_CurrentBox = BS_SMALL;
//debug
m_pBox[0]->SetPos(0.0, -5.0, -15.0);
m_pBox[0]->SetRot(45.0, 0.0, 0.0);
m_pBox[0]->RandomizeTiles();
+
+ m_pBlock[0]->SetPos(-6.0, 1.0, -10.0);
+ m_pBlock[0]->SetRot(90.0, 0.0, 0.0);
+ m_pBlock[1]->SetPos(-2.0, 1.0, -10.0);
+ m_pBlock[1]->SetRot(90.0, 0.0, 0.0);
+ m_pBlock[2]->SetPos(2.0, 1.0, -10.0);
+ m_pBlock[2]->SetRot(90.0, 0.0, 0.0);
+ m_pBlock[3]->SetPos(6.0, 1.0, -10.0);
+ m_pBlock[3]->SetRot(90.0, 0.0, 0.0);
}
C_MatchBloxEngine::~C_MatchBloxEngine()
@@ -41,7 +63,18 @@ C_MatchBloxEngine::~C_MatchBloxEngine()
GameResult C_MatchBloxEngine::GameStep(msgQueue &f_Queue)
{
//process message queue
-
+ return GR_ERROR;
+}
+
+void C_MatchBloxEngine::Render_Basics(unsigned int f_uiElapsedTime)
+{
+ //render the environment
+ m_pEnvMap->Render();
+
+ m_pBox[(intptr_t)m_CurrentBox]->Render();
+ for (int i=0; i<4; i++)
+ m_pBlock[i]->Render(f_uiElapsedTime);
+// m_pHand->Render(f_uiElapsedTime);
}
void C_MatchBloxEngine::Render(unsigned int f_uiElapsedTime)
@@ -49,23 +82,64 @@ void C_MatchBloxEngine::Render(unsigned int f_uiElapsedTime)
switch (m_State)
{
case ES_INITIALISED:
+ Render_Basics(f_uiElapsedTime);
break;
+
case ES_ERROR:
+ //render a red cube
+ glPushMatrix();
+ glPushAttrib(GL_ENABLE_BIT);
+ glDisable(GL_LIGHTING);
+ glColor3d(1.0, 0.0, 0.0);
+ glTranslated(0.0, 0.0, -5.0);
+ glutSolidCube(5.0);
+ glPopAttrib();
+ glPopMatrix();
break;
+
case ES_GET_READY:
+ Render_Basics(f_uiElapsedTime);
+ //render some GET READY text
break;
+
case ES_PLAYING_GRAB_BLOCK:
+ Render_Basics(f_uiElapsedTime);
break;
+
case ES_PLAYING_PUT_BLOCK:
+ Render_Basics(f_uiElapsedTime);
break;
+
case ES_PAUSED:
+ Render_Basics(f_uiElapsedTime);
+ //render menu??
break;
+
case ES_FINISHED:
+ //render results...
break;
}
- m_pEnvMap->Render();
- m_pBox[0]->Render();
+ //glPushMatrix();
+
+ //double l_dSeconds = (double)f_uiElapsedTime/1000.0;
+
+ //glRotated(l_dSeconds * 5.0, 0.0, 1.0, 0.0);
+ ////glRotated(l_dSeconds * 10, 0.0, 0.0, 1.0);
+
+ //m_pEnvMap->Render();
+
+ //glPopMatrix();
+
+ //m_pBox[0]->Render();
+
+ //for(int i=0; i<4; i++)
+ //{
+ // glPushMatrix();
+ // m_pBlock[i]->Render(f_uiElapsedTime);
+ // glPopMatrix();
+ //}
+
}
bool C_MatchBloxEngine::NewGame(int f_iUserID, int f_iGameId, BoxSize f_BS)
@@ -81,6 +155,8 @@ bool C_MatchBloxEngine::NewGame(int f_iUserID, int f_iGameId, BoxSize f_BS)
//set state to GET READY
m_State = ES_GET_READY;
+ //init object positions
+ m_pBox[(int)m_CurrentBox]->SetPos(0.0, -6.0, -15.0);
return true;
}
@@ -148,7 +224,7 @@ bool C_MatchBloxEngine::LoadModels(const char* f_strModelDir)
std::string l_BaseName = f_strModelDir;
//create the environment mapped cube
- m_pEnvMap = new C_Environment("envmaps/brightday2_", 50.0);
+ m_pEnvMap = new C_Environment("envmaps/terrain_", 50.0);
//load the bitmaps for the textures
LoadTexture((l_BaseName + "/wood1.bmp").c_str(), m_uiWood1Tex);