/////////////////////////////////////////////////////////////////////////////////////////// // // 主函数入口 // ////////////////////////////////////////////////////////////////////////////////////////// int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { // 初始化游戏引擎 if( !dInitGameEngine( hInstance, lpCmdLine ) ) return 0; // To do : 在此使用API更改窗口标题 dSetWindowTitle("ARPG仙剑"); //全屏 dResizeWindow( GetSystemMetrics( SM_CXFULLSCREEN ), GetSystemMetrics( SM_CYFULLSCREEN ) ); //隐藏鼠标 dShowCursor( 0 ); //播放开始界面bgm,群山飞鹤 PlaySound(NULL, NULL, SND_PURGE); //PlaySound("game/data/audio/bgm_qunshan.wav", NULL, SND_ASYNC|SND_LOOP); // 引擎主循环,处理屏幕图像刷新等工作 while( dEngineMainLoop() ) { // 获取两次调用之间的时间差,传递给游戏逻辑处理 float fTimeDelta = dGetTimeDelta(); // 执行游戏主循环 GameMainLoop( fTimeDelta ); }; // 关闭游戏引擎 dShutdownGameEngine(); return 0; }
int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { int g_iGameState = 0; // 初始化游戏引擎 if( !dInitGameEngine( hInstance, lpCmdLine ) ) return 0; // To do : 在此使用API更改窗口标题 dSetWindowTitle("Lesson"); // 引擎主循环,处理屏幕图像刷新等工作 while( dEngineMainLoop() ) { // 获取两次调用之间的时间差,传递给游戏逻辑处理 float fTimeDelta = dGetTimeDelta(); /* for( iLoopY = 0; iLoopY < BLOCK_COUNT; iLoopY++ ) { for( iLoopX = 0; iLoopX < BLOCK_COUNT; iLoopX++ ) { iOneIndex = XYToOneIndex( iLoopX, iLoopY ); } // 数组的最后一个 if( BLOCK_COUNT - 1 == iLoopX && BLOCK_COUNT - 1 == iLoopY ) { g_iBlockState[iLoopY][iLoopX] = 0; g_szBlockName[iOneIndex][0] = '\0'; } else { // 在当前剩余未使用到的数值里随机一个出来,赋值给二维数组 iRandIndex = dRandomRange( 0, iDataCount - 1 ); g_iBlockState[iLoopY][iLoopX] = iRandData[iRandIndex]; strcpy( g_szBlockName[iOneIndex], dMakeSpriteName( "PictureBlock", g_iBlockState[iLoopY][iLoopX] ) ); // 将该精灵移动到对应的位置 MoveSpriteToBlock( g_szBlockName[iOneIndex], iLoopX, iLoopY ); } } for( iLoop = iRandIndex; iLoop < iDataCount - 1; iLoop++ ) { iRandData[iLoop] = iRandData[iLoop + 1]; } // 剩余有效值总数减一 iDataCount--; */ // 执行游戏主循环 GameMainLoop( fTimeDelta ); }; // 关闭游戏引擎 dShutdownGameEngine(); return 0; }
int main(void) { InitConsole(); Welcome(); while (1) { GameMainLoop(); ClearConsoleBuffer(); setConsoleColor(FRED); DrawString((WIDTH - strlen("You are dead")) / 2, HEIGHT / 2, "You are dead"); resetConsoleColor(); RedrawConsole(); while (!IsKeyPressed(VK_RETURN)); } return 0; }
int main(int argc, char** argv) { //int result; OS_Init(); LoggerCreate(TRUE,"log.txt",LOGGER_APPEND,LOGGER_LEVEL_ALL,LOGGER_FORMAT_C); LoggerInfo("Initializing game"); if(SDL_Init(SDL_INIT_EVERYTHING)) GameCrash("Initialized SDL failed"); LoggerInfo("SDL initialized"); MathInit(); RM_InitResourceManager(); PMD_Init(); RE_InitWindow(WINDOW_WIDTH,WINDOW_HEIGHT); IN_InitInput(); InitEntities(); InitAttributes(); GameMainLoop(); GameClose(); return 0; }
void StartMap(const std::string &filename, bool clean) { std::string nc, rc; gcn::Widget *oldTop = Gui->getTop(); gcn::Container *container = new gcn::Container(); Containers.push_back(container); container->setDimension(gcn::Rectangle(0, 0, Video.Width, Video.Height)); container->setOpaque(false); Gui->setTop(container); NetConnectRunning = 0; InterfaceState = IfaceStateNormal; // Create the game. DebugPrint("Creating game with map: %s\n" _C_ filename.c_str()); if (clean) { CleanPlayers(); } GetDefaultTextColors(nc, rc); CreateGame(filename.c_str(), &Map); UI.StatusLine.Set(NameLine); SetMessage("%s", _("Do it! Do it now!")); // Play the game. GameMainLoop(); // Clear screen Video.ClearScreen(); Invalidate(); CleanGame(); InterfaceState = IfaceStateMenu; SetDefaultTextColors(nc, rc); Gui->setTop(oldTop); Containers.erase(std::find(Containers.begin(), Containers.end(), container)); delete container; }