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

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

00001 #include <iostream>
00002 
00003 #include "textures.h"
00004 #include "ActiveGS.h"
00005 #include "LoadingGS.h"
00006 
00007 using namespace MMGUI;
00008 using namespace std;
00009 
00010 static GameState *thisGS;
00011 
00012 void LoadingGS::init() {    
00013     thisGS = this;
00014 
00015     // Hook up the startup callback.    
00016     callback = new LoadingCallback(this);
00017     client->setGameCallback(callback);
00018 
00019     menuInit();
00020 
00021     setupComplete = false;
00022     
00023     Frame *pane = new Frame(WidgetAlignCenter, 800, 600);
00024     getRoot()->addChild(pane);
00025     
00026     Image *loading = new Image(TEXTURE_LOADING, WidgetAlignTop, 200, 100);
00027     pane->addChild(loading);
00028     
00029     boxes = new ProgressBoxes(WidgetAlignCenter, 600, 100);
00030     pane->addChild(boxes);
00031     
00032     Image *instructions = new Image(TEXTURE_INSTRUCTIONS, WidgetAlignBottom, 600, 300);
00033     pane->addChild(instructions);
00034     
00035     tickCount = 0;
00036         glutPostRedisplay();
00037 
00038         // This just starts it now
00039     //cerr << "STARTUP - LoadingGS::init()" << endl;
00040 
00041         client->game->generateLevel();
00042     //cerr << "STARTUP - LoadingGS::init() done" << endl;
00043 }
00044 
00045 void LoadingGS::startGame() {
00046     //cerr << "STARTUP - LoadingGS startGame()" << endl;
00047     setGameState(new ActiveGS(client));
00048 }
00049 
00050 void LoadingGS::exit() {
00051     menuClear();
00052 }
00053 
00054 void LoadingGS::update() {
00055     tickCount++;    
00056 
00057     if(setupComplete == false) {
00058         //cerr << "STARTUP - LoadingGS::update" << endl;        
00059         if(thisGS->client->game->isSetupDone()) {
00060             setupComplete = true;
00061             //cerr << "STARTUP - LoadingGS::update -> setupComplete" << endl;
00062             this->client->setupComplete();
00063             return;
00064         }
00065     }   
00066     
00067     if(tickCount < TICK_DELTA) {
00068         return;                   
00069     }   
00070 
00071     tickCount = 0;
00072 
00073     boxes->updateImages();   
00074 }
00075 
00076 void LoadingGS::display() {
00077     //This stuff should probably be done in display
00078     glClearColor(0,0,0,0); //must have black background
00079     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
00080 
00081     menuDraw();
00082     
00083     glutSwapBuffers();
00084 }
00085 
00086 
00087 ProgressBoxes::ProgressBoxes(int x, int y, int height, int width) : Frame(x, y, height, width) {
00088     init();
00089 }
00090 
00091 ProgressBoxes::ProgressBoxes(enum WidgetAlign align, int height, int width) : Frame(align, height, width) {
00092     init();
00093 }
00094 
00095 void ProgressBoxes::init() {
00096     direction = 1;
00097     location = 0;
00098     image = new Image(TEXTURE_LOAD_ARROW, 0, 0, 100, 45);
00099     addChild(image);
00100 }
00101 
00102 void ProgressBoxes::updateImages() {
00103  
00104     location = (location + 20) % 550;
00105     image->move(location, 0);    
00106     glutPostRedisplay();
00107 }
00108 
00109 

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