proj home

Files   Classes   Functions   Hierarchy  

Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
maze005 Class Reference

Simple maze D2 game. More...

#include <maze005.h>

Collaboration diagram for maze005:
Collaboration graph

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 mazegameD2state01mg = 0
 Maze game state.
static mazegameD2solver01ms = 0
 Maze solver.
static mazedisp03md = 0
 Maze game display.
static boolhelp = 0
 Toggle help menu.
static menusystemmessages = 0
 Output window.

Detailed Description

Simple maze D2 game.

Definition at line 14 of file maze005.h.

Constructor & Destructor Documentation

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.

: xGraphics(true)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(800,600);
glutCreateWindow("");
glutDisplayFunc(maze005::display01);
glutKeyboardFunc(maze005::keyboard01);
glutSpecialFunc(maze005::special01);
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
glEnable(GL_NORMALIZE);
commandline cmd(argc,argv);
// Construct the maze.
cmd.mapvar(mg->m,"m");
cmd.mapvar(mg->n,"n");
cmd.mapvar(mg->randomize,"randomize");
cmd.mapvar(mg->proper,"proper");
cmd.mapvar(mg->deletewall,"deletewall");
mg->game01();
assert(mg->valid());
md = new mazedisp03(*mg);
md->game01default();
cmd.mapvar(md->dx,"dx");
cmd.mapvar(md->displaycellid,"id");
cmd.mapvar(md->pipes,"pipes");
graphmisc::colornormalize(md->pipecolor,cmd,"pipecolor");
cmd.mapvar(md->walls,"walls");
graphmisc::colornormalize(md->wallcolor,cmd,"wallcolor");
string originstr("(0,0)");
cmd.mapvar(originstr,"origin");
md->origin.serializeInverseBrackets(originstr);
graphmisc::colornormalize(md->backgroundcolor,cmd,"backgroundcolor");
cmd.mapvar(md->endpointratio,"endpointratio");
graphmisc::colornormalize(md->endpointcolor,cmd,"endpointcolor");
graphmisc::colornormalize(md->currentposcolor,cmd,"currentposcolor");
cout << mg->settings() << md->settings() << endl;
}

Member Function Documentation

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().

{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
assert(gobj::global);
glutSwapBuffers();
}
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.

Referenced by main().

{
assert(md);
assert(ms);
gobjpush(new gobjglClear(GL_COLOR_BUFFER_BIT));
zpr zz;
// Because zpr overides reshape function in constructor.
glutReshapeFunc(maze005::reshape01);
assert(md);
md->zm = new zprmouse(zz);
ms->reset();
zz.update();
glutMainLoop();
}
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().

{
switch (key)
{
case 'q': exit(0); break;
case 's':
if (!(*ms)) ++(*ms);
break;
case 'S':
for ( ; !(*ms); ++(*ms) );
break;
case 'h':
*help = !(*help); break;
case '1':
case '2': messages->scrolldown(); break;
case '3': messages->scrollup(); break;
case '4': messages->clear(); break;
case 'p': md->pipes = ! md->pipes; md->gx.update(); break;
case 'w': md->walls = ! md->walls; md->gx.update(); break;
case 'i': md->displaycellid= ! md->displaycellid; md->gx.update(); break;
}
glutPostRedisplay();
}
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, and textoverlay::lightingdisable().

Referenced by eval().

{
menusystem * menu =
new menusystem(point2<GLint>(60,30),10);
menu->fontcolor = point4<float>(218.0/255.0,165.0/255.0,32.0/255.0,0.75);
menu->addfont12("Maze Game [prototype 02]",2);
menu->addfont10("[page up] move up",1);
menu->addfont10("[page down] move down",1);
menu->addfont10("[< home] move left",1);
menu->addfont10("[end >] move right",2);
menu->addfont10("[s] solver 1 step",1);
menu->addfont10("[S] solve maze",1);
menu->addfont10("[h] Toggle the menu",2);
menu->addfont10("[p] Toggle pipes",1);
menu->addfont10("[w] Toggle walls",1);
menu->addfont10("[i] Toggle cell id",2);
menu->addfont10("[1] Print settings",1);
menu->addfont10("[2] scroll down",1);
menu->addfont10("[3] scroll up",1);
menu->addfont10("[4] clear",2);
menu->addfont10("[q] Quit",1);
menu->lightingdisable();
gobjSwitch<> * menuswitch = new gobjSwitch<>(menu,true);
help = & menuswitch->isdrawn;
gobjpush(menuswitch);
// The messages menu
new menusystem(point2<GLint>(60,250),10);
messages->fontcolor = point4<float>(1.0,0.0,0.0,0.8);
}
void maze005::reshape01 ( intc  width_,
intc  height_ 
)
static

Graphics dependent on window size needs to be updated.

Definition at line 99 of file maze005.cpp.

References reshape().

Referenced by eval().

{
zpr::reshape(width_,height_);
assert(md);
// assert(md->bp02);
// md->bp02->update();
}
void maze005::special01 ( int  key,
int  x,
int  y 
)
static

Special character keyboard handler.

Definition at line 29 of file maze005.cpp.

Referenced by maze005().

{
assert(mg!=0);
assert(md!=0);
switch (key)
{
case GLUT_KEY_LEFT : mg->currentmove(3); break;
case GLUT_KEY_RIGHT : mg->currentmove(1); break;
case GLUT_KEY_UP : mg->currentmove(0); break;
case GLUT_KEY_DOWN : mg->currentmove(2); break;
}
glutPostRedisplay();
}

Member Data Documentation

string maze005::doc
static
Initial value:
{
"",
"$ ./main prog=14 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."
}

Brief description of each test.

Definition at line 19 of file maze005.h.

Referenced by main().

bool * maze005::help = 0
static

Toggle help menu.

Definition at line 32 of file maze005.h.

mazedisp03 * maze005::md = 0
static

Maze game display.

Definition at line 29 of file maze005.h.

Referenced by eval(), and maze005().

menusystem * maze005::messages = 0
static

Output window.

Definition at line 34 of file maze005.h.

mazegameD2state01 * maze005::mg = 0
static

Maze game state.

Definition at line 25 of file maze005.h.

Referenced by maze005().

mazegameD2solver01 * maze005::ms = 0
static

Maze solver.

Definition at line 27 of file maze005.h.

Referenced by eval(), and maze005().

gobjContainer maze005::xGraphics

Global graphics stream.

Definition at line 22 of file maze005.h.

Referenced by maze005().


The documentation for this class was generated from the following files: