Main Page | Namespace List | Class Hierarchy | Data Structures | File List | Data Fields | Globals

D:/Archiv/Projekte/OpenGL/quaxbomber03/GameTile.cpp

Go to the documentation of this file.
00001 
00008 #include "GameTile.h"
00009 #include "CoveredGameTileModel.h"
00010 
00011 #include <gl/glut.h>
00012 #include <iostream>
00013 #include <String>
00014 
00015 using namespace std;
00016 
00021 GameTile::GameTile() {
00022   currentIState = CLEAN;
00023   currentVState = COVERED;
00024   bombCounter = 0;
00025   goodieCounter = 0;
00026 }
00027 
00028 
00036 GameTile::GameTile(InvisibleState invState, VisibleState visState) {  
00037   currentIState = invState;
00038   currentVState = visState;
00039   bombCounter = 0;
00040   goodieCounter = 0;
00041 }           
00042 
00043 
00049 void GameTile::setInvisibleState(InvisibleState s) {
00050   currentIState = s;  
00051 }
00052 
00053 
00059 void GameTile::setVisibleState(VisibleState s) {
00060   currentVState = s;
00061   glutPostRedisplay();  
00062 }
00063 
00064 
00070 void GameTile::renderModel() {
00071   switch(currentVState) {
00072     case UNCOVERED:
00073       modelList[1]->render();
00074       break;
00075     default:
00076       modelList[0]->render();
00077       break;
00078   }
00079 }
00080 
00081 
00088 void GameTile::addModel(Model *m) {
00089   this->modelList.push_back(m);
00090 }
00091 
00092 
00100 void GameTile::addNeighbor(GameTile *gt) {
00101   this->neighborList.push_back(gt);
00102 }
00103 
00104 
00111 void GameTile::uncover() {
00112   // cout << "o, v, h: "  << offset << ", " << v << ", " << h << endl;  
00113   vector<GameTile*>::iterator i = neighborList.begin();
00114   if(currentVState == GameTile::COVERED) {
00115     setVisibleState(GameTile::UNCOVERED);
00116     switch(currentIState) {
00117       case CLEAN:       
00118         if((bombCounter == 0)&&(goodieCounter == 0)) {          
00119           for(; i < neighborList.end(); i++) {
00120             ((GameTile*)*i)->uncover();            
00121           }
00122         }
00123         cout << " CLEAN: Bombcounter, GoodieCounter :" << bombCounter << ", " << goodieCounter << endl;
00124         break;
00125       case BOMB:
00126         // explodieren
00127         cout << " BOMB: Bombcounter, GoodieCounter :" << bombCounter << ", " << goodieCounter << endl;
00128         break;
00129       case LIFE:
00130         // leben zuweisen
00131         cout << " LIFE: Bombcounter, GoodieCounter :" << bombCounter << ", " << goodieCounter << endl;
00132         break;
00133       case TIMEFREEZER:
00134         // timer anhalten
00135         cout << " TIMEFREEZER: Bombcounter, GoodieCounter :" << bombCounter << ", " << goodieCounter << endl;
00136         break;
00137       default:
00138         break;
00139     }
00140   }
00141 }
00142 
00143 
00149 int GameTile::getBombCounter() {
00150   return bombCounter;
00151 }
00152 
00153 
00159 int GameTile::getGoodieCounter() {
00160   return goodieCounter;
00161 }

Generated on Fri Apr 8 00:11:47 2005 for Quaxbomber by  doxygen 1.4.1