/*主函数*/ void snake_main(void) { Init();/*图形驱动*/ DrawK();/*开始画面*/ GamePlay();/*玩游戏具体过程*/ Close();/*图形结束*/ }
/*function the present the page- AI MENU- and handle the events releated to him*/ int AISettings(SDL_Surface* screen){ int x, y; int move_next_page = FALSE; SDL_Surface* AI_Menu = NULL; SDL_Event event; AI_Menu = SDL_LoadBMP("Images/aiset.bmp"); if (AI_Menu == NULL) return 1; apply_surface(0, 0, AI_Menu, screen); drawArrows(screen, AI_SETTINGS); //Update Screen SDL_Flip(screen); while (quit == FALSE && move_next_page == FALSE){ if (SDL_PollEvent(&event)){ if (event.type == SDL_MOUSEBUTTONUP){ //Get the mouse offsets x = event.button.x; y = event.button.y; //If the mouse is over the button //colorComp if ((x > 60) && (x < 60 + 155) && (y > 210) && (y < 210 + 70)){ userColor = BLACK; } if ((x > 60) && (x < 60 + 155) && (y > 330) && (y < 330 + 70)){ userColor = WHITE; } //cancel if ((x > 60) && (x < 60 + 155) && (y > 490) && (y < 490 + 70)){ return FALSE; // return to previous page- but dont exit the program! } //depth if ((x > 310) && (x < 310 + 155) && (y > 100) && (y < 100 + 70)){ minimax_depth = 1; } if ((x > 310) && (x < 310 + 155) && (y > 212) && (y < 212 + 70)){ minimax_depth = 2; } if ((x > 310) && (x < 310 + 155) && (y > 332) && (y < 332 + 70)){ minimax_depth = 3; } if ((x > 310) && (x < 310 + 155) && (y > 440) && (y < 440 + 70)){ minimax_depth = 4; } if ((x > 577) && (x < 577 + 155) && (y > 324) && (y < 324 + 70)){ minimax_depth = 5; } //next if ((x > 577) && (x < 577 + 155) && (y > 488) && (y < 488 + 70)){ if (GamePlay(screen, fileName)){ quit = TRUE; break; } } apply_surface(0, 0, AI_Menu, screen); drawArrows(screen, AI_SETTINGS); //Update Screen SDL_Flip(screen); }//end of handle key pressed //If the user has Xed out the window if (event.type == SDL_QUIT){ quit = TRUE; break; } //Apply image to screen }//end of handle events }//end while //Free the loaded image SDL_FreeSurface(AI_Menu); return quit; }
void Game::GameLoop() { while(running) { switch(game_status) { case MENU: GameMenu(); break; case EDITOR: GameEditor(); break; case GAMEPLAY: GamePlay(); break; case MAPCHOOSE: MapChoose(); break; } } }
int main(int argc, char **argv) { _ksys_get_screen_size (&ScreenX, &ScreenY); OffsetX=ScreenX/2-Width/2; OffsetY=ScreenY/2-Height/2; draw_window(); while (!0) { if (GAME_TYPE==1) { _ksys_delay(15-Max_Speed); } else { _ksys_delay(1); } Key=getKey(); if (GAME_TYPE==-1) return 0; if (GAME_TYPE==0) MainMenu (); if (GAME_TYPE==1) GamePlay (); if (GAME_TYPE==2) ShowHelp (); if (GAME_TYPE==3) LevelEditor(); if (GAME_TYPE==4) Authors(); Update(); } }
// main function int main() { CountRanking(); while(1){ selection=StartMenu(selection); switch(selection){ case '1': // 게임 시작 GamePlay(); return 0; case '2': // Ranking 확인 ViewRanking(); break; case '3': // 도움말 HelpScreen(); break; case '4': // 게임 종료 ExitGame(); system("PAUSE"); return 0; break; } // switch } // while return 0; }
/*function the present the page- SETTING MENU- and handle the events releated to him*/ int SettingMenu(SDL_Surface* screen, int isLoaded){ int x, y; int move_next_page = FALSE; SDL_Surface* Setting_Menu = NULL; SDL_Event event; Setting_Menu = SDL_LoadBMP("Images/settingsmenu.bmp"); if (Setting_Menu == NULL) return 1; apply_surface(0, 0, Setting_Menu, screen); drawArrows(screen, SET_SETTINGS); // the function draw arrows on the chosen options SDL_Flip(screen); while (quit == FALSE && move_next_page == FALSE){ if (SDL_PollEvent(&event)){ if (event.type == SDL_MOUSEBUTTONUP){ //Get the mouse offsets x = event.button.x; y = event.button.y; //If the mouse is over the button: //gameMode if ((x > 52) && (x < 52 + 155) && (y > 212) && (y < 212 + 70)){ game_mode = 1; } if ((x > 52) && (x < 52 + 155) && (y > 332) && (y < 332 + 70)){ game_mode = 2; } //cancel if ((x > 52) && (x < 52 + 155) && (y > 501) && (y < 501 + 70)){ return FALSE;// return to previous page- but dont exit the program! } //to setTheBoard if (isLoaded == 0 && (x > 318) && (x < 318 + 155) && (y > 379) && (y < 379 + 70)){ if (setBoard(screen)){ quit = TRUE; break; } } //color if ((x > 579) && (x < 579 + 155) && (y > 212) && (y < 212 + 70)){ nextPlayer = WHITE; } if ((x > 579) && (x < 579 + 155) && (y > 332) && (y < 332 + 70)){ nextPlayer = BLACK; } //next if ((x > 581) && (x < 581 + 155) && (y > 501) && (y < 501 + 70)){ if (game_mode == 2){ if (AISettings(screen)){ quit = TRUE; break; } } if (game_mode == 1){ if (GamePlay(screen, fileName)){ quit = TRUE; break; } } } apply_surface(0, 0, Setting_Menu, screen); drawArrows(screen, SET_SETTINGS); //the user clicked- maybe somthings changed- need to update the arrows SDL_Flip(screen); //update screen } //If the user has Xed out the window if (event.type == SDL_QUIT){ quit = TRUE; break; } } } //Free the loaded image SDL_FreeSurface(Setting_Menu); return quit; }
void Arcade() { int selectedplayer,nextmap,nextplayer,won=1; Location locat; int Played[5],i,playedCount=1,exists=1; //Loading of data voice_set_playmode(Dramatic, PLAYMODE_LOOP); Cinematic1(); voice_ramp_volume(Dramatic,1000,Music_volume); rest(1000); selectedplayer=CharacterSelect(); if(selectedplayer==-1) { voice_stop(Dramatic); return; } Played[0]=selectedplayer; while(playedCount<5) { if(won) { exists=1; while(exists) { nextplayer=Random(0,4); player1=selectedplayer; player2=nextplayer; exists=0; for (i=0; i<playedCount; i++) { if(Played[i]==nextplayer) { exists=1; } } } Played[playedCount]=nextplayer; playedCount++; nextmap=Random(0,4); } CinematicVoice(selectedplayer,nextplayer,nextmap); voice_stop(Dramatic); switch(GamePlay(selectedplayer,nextplayer,nextmap,1)) { case 0: voice_stop(Dramatic); return; case 1: won=1; CinematicWin(selectedplayer,nextplayer); break; case 2: won=0; if(!GameOver(selectedplayer)) { voice_stop(Dramatic); return; } break; } Savegame(); } voice_stop(Dramatic); }