00001 /* 00002 * $Id: main.cpp,v 1.43 2002/08/09 05:53:26 virtualcasino Exp $ 00003 */ 00004 #include<SDL/SDL.h> 00005 #include<clawsoft.h> 00006 #include<BaseButton.h> 00007 #include<TextButton.h> 00008 #include<Resource.h> 00009 #include<Event.h> 00010 #include<MouseEvent.h> 00011 #include<Window.h> 00012 #include<TextField.h> 00013 #include<LoginDialog.h> 00014 #include<GameSelector.h> 00015 #include<unistd.h> 00016 #include<stdlib.h> 00017 #include<fx.h> 00018 #include<SDL_gfxPrimitives.h> 00019 #ifndef BINGO 00020 #define BINGO 2 00021 #endif 00022 #ifndef RULETA 00023 #define RULETA 3 00024 #endif 00025 #ifndef BLACKJACK 00026 #define BLACKJACK 4 00027 #endif 00028 00030 SDL_Surface *Screen; 00031 String usrName; 00032 00033 00034 00035 00036 00037 extern Uint32 audio_len; 00038 using namespace clawsoft; 00039 int doexit; 00040 00041 class TestButton:public TextButton{ 00042 protected: 00043 int count; 00044 public: 00045 TestButton(const char *str, Rect &r):TextButton(r, str){ 00046 count = 0; 00047 } 00048 void action(int xx, int yy, int bb){ 00049 cout << "Exiting..." << endl; 00050 doexit = 1; 00051 } 00052 }; 00053 00054 00055 SDL_Event globalEvent; 00056 int main(int argc, char *argv[]){ 00057 bool cont; 00058 SDL_Rect src, dest; 00059 Rect r(0, 0, 106, 32); 00060 doexit = 0; 00061 TestButton button("Salir", r); 00062 LoginDialog login; 00063 GameSelector menu; 00064 int opcion; 00065 if(SDL_Init(SDL_INIT_VIDEO) != 0){ 00066 fprintf(stderr, "Unable to start SDL :-(\n"); 00067 return 1; 00068 } 00069 atexit(SDL_Quit); 00070 if(TTF_Init() < 0){ 00071 cerr << "Unable to initialize true type support" << endl; 00072 return 1; 00073 } 00074 atexit(TTF_Quit); 00075 if((Screen = SDL_SetVideoMode(800, 600, 32, SDL_HWSURFACE|SDL_DOUBLEBUF)) == 0){ 00076 /*if((Screen = SDL_SetVideoMode(1024, 768, 32, 00077 SDL_HWSURFACE|SDL_FULLSCREEN| 00078 SDL_DOUBLEBUF)) == 0){*/ 00079 fprintf(stderr, "Unable to enter graphics mode: %s\n", 00080 SDL_GetError()); 00081 return 1; 00082 } 00083 SDL_WM_SetCaption("Virtual Casino", "Virtual Casino"); 00084 loadResources(); 00085 playSound("../sounds/thx.wav"); 00086 fade_out(bRes[SPLASH], 0.01); 00087 /*while(!playFinished()) 00088 SDL_Delay(500);*/ 00089 fade_in(bRes[SPLASH], 0.1); 00090 SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); 00091 src.x = 0; 00092 src.y = 0; 00093 00094 dest.x = 0; 00095 dest.y = 0; 00096 src.w = bRes[BACKGROUND]->w; 00097 src.h = bRes[BACKGROUND]->h; 00098 dest.w = Screen->w; 00099 dest.h = Screen->h; 00100 login.map(); 00101 login.draw(); 00102 if(!login.run()){ 00103 playSound("../sounds/program-complete.wav"); 00104 while(!playFinished()) 00105 SDL_Delay(500); 00106 return 0; 00107 } 00108 //Obtiene el login name 00109 usrName = login.getText(); 00110 while(!playFinished()) 00111 SDL_Delay(500); 00112 playSound("../sounds/working.wav"); 00113 while(!playFinished()) 00114 SDL_Delay(500); 00115 button.map(); 00116 button.draw(); 00117 drawGrid(); 00118 menu.map(); 00119 do{ 00120 cont = false; 00121 opcion = menu.run(); 00122 if(opcion == BINGO || opcion == RULETA || 00123 opcion == BLACKJACK){ 00124 playSound("../sounds/standby.wav"); 00125 while(!playFinished()) 00126 SDL_Delay(500); 00127 } 00128 switch(opcion){ 00129 case BINGO: 00130 cont = true; 00131 break; 00132 case RULETA: 00133 cont = true; 00134 break; 00135 case BLACKJACK: 00136 cont = true; 00137 break; 00138 } 00139 }while(cont); 00140 playSound("../sounds/program-complete.wav"); 00141 while(!playFinished()) 00142 SDL_Delay(500); 00143 return 0; 00144 }
Powered by: