Back to Evolution Project page


Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Header Files   Sources   Compound Members   File Members  

ScreenMenu.cc

00001 #include "ScreenMenu.h"
00002 #include "Screen.h"
00003 #include "configs.h"
00004 
00005 #define MAX_OPT 4
00006 #define NEW_GAME 1
00007 #define LOAD_GAME 2
00008 #define LEVEL_EDITOR 3
00009 #define QUIT 4
00010 #define SPACING 3
00011 
00012 int TScreenMenu::Show() {
00013   int option=1; //Option that the user will choice
00014   bool getout=false; //When get out of choices?
00015   //Enter a loop to get a option from user
00016   while (1) {
00017     tile_bg();
00018     font->print_left(10, 10, "Welcome to evolution!!!!!");
00019     font->print_center(WIDTH/2, 10+SPACING*font->get_height(), "New Game");
00020     font->print_center(WIDTH/2, 10+2*SPACING*font->get_height(), "Load Game");
00021     font->print_center(WIDTH/2, 10+3*SPACING*font->get_height(), "Level Editor");
00022     font->print_center(WIDTH/2, 10+4*SPACING*font->get_height(), "Quit");
00023     if (option!=0)
00024       font->print_left  (15, 10+option*SPACING*font->get_height(), "0");
00025     CL_Display::flip_display();
00026 
00027     CL_System::keep_alive();
00028 
00029     if (CL_Keyboard::get_keycode(CL_KEY_1) )
00030       option=1;
00031     else if (CL_Keyboard::get_keycode(CL_KEY_2) )
00032       option=2;
00033     else if (CL_Keyboard::get_keycode(CL_KEY_3) )
00034       option=3;
00035     else if (CL_Keyboard::get_keycode(CL_KEY_4) )
00036       option=4;
00037     else if (CL_Keyboard::get_keycode(CL_KEY_ESCAPE) ) {
00038       option=4; getout=true;
00039     } else if (CL_Keyboard::get_keycode(CL_KEY_ENTER) )
00040       getout=true;
00041     else if (CL_Keyboard::get_keycode(CL_KEY_UP) ) {
00042       option = (option>1) ? option-1 : MAX_OPT;
00043     }
00044     else if (CL_Keyboard::get_keycode(CL_KEY_DOWN) ) {
00045       option = (option<MAX_OPT) ? option+1 : 1;
00046     }
00047     
00048     if (getout && option!=0) {
00049       switch (option) {
00050       case NEW_GAME: return SCREEN_GAME;
00051       case LOAD_GAME: return SCREEN_LOAD;
00052       case LEVEL_EDITOR: return SCREEN_EDITOR;
00053       case QUIT: return SCREEN_QUIT;
00054       default: option=0; getout=false;
00055       }
00056     } else if (option==0) {
00057       getout=false;
00058     } 
00059 
00060     CL_System::keep_alive();
00061   }
00062   return SCREEN_QUIT;
00063 }
00064 
00065 
00066 

Generated at Mon Nov 6 22:47:05 2000 for TheGameofEvolution by doxygen 1.0.0 written by Dimitri van Heesch, © 1997-1999