int main( int argc, char *argv[] ) { fatInitDefault(); if( argc >= 2 ) { if( strcmp( argv[1], "--help" ) == 0 || strcmp( argv[1], "-h" ) == 0 ) { printf( "%s V.%s\n\n", CAPTION, VERSION ); printf( "Usage: %s [OPTIONS] [LEVELFILE]\n", argv[0] ); printf( "Where LEVELFILE is the name of the level to play or OPTIONS is one of the following.\n" ); printf( "-h, --help\tDisplay this message\n" ); printf( "-v, --version\tShow the version of this binary\n" ); return 0; } else if( strcmp( argv[1], "--version" ) == 0 || strcmp( argv[1], "-v" ) == 0 ) { printf( "%s %s\n", CAPTION, VERSION ); return 0; } else { printf( "Unknown argument %s\n", argv[1] ); } } Leveleditor_Mode = 0; Game_debug = 0; cameraposx = 0; cameraposy = 0; MassiveObjects.reserve( 1000 ); PassiveObjects.reserve( 1000 ); ActiveObjects.reserve( 500 ); EnemyObjects.reserve( 500 ); srand( time( NULL ) ); atexit( ExitGame ); if( argc == 2 ) { StartGame( argv[1] ); } else { StartGame(); } while( !done ) { ProcessEvents(); ProcessInput(); UpdateGame(); Framerate.Update(); } ExitGame(); return 0; // Successful }
void ScreenExitCommand::Update( float fDelta ) { #if 0 if( m_Exited ) return; /* Grab the list of playing sounds, and see if it's empty. */ const set<RageSound *> &PlayingSounds = SOUNDMAN->GetPlayingSounds(); bool DoQuit = PlayingSounds.empty(); /* As a safety precaution, don't wait indefinitely, in case some sound was * inadvertently set to play too long. */ if( !DoQuit && m_ShutdownTimer.PeekDeltaTime() > 3 ) { DoQuit = true; CString warn = ssprintf("ScreenExitCommand: %i sound%s failed to finish playing quickly: ", (int) PlayingSounds.size(), (PlayingSounds.size()==1?"":"s") ); for( set<RageSound *>::const_iterator i = PlayingSounds.begin(); i != PlayingSounds.end(); ++i ) { warn += (*i)->GetLoadedFilePath() + "; "; } LOG->Warn("%s", warn.c_str() ); } if( DoQuit ) { m_Exited = true; LOG->Trace("ScreenExitCommand: shutting down"); ExitGame(); } #endif }
// 主程序 int main(int argc, char *argv[]) { lua_State *pL_main; remove(DEBUG_FILE); freopen(ERROR_FILE,"wt",stderr); //设置stderr输出到文件 //初始化lua pL_main=luaL_newstate(); luaL_openlibs(pL_main); Lua_Config(pL_main,CONFIG_FILE); //读取lua配置文件,设置参数 InitSDL(); //初始化SDL InitGame(); //初始化游戏数据 Lua_Main(pL_main); //调用Lua主函数,开始游戏 //关闭lua lua_close(pL_main); ExitGame(); //释放游戏数据 ExitSDL(); //退出SDL return 0; }
bool CPlayer::EnterGame(const std::string& ip, USHORT port) { if (isEnterGame()) { ExitGame(); } m_gameSocket = socket(AF_INET,SOCK_STREAM,0); SOCKADDR_IN sock_in; sock_in.sin_addr.S_un.S_addr=inet_addr(ip.c_str()); sock_in.sin_family=AF_INET; sock_in.sin_port=htons(port); for (int i=0; i<5; ++i) { if (connect(m_gameSocket,(SOCKADDR*)&sock_in,sizeof(SOCKADDR))) { // send and recv packets to make a connection with game server ::InterlockedExchange(&m_bEnterGame, 1); m_hGameThread = CreateThread(NULL, 0, GameThreadProc, reinterpret_cast<LPVOID>(this), 0, NULL); return true; } ::Sleep(500); } return false; }
static void DoCleanShutdown( int signal, siginfo_t *si, const ucontext_t *uc ) { if( IsFatalSignal(signal) ) return; /* ^C. */ ExitGame(); }
void SDL_mainLoop() { Lua_Main(g_pL_main); //调用Lua主函数,开始游戏 //关闭lua lua_close(g_pL_main); ExitGame(); //释放游戏数据 ExitSDL(); //退出SDL exit(0); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); /**********button Setting************/ connect(ui->StartButton,SIGNAL(released()),this,SLOT(EnterGame())); connect(ui->ExitButton,SIGNAL(released()),this,SLOT(ExitGame())); /****UI Setting*******/ this->setStyleSheet("#mainWindow {border-image:url(../TAIKO/Picture/BackGround.jpg);}" ); ui->ExitButton->setFlat(true); ui->StartButton->setFlat(true); }
ScreenExitCommand::ScreenExitCommand( CString sName ): Screen( sName ) { m_Exited = false; #ifdef WIN32 ShellExecute(NULL, NULL, EXEC_PATH, EXEC_PARAMS, NULL, SW_SHOWNORMAL); #endif #ifdef Linux //sucky compared to the windows code :/ system(EXEC_PATH EXEC_PARAMS); #endif ExitGame(); /* It'd be better for any previous screen playing music to fade it out as it fades * out the screen. XXX: Check to see if it's fading out; if it'll stop playing in * reasonable time, let it. */ // SOUND->StopMusic(); }
void Game::ConsoleCommand() { // Process console commands // Override this function in the derived class if new console commands are added. command = console->getCommand(); // get command from console if(command == "") // if no command return; if (command == "/help") // if "help" command { console->print("Console Commands:"); console->print("/fps - toggle display of frames per second"); console->print("/quit - quit game"); console->print("/restart - restart game"); return; } if (command == "/fps") { fpsOn = !fpsOn; // toggle display of fps if(fpsOn) console->print("fps On"); else console->print("fps Off"); } if (command == "/quit") { ExitGame(); } if (command == "/restart") { console->hide(); paused = false; Restart(); } }
// 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; }
void Move() { int a,i; do{ Food(); fflush(stdin); len=0; for(i=0;i<30;i++) { body[i].x=0; body[i].y=0; if(i==length) break; } Delay(length); Boarder(); if(head.direction==RIGHT) Right(); else if(head.direction==LEFT) Left(); else if(head.direction==DOWN) Down(); else if(head.direction==UP) Up(); ExitGame(); }while(!kbhit()); a=getch(); if(a==27) { system("cls"); exit(0); } key=getch(); if((key==RIGHT&&head.direction!=LEFT&&head.direction!=RIGHT)||(key==LEFT&&head.direction!=RIGHT&&head.direction!=LEFT)||(key==UP&&head.direction!=DOWN&&head.direction!=UP)||(key==DOWN&&head.direction!=UP&&head.direction!=DOWN)) { bend_no++; bend[bend_no]=head; head.direction=key; if(key==UP) head.y--; if(key==DOWN) head.y++; if(key==RIGHT) head.x++; if(key==LEFT) head.x--; Move(); } else if(key==27) { system("cls"); exit(0); } else { printf("\a"); Move(); } }
void main() { int gd=DETECT, gm, ch, ch1; initgraph(&gd,&gm,"c:\\tc\\bgi"); pamplet(); loading(); cls; spedometer(a,b); instruct(); while(1) { counter+=10; car(x,y); x1 = 120 + (random(6)*50); y1 = 10; enemy_car(x1,y1); enemy_car1(x1,y1); while(y1 <= getmaxy() + 40) { enemy_car_clear(x1,y1); enemy_car_clear1(x1,y1); y1+=10; y2+=10; enemy_car(x1,y1); enemy_car1(x1,y1); if(((y1+89) >= y) && (((x>=x1) && (x<=x1+70)) || (x<=x1 && x+70>=x1+10))) { accident(); } if(kbhit()) { ch = getche(); if(ch==77) { temp++; if(x>=340) { x-=70; car(x,y); } car_clear(x,y); x+=70; car(x,y); } if(ch==75) { if(x<=150) { x+=70; car(x,y); } car_clear(x,y); x-=70; car(x,y); } if(ch==27) { ExitGame(); } } delay(random(10)); } delay(1); } }
void CGameGunHound::Loop() { //----------------------------------------- //ハウンドメイン //----------------------------------------- if( m_bResetOK ) { if( m_bResetPlease ) { m_bResetPlease = gxFalse; m_sEndSeq = -1; ChangeGameSeq( enMainSeqGameEnd ); } else if( CDashBoard::GetInstance()->IsMenuBar() ) { m_bPauseFlag = gxTrue; } else { m_bPauseFlag = gxFalse; } } switch( m_GameSeq ){ case enMainSeqInit: //----------------------------------------- //ゲーム初期化 //----------------------------------------- m_bBriefingRoot = gxTrue; m_bResetOK = gxFalse; viiDbg::log("ハウンドシーケンス:enMainSeqInit"); //SaveDataInit(); //GameConfigLoad(); m_bPauseFlag = gxFalse; ChangeGameSeq( enMainSeqStart ); break; case enMainSeqStart: //----------------------------------------- //スコア初期化 //----------------------------------------- m_bResetOK = gxFalse; viiDbg::log("ハウンドシーケンス:enMainSeqStart"); #ifdef _VII_DEBUG_ CDashBoard::GetInstance()->SetMenuDisable(gxFalse); CDashBoard::GetInstance()->SetLogo(gxFalse); CDashBoard::GetInstance()->SetWallPaper(gxFalse); ChangeGameSeq( enMainSeqRestart ); #else // ChangeGameSeq( enMainSeqGameOpeningDemo ); CDashBoard::GetInstance()->SetMenuDisable(gxFalse); CDashBoard::GetInstance()->SetLogo(gxFalse); CDashBoard::GetInstance()->SetWallPaper(gxFalse); ChangeGameSeq( enMainSeqGameTitle ); #endif break; case enMainSeqGameTitle: //----------------------------------------- //タイトルのシーケンス //----------------------------------------- UploadTexture(); m_bResetOK = gxFalse; ChangeGameSeq( enMainSeqRestart ); break; case enMainSeqRestart: //----------------------------------------- //リスタートのポイント //----------------------------------------- m_bResetOK = gxFalse; ResetClass(); #ifdef GX_DEBUG ChangeGameSeq( enMainSeqDebugMenu ); #else ChangeGameSeq( enMainSeqGameMainMenu ); #endif break; case enMainSeqGameMainMenu: //----------------------------------------- //メインメニューのシーケンス //----------------------------------------- m_bResetOK = gxTrue; CDashBoard::GetInstance()->SetMenuDisable(gxTrue); switch( MainMenu() ){ case enMenuSeqBack: case enMenuSeqNext: g_StGameInfo.Reset(); if( m_sMainMenuSelected == CMainMenu::enMainMenuOpening ) { //オープニングへ ChangeGameSeq( enMainSeqGameOpeningDemo ); } else if( m_sMainMenuSelected == CMainMenu::enMainMenuDebug ) { //デバッグモードへ g_StGameInfo.m_sGameMode = StGameInfo::enGameModeNormal; ChangeGameSeq( enMainSeqDebugMenu ); } else if( m_sMainMenuSelected == CMainMenu::enMainMenuEnding ) { //エンディング CDashBoard::GetInstance()->SetIcon( enIconNone ); ChangeGameSeq( enMainSeqGameEndingDemo ); } else if( m_sMainMenuSelected == CMainMenu::enMainMenuStart ) { //ゲームスタートへ CDashBoard::GetInstance()->SetIcon( enIconNone ); g_StGameInfo.m_sGameMode = StGameInfo::enGameModeNormal; g_StGameInfo.m_bMessage = gxTrue; ChangeGameSeq( enMainSeqGameBriefing ); } else if( m_sMainMenuSelected == CMainMenu::enMainMenuTutorial ) { //チュートリアルスタートへ g_StGameInfo.m_bMusic = gxTrue; g_StGameInfo.m_bMessage = gxTrue; g_StGameInfo.m_bReplay = gxFalse; CDashBoard::GetInstance()->SetIcon( enIconNone ); g_StGameInfo.m_sGameMode = StGameInfo::enGameModeNormal; g_StGameInfo.PlayStage = enScenarioTutorial; StageSet(); g_StGameInfo.PlayArea = m_sSelectedStage; ChangeGameSeq( enMainSeqGameInit ); } else if( m_sMainMenuSelected == CMainMenu::enMainMenuMission ) { //ゲームスタートへ CDashBoard::GetInstance()->SetIcon( enIconNone ); g_StGameInfo.m_sGameMode = StGameInfo::enGameModeMission; g_StGameInfo.PlayStage = m_sSelectedStage;//enScenarioTutorial; g_StGameInfo.PlayArea = 0; StageSet(); ChangeGameSeq( enMainSeqGameInit ); } else if( m_sMainMenuSelected == CMainMenu::enMainMenuExit ) { //ゲーム終了 ExitGame(); } break; default: break; } break; case enMainSeqGameOpeningDemo: //----------------------------------------- //オープニングのシーケンス //----------------------------------------- m_bResetOK = gxFalse; if( AdvertiseDemo() ) { ChangeGameSeq( enMainSeqGameTitle ); } break; case enMainSeqDebugMenu: //----------------------------------------- //デバッグメニュー //----------------------------------------- m_bResetOK = gxTrue; switch( DebugMenu() ) { case enMenuSeqBack: ChangeGameSeq( enMainSeqGameMainMenu ); break; case enMenuSeqNext: // g_StGameInfo.Reset(); g_StGameInfo.m_bMessage = gxTrue; g_StGameInfo.m_bMusic = gxTrue; g_StGameInfo.m_bReplay = gxFalse; ChangeGameSeq( enMainSeqGameInit ); break; } break; case enMainSeqGameBriefing: g_StGameInfo.ContinueArea = 0; CCockpit::GetInstance()->SetHidden(); CDashBoard::GetInstance()->SetMenuDisable(gxFalse); m_bResetOK = gxTrue; if( m_pSetUp == NULL ) { //セットアップ画面を作る m_pSetUp = new CSetUp( -1 );//g_StGameInfo.PlayStage ); } if( BriefingMain() ) { //ステージ決定 StageSet(); m_bBriefingRoot = gxTrue; ChangeGameSeq( enMainSeqGameSetUp ); } CockpitControl(); break; case enMainSeqGameSetUp: CCockpit::GetInstance()->SetHidden(); m_bResetOK = gxTrue; if( m_pSetUp->IsEnd() ) { ChangeGameSeq( enMainSeqGameBefore ); } CockpitControl(); break; case enMainSeqGameBefore: //----------------------------------------- //ゲーム初期化 //----------------------------------------- CCockpit::GetInstance()->ReNew(); CCockpit::GetInstance()->SetHidden(); CockpitControl(); m_bResetOK = gxTrue; if( !m_pSetUp->IsWait() ) { //CCockpit::GetInstance()->Reset(); viiMus::StopBGM( enSoundBgm1 ); ChangeGameSeq( enMainSeqGameInit ); } break; case enMainSeqGameInit: //----------------------------------------- //ゲーム初期化 //----------------------------------------- CCockpit::GetInstance()->Destroy(); CCockpit::GetInstance()->SetHidden(); m_bResetOK = gxFalse; if( pGame ) delete pGame; pGame = new CGameManager(); GameInit(); pGame->init(); CockpitControl(); viiMus::Destroy(); ChangeGameSeq( enMainSeqGameMain ); break; case enMainSeqGameMain: //----------------------------------------- //ゲームメイン //----------------------------------------- CDashBoard::GetInstance()->SetMenuDisable(gxFalse); m_bResetOK = gxTrue; if( m_pSetUp ) { m_bResetOK = gxFalse; m_pSetUp->Draw(); if( m_pSetUp->GoDestroy() ) { //---------------------------------------------- //セットアップ終了 //---------------------------------------------- CCockpit::GetInstance()->Reset(); delete m_pSetUp; m_pSetUp = NULL; } } if( !m_bGameStart && pGame->IsGameStart() ) { m_bGameStart = gxTrue; } GameMain(); if( pGame->IsStageClear() ) { m_sEndSeq = pGame->GetNextSeq(); //m_sEndSeq = 1; //次へ ChangeGameSeq( enMainSeqGameEnd ); } else if( CCockpit::GetInstance()->IsGameOver() ) { m_sEndSeq = enClearSeqContinue; ChangeGameSeq( enMainSeqGameEnd ); } break; case enMainSeqGameEnd: //----------------------------------------- //ゲーム終了 //----------------------------------------- m_bResetOK = gxFalse; GameEnd(); if( pGame ) { delete pGame; pGame = NULL; } if( !m_bBriefingRoot ) { m_sEndSeq = 0; } CCockpit::GetInstance()->ReNew(); if( m_sMainMenuSelected == CMainMenu::enMainMenuMission || m_sMainMenuSelected == CMainMenu::enMainMenuTutorial) { //--------------------------------------- //ストーリーモード以外の時 //--------------------------------------- //スコアを加算する g_CHoundSaveData.UpdateHighScore( g_StGameInfo.m_uAllScore ); //ミッションモードだった ChangeGameSeq( enMainSeqGameMainMenu ); //チュートリアルモードだった ChangeGameSeq( enMainSeqGameMainMenu ); } else if( m_sEndSeq == enClearSeqStageClear ) { #ifdef _TRIAL_VERSION_ //タイトルに戻る g_CHoundSaveData.UpdateHighScore( g_StGameInfo.m_uAllScore ); ChangeGameSeq( enMainSeqRestart ); #else //ステージクリアだった g_StGameInfo.SetStageClear( g_StGameInfo.PlayStage ); switch( g_StGameInfo.PlayStage ){ case enScenarioJungle: g_CHoundSaveData.SetHiddenOpen( enHiddenItemMission2 ); break; case enScenarioRiver: g_CHoundSaveData.SetHiddenOpen( enHiddenItemMission3 ); break; case enScenarioMountain: g_CHoundSaveData.SetHiddenOpen( enHiddenItemMission4 ); break; case enScenarioBase: g_CHoundSaveData.SetHiddenOpen( enHiddenItemMission5 ); break; } ChangeGameSeq( enMainSeqGameBriefing ); #endif } else if( m_sEndSeq == enClearSeqContinue ) { //ステージ失敗だった(コンティニュールート) ChangeGameSeq( enMainSeqGameContinue ); } else if( m_sEndSeq == enClearSeqGameOver ) { //ゲームオーバーだった ChangeGameSeq( enMainSeqGameContinue ); } else if( m_sEndSeq == enClearSeqEnding ) { //エンディングだった g_StGameInfo.SetStageClear( g_StGameInfo.PlayStage ); g_CHoundSaveData.UpdateHighScore( MISSION_ALLOVER_BONUS ); Uint32 uScore = 0; //ゲームスコアを加算 m_stEndingBonus.uAllScore = g_StGameInfo.m_uAllScore; //オールオーバーボーナスをコンティニュー回数で割る m_stEndingBonus.uContinueBonus = MISSION_ALLOVER_BONUS/(g_StGameInfo.m_sContinueCnt+1); m_stEndingBonus.uContinueBonus = m_stEndingBonus.uContinueBonus/10; m_stEndingBonus.uContinueBonus = m_stEndingBonus.uContinueBonus*10; //Trueエンディングの場合場合ボーナス m_stEndingBonus.uTrueEndBonus = 0; if( g_StGameInfo.m_bTrueEnd ) { m_stEndingBonus.uTrueEndBonus = ENDING_TRUEVERSION_BONUS; g_CHoundSaveData.SetHiddenOpen( enHiddenItemViewEnding ); } //ノーコンティニューだった場合2倍ボーナス if( g_StGameInfo.m_sContinueCnt == 0 ) { m_stEndingBonus.uNoContinueBonus = m_stEndingBonus.uAllScore + m_stEndingBonus.uContinueBonus + m_stEndingBonus.uTrueEndBonus; } uScore = m_stEndingBonus.uAllScore; uScore += m_stEndingBonus.uContinueBonus; uScore += m_stEndingBonus.uTrueEndBonus; uScore += m_stEndingBonus.uNoContinueBonus; m_stEndingBonus.uTotalScore = uScore; //スコアを加算する g_CHoundSaveData.UpdateHighScore( uScore ); ChangeGameSeq( enMainSeqGameEndingDemo ); } else { //リセットだった /* if( m_bGameStart && m_sMainMenuSelected == CMainMenu::enMainMenuStart ) { m_sResetCount = 120; ChangeGameSeq( enMainSeqResetInGame ); } else { ChangeGameSeq( enMainSeqRestart ); } */ ChangeGameSeq( enMainSeqRestart ); } break; case enMainSeqGameContinue: //----------------------------------------- //コンティニュー //----------------------------------------- m_bResetOK = gxTrue; m_bGameStart = gxFalse; switch( ContinueScreen() ){ case enMenuSeqNext: { //タイトルに戻る g_CHoundSaveData.UpdateHighScore( g_StGameInfo.m_uAllScore ); ChangeGameSeq( enMainSeqRestart ); } break; case enMenuSeqBack: { //コンティニューする // Sint32 sMem = g_StGameInfo.PlayArea; // StageSet(); //スコアをリセットする /* g_StGameInfo.m_uAllScore = (g_StGameInfo.m_uAllScore/2); g_StGameInfo.m_uAllScore -= g_StGameInfo.m_uAllScore%10;; */ //スコア更新 g_CHoundSaveData.UpdateHighScore( g_StGameInfo.m_uAllScore ); g_StGameInfo.m_uAllScore = 0;//(g_StGameInfo.m_uAllScore/2); g_StGameInfo.m_uStageScore = g_StGameInfo.m_uAllScore; if( g_StGameInfo.m_sContinueCnt < 99 ) g_StGameInfo.m_sContinueCnt ++; g_StGameInfo.ContinueArea = g_StGameInfo.PlayArea; ChangeGameSeq( enMainSeqGameInit ); } break; default: break; } break; case enMainSeqGameEndingDemo: //----------------------------------------- //ゲーム終了 //----------------------------------------- m_bResetOK = gxTrue; m_bGameStart = gxFalse; CCockpit::GetInstance()->SetHidden(); CDashBoard::GetInstance()->SetMenuDisable(gxFalse); if( EndingDemo() ) { ChangeGameSeq( enMainSeqRestart ); } break; case enMainSeqResetInGame: if( m_sResetCount > 0 ) { m_sResetCount --; } else { g_StGameInfo.m_uAllScore = 0; g_StGameInfo.m_uStageScore = 0; g_StGameInfo.ContinueArea = g_StGameInfo.PlayArea; CCockpit::GetInstance()->ReNew(); ChangeGameSeq( enMainSeqGameInit ); } break; default: break; } viiMus::GetInstance()->Action(); CFadeManager::GetInstance()->action(); }