Files Classes Functions Hierarchy
Simple maze D2 game. More...
#include <maze005.h>

Public Member Functions | |
| void | menubuild () |
| Build the help menu. | |
| maze005 (int argc, char **argv) | |
| | |
| void | eval () |
| Enter infinite graphics display. | |
Static Public Member Functions | |
| static void | keyboard01 (unsigned char key, int x, int y) |
| Default keyboard handler - ESC to quit. | |
| static void | special01 (int key, int x, int y) |
| Special character keyboard handler. | |
| static void | display01 () |
| Displays the gobj::global with double buffering. | |
| static void | reshape01 (intc width_, intc height_) |
| Graphics dependent on window size needs to be updated. | |
Public Attributes | |
| gobjContainer | xGraphics |
| Global graphics stream. | |
Static Public Attributes | |
| static string | doc [] |
| Brief description of each test. | |
| static mazegameD2state01 * | mg = 0 |
| Maze game state. | |
| static mazegameD2solver01 * | ms = 0 |
| Maze solver. | |
| static mazedisp03 * | md = 0 |
| Maze game display. | |
| static bool * | help = 0 |
| Toggle help menu. | |
| static menusystem * | messages = 0 |
| Output window. | |
Simple maze D2 game.
Definition at line 14 of file maze005.h.
| maze005::maze005 | ( | int | argc, | |
| char ** | argv | |||
| ) |
/main prog=12 m=10 n=20 dx=0.15 backgroundcolor=0,255,0 wallcolor=0,25,255 randozize=0 id=1 origin=-1.4,-.5,0 - Display m by n maze.
Definition at line 149 of file maze005.cpp.
References graphmisc::colornormalize(), mazegameD2state01::deletewall, display01(), mazegameD2state01::game01(), keyboard01(), mazegameD2state01::m, commandline::mapvar(), md, mg, ms, mazegameD2state01::n, mazegameD2state01::proper, mazegameD2state01::randomize, gobjContainer::set(), mazegameD2state01::settings(), special01(), mazegameD2state01::valid(), and xGraphics.
00150 : xGraphics(true) 00151 { 00152 glutInit(&argc,argv); 00153 glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); 00154 glutInitWindowSize(800,600); 00155 glutCreateWindow(""); 00156 glutDisplayFunc(maze005::display01); 00157 glutKeyboardFunc(maze005::keyboard01); 00158 glutSpecialFunc(maze005::special01); 00159 00160 00161 OpenGLinitialisation(); 00162 00163 glEnable(GL_DEPTH_TEST); 00164 glEnable(GL_CULL_FACE); 00165 glEnable(GL_NORMALIZE); 00166 00167 xGraphics.set(); 00168 00169 commandline cmd(argc,argv); 00170 00171 // Construct the maze. 00172 00173 mg = new mazegameD2state01(); 00174 00175 cmd.mapvar(mg->m,"m"); 00176 cmd.mapvar(mg->n,"n"); 00177 cmd.mapvar(mg->randomize,"randomize"); 00178 00179 cmd.mapvar(mg->proper,"proper"); 00180 cmd.mapvar(mg->deletewall,"deletewall"); 00181 00182 mg->game01(); 00183 assert(mg->valid()); 00184 00185 md = new mazedisp03(*mg); 00186 md->game01default(); 00187 00188 cmd.mapvar(md->dx,"dx"); 00189 00190 cmd.mapvar(md->displaycellid,"id"); 00191 00192 cmd.mapvar(md->pipes,"pipes"); 00193 graphmisc::colornormalize(md->pipecolor,cmd,"pipecolor"); 00194 00195 cmd.mapvar(md->walls,"walls"); 00196 graphmisc::colornormalize(md->wallcolor,cmd,"wallcolor"); 00197 00198 string originstr("(0,0)"); 00199 cmd.mapvar(originstr,"origin"); 00200 md->origin.serializeInverseBrackets(originstr); 00201 00202 graphmisc::colornormalize(md->backgroundcolor,cmd,"backgroundcolor"); 00203 00204 cmd.mapvar(md->endpointratio,"endpointratio"); 00205 graphmisc::colornormalize(md->endpointcolor,cmd,"endpointcolor"); 00206 00207 graphmisc::colornormalize(md->currentposcolor,cmd,"currentposcolor"); 00208 00209 cout << mg->settings() << md->settings() << endl; 00210 00211 ms = new mazegameD2solver01(*mg); 00212 00213 }
| void maze005::display01 | ( | ) | [static] |
Displays the gobj::global with double buffering.
Definition at line 85 of file maze005.cpp.
References gobjContainer::draw(), glerrordisplay(), and gobj::global.
Referenced by maze005().
00086 { 00087 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00088 00089 assert(gobj::global); 00090 00091 gobj::global->draw(); 00092 00093 glerrordisplay(); 00094 00095 glutSwapBuffers(); 00096 }
| void maze005::eval | ( | ) |
Enter infinite graphics display.
Definition at line 216 of file maze005.cpp.
References mazedisp03::backgroundcolor, mazedisp03::construct(), gobjpush, md, menubuild(), mazedisp03::mousecallback, zpr::mousecallback, ms, mazedisp03::origin, mazegameD2solver01::reset(), reshape01(), zpr::update(), point2< T >::x, point2< T >::y, and mazedisp03::zm.
00217 { 00218 assert(md); 00219 assert(ms); 00220 00221 gobjpush(new gobjglTranslated(md->origin.x,md->origin.y,0.0)); 00222 00223 gobjpush(new gobjglClearColor(md->backgroundcolor)); 00224 gobjpush(new gobjglClear(GL_COLOR_BUFFER_BIT)); 00225 00226 zpr zz; 00227 // Because zpr overides reshape function in constructor. 00228 glutReshapeFunc(maze005::reshape01); 00229 00230 assert(md); 00231 zz.mousecallback = & md->mousecallback; 00232 md->zm = new zprmouse(zz); 00233 00234 md->construct(); 00235 gobjpush(md); 00236 00237 ms->reset(); 00238 00239 menubuild(); 00240 00241 zz.update(); 00242 glutMainLoop(); 00243 }
| void maze005::keyboard01 | ( | unsigned char | key, | |
| int | x, | |||
| int | y | |||
| ) | [static] |
Default keyboard handler - ESC to quit.
Definition at line 46 of file maze005.cpp.
References assertreturn, and help().
Referenced by maze005().
00051 { 00052 assertreturn(mg!=0); 00053 assertreturn(md!=0); 00054 assertreturn(ms!=0); 00055 assertreturn(messages); 00056 00057 switch (key) 00058 { 00059 case 'q': exit(0); break; 00060 00061 case 's': 00062 if (!(*ms)) ++(*ms); 00063 break; 00064 case 'S': 00065 for ( ; !(*ms); ++(*ms) ); 00066 break; 00067 case 'h': 00068 *help = !(*help); break; 00069 00070 case '1': 00071 messages->addfont10paragraphs((stringc)(*mg),50); break; 00072 case '2': messages->scrolldown(); break; 00073 case '3': messages->scrollup(); break; 00074 case '4': messages->clear(); break; 00075 00076 case 'p': md->pipes = ! md->pipes; md->gx.update(); break; 00077 case 'w': md->walls = ! md->walls; md->gx.update(); break; 00078 case 'i': md->displaycellid= ! md->displaycellid; md->gx.update(); break; 00079 00080 } 00081 00082 glutPostRedisplay(); 00083 }
| void maze005::menubuild | ( | ) |
Build the help menu.
Definition at line 107 of file maze005.cpp.
References menusystem::addfont10(), menusystem::addfont12(), menusystem::fontcolor, gobjpush, help, gobjSwitch< BOOL >::isdrawn, textoverlay::lightingdisable(), and messages.
Referenced by eval().
00108 { 00109 menusystem * menu = 00110 new menusystem(point2<GLint>(60,30),10); 00111 menu->fontcolor = point4<float>(218.0/255.0,165.0/255.0,32.0/255.0,0.75); 00112 00113 menu->addfont12("Maze Game [prototype 02]",2); 00114 00115 menu->addfont10("[page up] move up",1); 00116 menu->addfont10("[page down] move down",1); 00117 menu->addfont10("[< home] move left",1); 00118 menu->addfont10("[end >] move right",2); 00119 00120 menu->addfont10("[s] solver 1 step",1); 00121 menu->addfont10("[S] solve maze",1); 00122 menu->addfont10("[h] Toggle the menu",2); 00123 00124 menu->addfont10("[p] Toggle pipes",1); 00125 menu->addfont10("[w] Toggle walls",1); 00126 menu->addfont10("[i] Toggle cell id",2); 00127 00128 menu->addfont10("[1] Print settings",1); 00129 menu->addfont10("[2] scroll down",1); 00130 menu->addfont10("[3] scroll up",1); 00131 menu->addfont10("[4] clear",2); 00132 00133 menu->addfont10("[q] Quit",1); 00134 00135 menu->lightingdisable(); 00136 00137 gobjSwitch<> * menuswitch = new gobjSwitch<>(menu,true); 00138 help = & menuswitch->isdrawn; 00139 gobjpush(menuswitch); 00140 00141 // The messages menu 00142 messages = 00143 new menusystem(point2<GLint>(60,250),10); 00144 gobjpush(messages); 00145 messages->fontcolor = point4<float>(1.0,0.0,0.0,0.8); 00146 messages->lightingdisable(); 00147 }
Graphics dependent on window size needs to be updated.
Definition at line 99 of file maze005.cpp.
Referenced by eval().
00100 { 00101 zpr::reshape(width_,height_); 00102 assert(md); 00103 // assert(md->bp02); 00104 // md->bp02->update(); 00105 }
| void maze005::special01 | ( | int | key, | |
| int | x, | |||
| int | y | |||
| ) | [static] |
Special character keyboard handler.
Definition at line 29 of file maze005.cpp.
References mazegameD2state01::currentmove(), md, and mg.
Referenced by maze005().
00030 { 00031 assert(mg!=0); 00032 assert(md!=0); 00033 00034 switch (key) 00035 { 00036 case GLUT_KEY_LEFT : mg->currentmove(3); break; 00037 case GLUT_KEY_RIGHT : mg->currentmove(1); break; 00038 case GLUT_KEY_UP : mg->currentmove(0); break; 00039 case GLUT_KEY_DOWN : mg->currentmove(2); break; 00040 } 00041 00042 glutPostRedisplay(); 00043 }
string maze005::doc [static] |
bool * maze005::help = 0 [static] |
mazedisp03 * maze005::md = 0 [static] |
Maze game display.
Definition at line 29 of file maze005.h.
Referenced by eval(), maze005(), reshape01(), and special01().
menusystem * maze005::messages = 0 [static] |
mazegameD2state01 * maze005::mg = 0 [static] |
mazegameD2solver01 * maze005::ms = 0 [static] |
1.6.1