Main Page   Modules   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   Related Pages  

/home/rdbrown/doxygen/cse125g1/src/game/client/ActiveGS.cpp

00001 #include "ActiveGS.h"
00002 #include "sceneManagement/sceneManager.h"
00003 #include "levelGen/levelGen.h"
00004 #include "actor/Actor.h"
00005 #include "actor/Item.h"
00006 #include "resources/resources.h"
00007 #include "sceneManagement/sceneObject.h"
00008 //game actors
00009 #include "actors.h"
00010 #include "textures.h"
00011 #include "animations.h"
00012 #include "miniMap/miniMap.h"
00013 #include "math/random.h"
00014 #include "endgameGS.h"
00015 #include "net/Player.h"
00016 #include "Music.h"
00017 //#include "net/Powerup.h"
00018 
00019 using namespace std;
00020 using namespace MMNet;
00021 
00022 static SceneManager * sm = new SceneManager();
00023 
00024 static MMNet::Game *gsgame;
00025 static TNL::U32 chargeTime = 0;
00026 
00027 static void charge(int x, int y) {
00028         //cerr << "Charging\n";
00029         chargeTime = TNL::Platform::getRealMilliseconds();
00030         gsgame->myPlayer->clientCharge();
00031 }
00032 static void attack(int x, int y) {
00033         //cerr << "Firing\n";
00034         chargeTime = 0;
00035         gsgame->myPlayer->clientAttack();
00036 }
00037 void ActiveGS::init() {
00038         gsgame = game;
00039 
00040     callback = new ActiveCallback(this);
00041     client->setGameCallback(callback);
00042     
00043         glutKeyboardFunc(InputSystemKeyDown);
00044         //pc = new PlayerControl();
00045         sm = game->sm;
00046 
00047 
00048         //testing AI path
00049         //trogdor needs to know where he is and what to wear
00050         //trogdor = new Trogdor(lg, TEXTURE_PARTICLE, &camera);
00051         //sm->addObject(2,2, trogdor); 
00052 
00053         //SceneQuadrant *sq = new SceneQuadrant();
00054         sm->init(&camera);
00055         fog.Init();
00056         
00057         lighting.Init();
00058         sm->getBucket(trunk)->init(TEXTURE_CRACKLY_BARK);
00059         sm->getBucket(trunk)->initImposters(TEXTURE_GENERIC_TREE);
00060         sm->getBucket(sheriff)->init(TEXTURE_SHERIFF);
00061         sm->getBucket(trogdor)->init(TEXTURE_HARLEY_QUINN);
00062         sm->getBucket(robin)->init(TEXTURE_ROBIN);
00063         sm->getBucket(john)->init(TEXTURE_JOHN);
00064         sm->getBucket(guard)->init(TEXTURE_GUARD);
00065         sm->getBucket(rogue_sword)->init(TEXTURE_ROGUE_SWORD);
00066         sm->getBucket(guard_sword)->init(TEXTURE_GUARD_SWORD);
00067         sm->getBucket(guard_mace)->init(TEXTURE_MACE);
00068         sm->getBucket(bow)->init(TEXTURE_ROBIN_BOW);
00069         sm->getBucket(crossbow)->init(TEXTURE_CROSS_BOW);
00070         sm->getBucket(felled_tree)->init(TEXTURE_FELLED_TREE);
00071         sm->getBucket(tree_stump)->init(TEXTURE_TREE_STUMP);
00072         sm->getBucket(rock1)->init(TEXTURE_GRANITE1);
00073         sm->getBucket(rock2)->init(TEXTURE_GRANITE2);
00074         sm->getBucket(rock3)->init(TEXTURE_MARBLE);
00075         sm->getBucket(rock4)->init(TEXTURE_MERMER);
00076         sm->getBucket(rock5)->init(TEXTURE_TRAVERTINE);
00077 
00078     sm->getBucket(powerup_rapid_fire)->init(TEXTURE_POWERUP_RAPID_FIRE);
00079     sm->getBucket(powerup_multi_shot)->init(TEXTURE_POWERUP_MULTI_SHOT);
00080     sm->getBucket(powerup_fast_shot)->init(TEXTURE_POWERUP_FAST_SHOT);
00081     sm->getBucket(powerup_damage_x2)->init(TEXTURE_POWERUP_DAMAGE_X2);
00082     sm->getBucket(powerup_spy_arrow)->init(TEXTURE_POWERUP_SPY);
00083     sm->getBucket(powerup_sneak)->init(TEXTURE_POWERUP_SNEAK);
00084     sm->getBucket(powerup_health)->init(TEXTURE_POWERUP_HEALTH);
00085     
00086         //sm->getBucket(powerup...)->init(TEXTURE_POWERUP...);
00087     //glutFullScreen();
00088     glutSetCursor(GLUT_CURSOR_NONE);
00089 
00090         assert(game != NULL);
00091         assert(game->myPlayer.isValid());
00092         input = new PlayerInput(game->myPlayer);
00093         input->pinMouse(false);
00094         camera.SetPlayer(game->myPlayer);
00095 
00096         hud = new HUD(game->myPlayer); //need player namec
00097     game->myPlayer->setHud(hud);
00098     
00099         //load up score menu
00100         //scoreMenu = new ScoreMenu(game);
00101         //scoreMenu->init();
00102 
00103         InitActors();
00104         InitArrows();
00105     InitPowerups();
00106         InputSetMouseDown(0, charge);
00107         InputSetMouseUp(0, attack);
00108 
00109         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
00110         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
00111 
00112         //InitTextures
00113         getNameForTexture(TEXTURE_KILLED);
00114         getNameForTexture(TEXTURE_HEADSHOT_TROGDOR);
00115 
00116         //load up the textures for skybox
00117         initSkybox();
00118         blood.init(Vector3(0,0,0), Vector3(0,0,0), Vector3(1, 0, 0), Vector3(1,1,1), Vector3(10000,10000,10000), 1000, 300);
00119         timer.Init();
00120         playBirds();
00121 
00122 //      glutFullScreen();
00123 
00124 }
00125 void ActiveGS::initSkybox()
00126 {
00127         unsigned int filenames[10] = {TEXTURE_SKYBOX_SIDE1,TEXTURE_SKYBOX_SIDE2,TEXTURE_SKYBOX_SIDE3,TEXTURE_SKYBOX_SIDE4,TEXTURE_SKYBOX_SIDE5,TEXTURE_ROCK_WALL3,TEXTURE_ROCK_WALL3,TEXTURE_ROCK_WALL3,TEXTURE_ROCK_WALL3,TEXTURE_GROUND};
00128         for (int i = 0; i < 10; i++)
00129                 textureName[i] = getNameForTexture(filenames[i]);
00130 
00131 
00132         //Ground
00133         groundDL = glGenLists(1);
00134         glNewList(groundDL,GL_COMPILE);
00135         drawGround();
00136         glEndList();
00137 
00138         //sky walls
00139         skyWallsDL = glGenLists(1);
00140         glNewList(skyWallsDL,GL_COMPILE);
00141         drawSkyboxWalls();
00142         glEndList();
00143 
00144         //sky
00145         skyDL = glGenLists(1);
00146         glNewList(skyDL,GL_COMPILE);
00147         drawSkyboxSky();
00148         glEndList();
00149 
00150         //other wall
00151         wallDL = glGenLists(1);
00152         glNewList(wallDL,GL_COMPILE);
00153         drawWall();
00154         glEndList();
00155 }
00156 void LoadCharacterSkel(Actor *a, int type)
00157 {
00158         Tokenizer tokens;
00159         char *filename;
00160         switch(type) {
00161                 case ACTOR_SHERIFF:
00162                         tokens.Open(filename=resFindResource("StaticCharacters/Sheriff.MMA"));
00163                         break;
00164                 case ACTOR_GUARD:
00165                         tokens.Open(filename=resFindResource("StaticCharacters/Guard.MMA"));
00166                         break;
00167                 case ACTOR_ROBIN:
00168                         tokens.Open(filename=resFindResource("StaticCharacters/Robin.MMA"));
00169                         break;
00170                 case ACTOR_JOHN:
00171                         tokens.Open(filename=resFindResource("StaticCharacters/LittleJohn.MMA"));
00172                         break;
00173                 case ACTOR_TROGDOR:
00174                         tokens.Open(filename=resFindResource("StaticCharacters/Harleyquinn.MMA"));
00175                         break;
00176         }
00177         free(filename);
00178         a->skel.Load(tokens);
00179         tokens.Close();
00180 }
00181 void LoadWeaponSkel(Actor *a, int type)
00182 {
00183         Tokenizer tokens;
00184         char *filename;
00185         switch(type) {
00186                 case WEAPON_ROGUE_SWORD:
00187                         tokens.Open(filename=resFindResource("StaticWeapons/roguesword.MMA"));
00188                         break;
00189                 case WEAPON_BOW:
00190                         tokens.Open(filename=resFindResource("StaticWeapons/Bow.MMA"));
00191                         break;
00192                 case WEAPON_GUARD_SWORD:
00193                         tokens.Open(filename=resFindResource("StaticWeapons/guardsword.MMA"));
00194                         break;
00195                 case WEAPON_GUARD_MACE:
00196                         tokens.Open(filename=resFindResource("StaticWeapons/guardmace.MMA"));
00197                         break;
00198                 case WEAPON_CROSSBOW:
00199                         tokens.Open(filename=resFindResource("StaticWeapons/CrossBow.MMA"));
00200                         break;
00201         }
00202         free(filename);
00203         a->skel.Load(tokens);
00204         tokens.Close();
00205 }
00206 
00207 Actor *myActor;
00208 void ActiveGS::InitActors()
00209 {
00210         Actor *a, *weapon;
00211         for(int i = 0; i < game->players.size(); i++)
00212         {
00213                 a = new Actor();
00214                 if(game->players[i] == game->myPlayer)
00215                         myActor = a;
00216                 sm->addObject(0,0,a);
00217                 int model = (game->players[i]->model - 1) % ACTOR_MAX;
00218                 *a = gameActors[model];
00219                 LoadCharacterSkel(a,model);
00220                 a->skin.AllocateVertexArrays();
00221                 a->SetPlayer(game->players[i]);
00222                 a->SetAnimations(animations);
00223 
00224                 if(game->players[i]->getTeam() == MMNet::TeamThieves)
00225                 {
00226                         //melee weapon
00227                         weapon = new Actor();
00228                         *weapon = gameWeapons[WEAPON_ROGUE_SWORD];
00229                         LoadWeaponSkel(weapon,WEAPON_ROGUE_SWORD);
00230                         weapon->skin.AllocateVertexArrays();
00231                         weapon->SetPlayer(NULL);
00232                         weapon->SetAnimations(animations);
00233                         a->AddWeapon(weapon,0);
00234                         sm->addObject(0,0,weapon);
00235                         //range weapon
00236                         weapon = new Actor();
00237                         *weapon = gameWeapons[WEAPON_BOW];
00238                         LoadWeaponSkel(weapon,WEAPON_BOW);
00239                         weapon->skin.AllocateVertexArrays();
00240                         weapon->SetPlayer(NULL);
00241                         weapon->SetAnimations(animations);
00242                         a->AddWeapon(weapon,1);
00243                         sm->addObject(0,0,weapon);
00244 
00245                 }
00246                 else //if(game->players[i]->getTeam() == MMNet::TeamKnights)
00247                 {
00248                         //melee weapon
00249                         weapon = new Actor();
00250                         if(mmrand()%2)
00251                         {
00252                                 *weapon = gameWeapons[WEAPON_GUARD_SWORD];
00253                                 LoadWeaponSkel(weapon,WEAPON_GUARD_SWORD);
00254                         }
00255                         else
00256                         {
00257                                 *weapon = gameWeapons[WEAPON_GUARD_MACE];
00258                                 LoadWeaponSkel(weapon,WEAPON_GUARD_MACE);
00259                         }
00260                         weapon->skin.AllocateVertexArrays();
00261                         weapon->SetPlayer(NULL);
00262                         weapon->SetAnimations(animations);
00263                         a->AddWeapon(weapon,0);
00264                         sm->addObject(0,0,weapon);
00265                         //range weapon
00266                         weapon = new Actor();
00267                         *weapon = gameWeapons[WEAPON_CROSSBOW];
00268                         LoadWeaponSkel(weapon,WEAPON_CROSSBOW);
00269                         weapon->skin.AllocateVertexArrays();
00270                         weapon->SetPlayer(NULL);
00271                         weapon->SetAnimations(animations);
00272                         a->AddWeapon(weapon,1);
00273                         sm->addObject(0,0,weapon);
00274                 }
00275         }
00276 }
00277 
00278 void ActiveGS::InitArrows()
00279 {
00280         Arrow *a;
00281         
00282         for(int i = 0; i < ARROW_COUNT; i++)
00283         {
00284                 a = new Arrow();
00285                 a->Init(game, game->arrows[i], 1.0, 0.0, 0.0);
00286                 //a->immuneToForces = false;
00287                 sm->addObject(0,0,a);
00288         }
00289 }
00290 
00291 void ActiveGS::InitPowerups() {    
00292     Powerup *p;
00293     int i;
00294     
00295     for(i = 0; i < game->PowerUps.size(); i++) {
00296         p = game->PowerUps[i];     
00297         p->loadSceneItem(sm);
00298     }
00299 }
00300 
00301 void ActiveGS::update() {
00302         input->update();
00303         float dt = game->tick();
00304 
00305         if (hud != NULL) {
00306                 hud->update();
00307         }
00308         //printf("OpenGL version %s\n", glGetString(GL_VERSION));
00309         /*
00310         if(InputKeyIsDown('j') || InputKeyIsDown('J'))
00311         {
00312                 weaponNum++;
00313                 *weapon = gameWeapons[weaponNum%WEAPON_MAX];
00314                 weapon->skin.AllocateVertexArrays();
00315                 weapon->SetPlayer(NULL);
00316                 weapon->SetAnimations(animations);
00317                 a->AddWeapon(weapon,0);
00318         }
00319 */
00320         if(InputKeyIsDown('1'))
00321         {
00322                 camera.Reset();
00323                 camera.SetCameraType(playerCamera);
00324         }
00325         else if (InputKeyIsDown('2')|| camera.GetCameraType() == arrowWaitingCamera)
00326         {
00327                 camera.Reset();
00328                 camera.SetLastArrow(game->lastArrow);
00329                 camera.SetCameraType(arrowCamera);
00330         }
00331         else if (InputKeyIsDown('3') )
00332         {
00333                 camera.SetCameraType(skyCamera);
00334                 //cerr << "bird's eye view";
00335                 camera.SetFOV(70.0f);
00336                 camera.SetIncline(M_PI/4.0f);
00337                 camera.SetDistance(100.0f);
00338                 camera.SetFarClip(600.0f);
00339         } 
00340         else if (InputKeyIsDown('4') ) 
00341         {
00342         //      scoreMenu->toggleDraw();
00343         }
00344 
00345 
00346 
00347         if (InputKeyIsDown('f'))
00348         {
00349                 //cerr << "(t)oggle full screen";
00350                 static bool _fullScreen = true;
00351                 _fullScreen = !_fullScreen;
00352                 if (_fullScreen)
00353                         glutFullScreen();
00354                 else
00355                         glutReshapeWindow(1024,768);
00356 
00357         }
00358     
00359         camera.Update();
00360         if (InputKeyIsDown('}'))
00361                 sm->incMaxTreeDistance();
00362         if (InputKeyIsDown('{'))
00363                 sm->decMaxTreeDistance();
00364         sm->update(dt);
00365 
00366         if (client->game->hadHit())
00367         {
00368                 blood.launchParticles(&client->game->hitLocationWas(), 
00369                                        &Vector3(rand()%10, rand()%10, rand()%10), 
00370                                                    NULL, false, true, -1, 700);
00371         }
00372         blood.update(dt);
00373 
00374     if(InputKeyIsDown(27)) {
00375         //cerr << "Quitting the game..." << endl;
00376         setGameState(NULL);        
00377     }
00378     
00379         glutPostRedisplay();
00380     // call high level display functions
00381 }
00382 
00383 void ActiveGS::exit() {
00384         //glutReshapeWindow(800,600);
00385         input->pinMouse(true);
00386     delete input;
00387         InputSetMouseDown(0, NULL);
00388         InputSetMouseUp(0, NULL);
00389         InputSetMouseMotion(NULL);
00390 
00391     //client->disconnectFromServer();    
00392     //delete hud;
00393     glutSetCursor(GLUT_CURSOR_INHERIT);
00394 }
00395 
00396 void ActiveGS::display() {
00397         // erase the background:
00398         static float secondCounter = 0.0f;
00399         float deltaTime;
00400 
00401         deltaTime = timer.GetTimeChange();
00402         secondCounter += deltaTime;
00403         timer.Update();
00404 
00405         if (secondCounter > 2.0) {
00406           printf("Frames Per Second: %f\n", 1.0/deltaTime);
00407                 secondCounter = 0.0f;
00408         }
00409 
00410         glClearColor(142.0/255.0, 220.0/255.0, 253.0/255.0, 1.0);
00411         glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
00412         camera.Draw();
00413         
00414         lighting.Draw();
00415         fog.Enable();
00416         
00417         //glPointSize(3.0);
00418         blood.draw();
00419         //lighting.Disable();
00420         glCallList(groundDL); //note that this also creates the ground
00421         
00422         
00423 
00424 
00425         //move skybox w/ arrows or player
00426         float playerX, playerZ;
00427         if (camera.GetCameraType() == arrowCamera)
00428         {
00429                 playerX = camera.GetLastArrow()->getPos().x;
00430                 playerZ = camera.GetLastArrow()->getPos().z;
00431         }
00432         else
00433         {
00434                 playerX = game->myPlayer->world.d.x;
00435                 playerZ = game->myPlayer->world.d.z;
00436         }
00437 
00438         //Draw moving skybox
00439         glPushMatrix();
00440                 glTranslatef(playerX-200, 0.0, playerZ-200);
00441                 glCallList(skyWallsDL);
00442                 fog.Disable();
00443                 glCallList(skyDL);
00444                 fog.Enable();
00445         glPopMatrix();
00446         
00447         //Create ground
00448         glCallList(wallDL); 
00449 
00450         //Draw arrows, actors, trees, rocks, etc
00451         sm->draw();
00452 
00453         if (game != NULL && game->myPlayer != NULL) {
00454         Player *player = game->myPlayer;
00455         
00456         // reset the charge time if the player's dead.
00457         if(player->isDead() && chargeTime > 0) {
00458             chargeTime = 0;
00459         }
00460         
00461         if(player->isDead() == false && player->weaponState == WeaponRanged) {
00462             TNL::U32 delta = 0;
00463 
00464             if (chargeTime > 0)
00465                 delta = TNL::Platform::getRealMilliseconds() - chargeTime;
00466                         //if(player->powerupActive(POWERUP_FAST_SHOT)) {
00467                         //      delta = MAX_CHARGE_TIME;
00468                         //}
00469             Vector3 pos = myActor->world.d;
00470             pos.y += 5.0;
00471 
00472                         lighting.Disable();
00473                         fog.Disable();
00474             as.DrawTarget(pos, player->world.c, delta);
00475         }
00476 
00477         
00478         //sm->drawQuadrants();
00479         //drawMiniMap(mapx, mapy, PosX, PosY, PosZ, Yrot, *sm);
00480         drawMiniMap(game->myPlayer->world.d, game->myPlayer->world.c, sm, getNameForTexture(TEXTURE_HUDCOVER)); // XXX: Player player, arrows, trees, rocks, bushes, textureID
00481 
00482         if (hud != NULL) {
00483             hud->draw();
00484                         //scoreMenu->draw();
00485         }
00486         }
00487         glutSwapBuffers();
00488 }
00489 
00490 void ActiveGS::drawGround() {
00491         float height = 0;
00492         float width = 1000;
00493         float length = 1000;
00494         float numTiles = 40.0;
00495 
00496         glEnable(GL_TEXTURE_2D);
00497         glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
00498         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
00499     glBindTexture(GL_TEXTURE_2D, textureName[9]); 
00500 
00501         glColor3f(1.0, 1.0, 1.0);
00502         glNormal3f(0.0, 0.5, 0.5);
00503         glBegin(GL_QUADS);
00504                 glTexCoord2f(0.0, 0.0);      glVertex3f( width, height, -length);
00505                 glTexCoord2f(0.0,      numTiles);      glVertex3f(-width, height, -length);
00506                 glTexCoord2f(numTiles, numTiles); glVertex3f(-width, height,  length);
00507                 glTexCoord2f(numTiles, 0.0);      glVertex3f( width, height,  length);
00508         glEnd();
00509         glDisable(GL_TEXTURE_2D);
00510 }
00511 
00512 void ActiveGS::drawSkyboxSky() {
00513         glPushMatrix();
00514         //glTranslatef(-50,0,-50);
00515         float height = 60;
00516         float width = 400;
00517         float length = 400;
00518 
00519         /*            0,0    N          0,l
00520 
00521                   W                        E
00522       
00523                                 w,0             S               w,l
00524         */
00525         //the sky
00526         glEnable(GL_TEXTURE_2D);
00527     glBindTexture(GL_TEXTURE_2D, textureName[4]); 
00528         glColor3f(1,1,1);
00529         glNormal3f(0.0, -1, 0.0);
00530         glBegin(GL_QUADS);
00531         glTexCoord2f(0.0, 0.0); glVertex3f(width, height, 0);
00532         glTexCoord2f(0.0, 1.0); glVertex3f(0, height, 0);
00533         glTexCoord2f(1.0, 1.0); glVertex3f(0, height, length);
00534         glTexCoord2f(1.0, 0.0); glVertex3f(width, height, length);
00535         glEnd();
00536         glPopMatrix();
00537         glDisable(GL_TEXTURE_2D);
00538 }
00539 
00540 void ActiveGS::drawSkyboxWalls() {
00541         glPushMatrix();
00542         //glTranslatef(-100,0,-100);
00543         float height = 60;
00544         float width = 400;
00545         float length = 400;
00546 
00547         /*            0,0    N          0,l
00548 
00549                   W                        E
00550       
00551                                 w,0             S               w,l
00552         */
00553         //the sky
00554         glEnable(GL_TEXTURE_2D);
00555     glBindTexture(GL_TEXTURE_2D, textureName[4]); 
00556         glColor3f(1,1,1);
00557         glNormal3f(0.0, -1, 0.0);
00558         glBegin(GL_QUADS);
00559         glTexCoord2f(0.0, 0.0); glVertex3f(width, height, 0);
00560         glTexCoord2f(0.0, 1.0); glVertex3f(0, height, 0);
00561         glTexCoord2f(1.0, 1.0); glVertex3f(0, height, length);
00562         glTexCoord2f(1.0, 0.0); glVertex3f(width, height, length);
00563         glEnd();
00564 
00565         //west
00566     glBindTexture(GL_TEXTURE_2D, textureName[0]); 
00567         glColor3f(1,1,1);
00568         glBegin(GL_QUADS);
00569         glTexCoord2f(0.0, 0.0); glVertex3f(width, 0, 0 );
00570         glTexCoord2f(0.0, 1.0); glVertex3f(width, height, 0);
00571         glTexCoord2f(1.0, 1.0); glVertex3f(0, height, 0);
00572         glTexCoord2f(1.0, 0.0); glVertex3f(0, 0, 0);
00573         glEnd();
00574 
00575         //north
00576     glBindTexture(GL_TEXTURE_2D, textureName[1]); 
00577         glColor3f(1,1,1);
00578         glBegin(GL_QUADS);
00579         glTexCoord2f(0.0, 0.0); glVertex3f(0, 0, 0);
00580         glTexCoord2f(0.0, 1.0); glVertex3f(0, height, 0);
00581         glTexCoord2f(1.0, 1.0); glVertex3f(0, height, length);
00582         glTexCoord2f(1.0, 0.0); glVertex3f(0, 0, length);
00583         glEnd();
00584 
00585         //east
00586     glBindTexture(GL_TEXTURE_2D, textureName[2]); 
00587         glColor3f(1,1,1);
00588         glBegin(GL_QUADS);
00589         glTexCoord2f(0.0, 0.0); glVertex3f(0, 0, length);
00590         glTexCoord2f(0.0, 1.0); glVertex3f(0, height, length);
00591         glTexCoord2f(1.0, 1.0); glVertex3f(width, height, length);
00592         glTexCoord2f(1.0, 0.0); glVertex3f(width, 0, length);
00593         glEnd();
00594 
00595         //south
00596     glBindTexture(GL_TEXTURE_2D, textureName[3]); 
00597         glColor3f(1,1,1);
00598         glBegin(GL_QUADS);
00599         glTexCoord2f(0.0, 0.0); glVertex3f(width, 0, length);
00600         glTexCoord2f(0.0, 1.0); glVertex3f(width, height, length);
00601         glTexCoord2f(1.0, 1.0); glVertex3f(width, height, 0);
00602         glTexCoord2f(1.0, 0.0); glVertex3f(width, 0, 0);
00603         glEnd();
00604         glPopMatrix();
00605         glDisable(GL_TEXTURE_2D);
00606 }
00607 
00608 void ActiveGS::drawWall() {
00609         glPushMatrix();
00610         float height = WALL_HEIGHT;
00611         float width = WALL_WIDTH;
00612         float length = WALL_LENGTH;
00613 
00614         glEnable(GL_TEXTURE_2D);
00615         glEnable(GL_BLEND);                                                                     //use blending
00616         glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);      //standard blending factor
00617 
00618         /*            0,0    N          0,l
00619 
00620                   W                        E
00621       
00622                                 w,0             S               w,l
00623         */
00624 
00625         //west
00626         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
00627     glBindTexture(GL_TEXTURE_2D, textureName[5]); 
00628         glColor3f(1,1,1);
00629         glBegin(GL_QUADS);
00630         glTexCoord2f(0.0, 0.0); glVertex3f(width, 0, 0 );
00631         glTexCoord2f(0.0, 1.0); glVertex3f(width, height, 0);
00632         glTexCoord2f(10.0, 1.0); glVertex3f(0, height, 0);
00633         glTexCoord2f(10.0, 0.0); glVertex3f(0, 0, 0);
00634         glEnd();
00635 
00636         //north
00637     glBindTexture(GL_TEXTURE_2D, textureName[6]); 
00638         glColor3f(1,1,1);
00639         glBegin(GL_QUADS);
00640         glTexCoord2f(0.0, 0.0); glVertex3f(0, 0, 0);
00641         glTexCoord2f(0.0, 1.0); glVertex3f(0, height, 0);
00642         glTexCoord2f(10.0, 1.0); glVertex3f(0, height, length);
00643         glTexCoord2f(10.0, 0.0); glVertex3f(0, 0, length);
00644         glEnd();
00645 
00646         //east
00647     glBindTexture(GL_TEXTURE_2D, textureName[7]); 
00648         glColor3f(1,1,1);
00649         glBegin(GL_QUADS);
00650         glTexCoord2f(0.0, 0.0); glVertex3f(0, 0, length);
00651         glTexCoord2f(0.0, 1.0); glVertex3f(0, height, length);
00652         glTexCoord2f(10.0, 1.0); glVertex3f(width, height, length);
00653         glTexCoord2f(10.0, 0.0); glVertex3f(width, 0, length);
00654         glEnd();
00655 
00656         //south
00657     glBindTexture(GL_TEXTURE_2D, textureName[8]); 
00658         glColor3f(1,1,1);
00659         glBegin(GL_QUADS);
00660         glTexCoord2f(0.0, 0.0); glVertex3f(width, 0, length);
00661         glTexCoord2f(0.0, 1.0); glVertex3f(width, height, length);
00662         glTexCoord2f(10.0, 1.0); glVertex3f(width, height, 0);
00663         glTexCoord2f(10.0, 0.0); glVertex3f(width, 0, 0);
00664         glEnd();
00665         glPopMatrix();
00666 
00667         glDisable(GL_BLEND);
00668         glDisable(GL_TEXTURE_2D);
00669 
00670 }
00671 
00672 void ActiveCallback::EndGame() {    
00673             // At the moment just put is back to the main menu
00674             //setGameState(MAIN_MENU);
00675                         //setGameState(new EndGameGS(this->parent->client));
00676                         this->parent->scoreMenu->update(); //last update
00677                         setGameState(new EndGameGS(this->parent->client, this->parent->scoreMenu));
00678             //setGameState(new ScoreMenu(parent->client->game));
00679         };       

Generated on Thu Aug 18 16:03:08 2005 for Robin Hood: Thieves & Knights by doxygen1.2.18