void MainWindow::downloadList() { QSettings settings; QString oldVersion = settings.value("updates/version", "0.0").toString(); delete _model; _model = new BamModel; ui->addonList->setModel(_model); //_model->downloadList(QUrl("http://127.0.0.1:8000/bam/addon_pack/" + oldVersion + "/")); _model->downloadList(QUrl("http://hh.unit22.org/bam/addon_pack/" + oldVersion + "/")); connect(_model, SIGNAL(xmlProcessed()), this, SLOT(resizeView())); connect(ui->addonList ,SIGNAL(clicked(QModelIndex)), _model, SLOT(setCheckBox(QModelIndex)), Qt::UniqueConnection ); connect(ui->install, SIGNAL(clicked()), _model, SLOT(installChecked())); connect(_model, SIGNAL(newVersionFound(bool, QString, QString)), this, SLOT(setNewVersionInfo(bool, QString, QString))); connect(_model, SIGNAL(totalFilesSizeChanged(int)), this, SLOT(setTotalFilesSize(int))); connect(_model, SIGNAL(runGame()), this, SLOT(runGame())); }
void main() { coreLoad(Window); coreLoad(Time); coreLoad(Input); coreLoad(Camera); coreLoad(Factory); coreLoad(Asset); systemLoad(TransformUpdate); systemLoad(Rendering); initCore(); // Safe to load assets and make dudes. core(Asset).loadShader("Flat","./shaders/simpleShader.vert", "./shaders/simpleShader.frag"); Vertex verts[3] = { { { 0, 30, 0, 1 }, { 0, 1, 1, 1 } }, { { -30, -30, 0, 1 }, { 1, 1, 0, 1 } }, { { 30, -30, 0, 1 }, { 1, 0, 1, 1 } } }; Triangle tris[1] = { 0, 1, 2 }; core(Asset).loadMesh("Triangle", verts, 3, tris, 1); core(Factory).MakeTriangle(); runGame(); }
void Game::startGame() { //Init singletons new OgreFW(); new SoundEngine(); new ScoreManager(); new NetworkEventManager(); if(!OgreFW::getSingletonPtr()->initOgre("Lapins sautillant", this, 0)) //if(!OgreFW::getSingletonPtr()->initOgre("Lapilles sautillant", NULL, NULL)) return; // VERY IMPORTANT: THE EFFECTSFACTORY NEEDS IT new EffectsFactory(); m_bShutdown = false; // Init random number generator srand( (unsigned int) time(NULL) + boost::interprocess::detail::get_current_process_id() ); OgreFW::getSingletonPtr()->m_pLog->logMessage("Game initialized!"); // Init the level Fectory //myLevelFactory = new RandomLevelFactory(OgreFW::getSingletonPtr()->m_pSceneMgr); myLevelFactory = new LevelFromFileFactory(OgreFW::getSingletonPtr()->m_pSceneMgr); // Set Ogre LOD pars Ogre::MaterialManager::getSingleton().setDefaultTextureFiltering(Ogre::TFO_TRILINEAR); Ogre::MaterialManager::getSingleton().setDefaultAnisotropy(1); NetworkEventManager::getSingletonPtr()->registerListener(this); // Proceed setupScene(); runGame(); }
int main() { printf("#########################################\n"); printf("# #\n"); printf("# Quiz #\n"); printf("# #\n"); printf("#########################################\n\n"); struct listNode * listPointer; loadQuestionFromFile(&listPointer); struct gameData gameData; //zerujemy wartosci gameData.pointsPlayers[0] = 0; gameData.pointsPlayers[1] = 0; gameData.pointsPlayers[2] = 0; gameData.pointsPlayers[3] = 0; enterPlayerNames(&gameData); runGame(&gameData, listPointer); deleteList(listPointer); return 0; }
Common::Error Parallaction_br::go() { bool splash = true; while (!shouldQuit()) { if (getFeatures() & GF_DEMO) { scheduleLocationSwitch("camalb"); _nextPart = 1; _input->_inputMode = Input::kInputModeGame; } else { startGui(splash); // don't show splash after first time splash = false; } // initCharacter(); while (((_engineFlags & kEngineReturn) == 0) && (!shouldQuit())) { runGame(); } _engineFlags &= ~kEngineReturn; cleanupGame(); } return Common::kNoError; }
int main() { unsigned short int corners[4] = {0,2,6,8}; unsigned short int sides[4] = {1,3,5,7}; unsigned short int center = 4; // Pointer for tictactoe structure ticTacToeBoard *selector = malloc(sizeof(*selector)); unsigned short int* intPtr = (unsigned short int*) (selector+5); char *charPtr = (char*) selector; *intPtr = 1; while(*intPtr) { // Set up game setUpGame(selector, charPtr, intPtr); // Run Game runGame(selector, corners, sides, center, charPtr, intPtr); // Ask to replay replay(selector, intPtr); } printf(" Thanks for playing!\n"); // Exits program exit(0); }
void LSidle() { switch (LoadingProgress++) { case 0: initLogo();break; case 1: initializeBallTables(BallResolution); break; //table init case 2: Ball[0].Init(0,TextureSize,BallResolution,Shadow); break; //ball0 init case 3: Ball[1].Init(1,TextureSize,BallResolution,Shadow); break; case 4: Ball[2].Init(2,TextureSize,BallResolution,Shadow); break; case 5: Ball[3].Init(3,TextureSize,BallResolution,Shadow); break; case 6: Ball[4].Init(4,TextureSize,BallResolution,Shadow); break; case 7: Ball[5].Init(5,TextureSize,BallResolution,Shadow); break; case 8: Ball[6].Init(6,TextureSize,BallResolution,Shadow); break; case 9: Ball[7].Init(7,TextureSize,BallResolution,Shadow); break; case 10: Ball[8].Init(8,TextureSize,BallResolution,Shadow); break; case 11: Ball[9].Init(9,TextureSize,BallResolution,Shadow); break; case 12: Ball[10].Init(10,TextureSize,BallResolution,Shadow); break; case 13: Ball[11].Init(11,TextureSize,BallResolution,Shadow); break; case 14: Ball[12].Init(12,TextureSize,BallResolution,Shadow); break; case 15: Ball[13].Init(13,TextureSize,BallResolution,Shadow); break; case 16: Ball[14].Init(14,TextureSize,BallResolution,Shadow); break; case 17: Ball[15].Init(15,TextureSize,BallResolution,Shadow); break; case 18: Table.Init(TableTextureSize); break; case 19: Lighting.Init(AmbientLighting,TableLamps,GreenLamp,Reflections); break; case 20: ShotStrength.Init(); break; case 21: Menu.Init(DisplayTextureSize); break; case 22: Menu.LoadLanguage(900); break; case 23: Menu.LoadLanguage(901); break; case 24: Menu.LoadLanguage(999); break; case 25: Menu.Init(DisplayTextureSize); break; case 26: BoardLayout(); break; case 27: Judge.NewGame(GameType); break; case 28: runGame(); break; } glutPostWindowRedisplay(CurrentWindow); }
/* ************************************** // // ./CheapTalk [game] [iters] [cheaptalk] // // ************************************** */ int main(int argc, char *argv[]) { if (argc < 3) { printf("not enough commandline parameters\n"); exit(1); } // read in the game file double ***M; int A[2]; int iters = atoi(argv[2]); printf("iters = %i\n", iters); if (argc > 3) { if (!strcmp(argv[3], "cheaptalk")) { cheapTalk = true; printf("cheapTalk = true\n"); } } M = readPayoffMatrixFromFile(A, argv[1]); runGame(M, A, iters); cleanPayoffMatrix(M, A); return 0; }
Common::Error AgiEngine::go() { if (_game.mouseEnabled) { CursorMan.showMouse(true); } inGameTimerReset(); runGame(); return Common::kNoError; }
//init the game scene void GameScene_17::InitScene() { background = CCSprite::create("17_scene.png"); background->setPosition(ccp(visibleOrigin.x + visibleSize.width * 0.5, visibleOrigin.y + visibleSize.height * 0.5)); this->addChild(background, 0); userDataFile->setIntegerForKey("CurGameScene", 17); runGame(); }
int gameMainOpen(void) { unsigned int joy; tmouse *mo; int sound; int draw; actualLevel->view.buf=GetVideo(); joy=GetJoystick(); mo=getMouseInf(); actualLevel->mouse=mo; actualLevel->key=joy; draw=getDrawFrame(); switch (runStateGame) { case 0: if(loadGame(actualLevel,draw)) runStateGame=1; break; case 1: runGame(actualLevel,draw); break; default: break; } wipeView(&actualLevel->transiction); if(getRenderAudio()) sound=SRenderAudio(); if(draw) FlipVideo(); WaitSyncTimer(); getFPS(&Vfpsg,&Vfps); return draw; }
Common::Error Parallaction_ns::go() { _saveLoad->renameOldSavefiles(); _globalFlagsNames = _disk->loadTable("global"); startGui(); while (!shouldQuit()) { runGame(); } return Common::kNoError; }
Common::Error AgiEngine::go() { CursorMan.showMouse(true); if (_game.state < STATE_LOADED) { do { mainCycle(); } while (_game.state < STATE_RUNNING); } runGame(); return Common::kNoError; }
void CGEEngine::cge_main() { memset(_barriers, 0xFF, sizeof(_barriers)); if (!_mouse->_exist) error("%s", _text->getText(kTextNoMouse)); if (!_resman->exist(kSavegame0Name)) _mode = 2; _debugLine->_flags._hide = true; if (_horzLine) _horzLine->_flags._hide = true; if (_music && _soundOk) _midiPlayer->loadMidi(0); if (_startGameSlot != -1) { // Starting up a savegame from the launcher _mode++; runGame(); _startupMode = 2; if (_flag[3]) // Flag FINIS movie(kEndgExt); } else { if (_mode < 2) movie(kLgoExt); if (showTitle("WELCOME")) { if (_mode == 1) movie(kIntroExt); runGame(); _startupMode = 2; if (_flag[3]) // Flag FINIS movie(kEndgExt); } else _vga->sunset(); } }
int main(void){ // the watchdog WDT->WDT_MR = WDT_MR_WDDIS; // Set the clock up systemInit(); //84 MHZ presentation(); runGame(); while (1){ } // WHILE(1) } //main
void DamnCute::Menu::MoveReturn() { if (_alive) { if( (*_itButtons)->getName() == "start") { runGame(); delete(this); } _alive = false; } else _alive = true; (*_itButtons)->setAlive2(); for (std::vector<DamnCute::Menu::Button*>::iterator it = _buttons.begin() ; it != _buttons.end(); ++it) (*it)->setAlive(); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); QCoreApplication::setOrganizationName("Bending software"); QCoreApplication::setApplicationName("Beta addon downloader"); _model = new BamModel; ui->addonList->setModel(_model); downloadList(); connect(ui->actionSettings, SIGNAL(triggered()), this, SLOT(openSettings())); connect(ui->runGame, SIGNAL(clicked()), this, SLOT(runGame())); }
int main(int argc, char **argv) { while(1){ int index; int c = getopt_long(argc, argv, "hva:", opts, &index); if(c == -1){ break; } switch(c){ case 'v': printVersion(); return 0; case 'h': printHelp(); return 0; case 'a': strcpy(assetdir, optarg); break; default: return 1; } } // Add trailing / when missing from the asset dir size_t len = strlen(assetdir); if(assetdir[len - 1] != '/'){ assetdir[len] = '/'; assetdir[++len] = '\0'; } if(pickFontFromDir(assetdir) < 0){ fprintf(stderr, "Could not find a font!\n"); return 1; } createWindow("Ancestral Roots - " TOSTRING(ROGUELIEK_VERSION), DEFAULT_WIDTH, DEFAULT_HEIGHT); runGame(); showCursor(); destroyWindow(); return 0; }
int main() { srand(time(NULL)); Matrix maze = {NULL, 0, 0}; Matrix fog = {NULL, 0, 0}; int width = 50, height = 40; Position hero, exit; allocateMatrix(&maze, width, height); allocateMatrix(&fog, width, height); generateMaze(maze, &hero, &exit); generateFog(fog, hero); runGame(maze, fog, exit, hero); freeMatrix(&fog); freeMatrix(&maze); return 0; }
Common::Error GlkEngine::run() { // Open up the game file Common::String filename = getFilename(); if (!Common::File::exists(filename)) return Common::kNoGameDataFoundError; if (Blorb::isBlorb(filename)) { // Blorb archive _blorb = new Blorb(filename, getInterpreterType()); SearchMan.add("blorb", _blorb, 99, false); if (!_gameFile.open("game", *_blorb)) return Common::kNoGameDataFoundError; } else { // Check for a secondary blorb file with the same filename Common::String baseName = filename; while (baseName.contains('.')) baseName.deleteLastChar(); if (Common::File::exists(baseName + ".blorb")) { _blorb = new Blorb(baseName + ".blorb", getInterpreterType()); SearchMan.add("blorb", _blorb, 99, false); } else if (Common::File::exists(baseName + ".blb")) { _blorb = new Blorb(baseName + ".blb", getInterpreterType()); SearchMan.add("blorb", _blorb, 99, false); } // Open up the game file if (!_gameFile.open(filename)) return Common::kNoGameDataFoundError; } // Perform initialization initialize(); // Play the game runGame(); return Common::kNoError; }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8")); smallSize.setCoords(30,30,840,600); setGeometry(smallSize); setWindowTitle("QMilion - gra edukacyjna"); button = new QPushButton("Rozpocznij, grę!", this); button->setGeometry(300,520,200,40); editorWidget = new QuizEdit(this); editorWidget->setGeometry(6,20,800,487); showWidget = new QuizShow(this); showWidget->setGeometry(0,5,744,600); showWidget->hide(); isGame = false; connect(button,SIGNAL(clicked()),this,SLOT(runGame())); }
void worker() { cerr << "Thread #" << this_thread::get_id() << " starting up." << endl; while(true) { // Blocking call. Job j = jobQueue.pop(); if(j.shutdown) { cerr << "Thread #" << this_thread::get_id() << " shutting down." << endl; return; } cerr << "Thread #" << this_thread::get_id() << " starting job." << endl; double score = runGame(j.config); double scoreDiff = -(score - j.currentScore); double flip = (float) drand48() / RAND_MAX; double acc = exp(-scoreDiff / j.temp); bool accepted = scoreDiff < 0 || acc > flip; Result res = { j.config, score, accepted}; resultQueue.push(res); cerr << "Thread #" << this_thread::get_id() << " finished job." << endl; } }
int main() { REG_DISPCTL = MODE3 | BG2_ENABLE; int isReset = 1; while(1) { // WaitForVblank(); if (KEY_DOWN_NOW(BUTTON_START)) { switch(state) { case TITLE: // start the game state = NORMAL; startGame(); break; case GAMEOVER: // reset initiate(); break; } } else if (KEY_DOWN_NOW(BUTTON_SELECT) || isReset) { initiate(); // reset whenever select is hit or at the start isReset = 0; } else if (state == NORMAL) { if(KEY_DOWN_NOW(BUTTON_A)) { goingUp = 1; jump(); } else { goingUp = 0; } runGame(); } } return 0; }
int utf8_main(int argc, char ** argv) { // Initialize Random now so that the crash handler can use it Random::seed(); // Initialize the crash handler { CrashHandler::initialize(argc, argv); std::string command_line; for(int i = 1; i < argc; i++) { command_line += util::escapeString(argv[i], "\\\" '$!"); command_line += ' '; } CrashHandler::setVariable("Command line", command_line); } { std::ostringstream oss; oss << ARX_COMPILER_VERNAME; CrashHandler::setVariable("Compiler", oss.str()); credits::setLibraryCredits("compiler", oss.str()); CrashHandler::setVariable("CMake", cmake_version); credits::setLibraryCredits("build", "CMake " + cmake_version); oss.str(std::string()); oss << (BOOST_VERSION / 100000) << '.' << (BOOST_VERSION / 100 % 1000) << '.' << (BOOST_VERSION % 100); CrashHandler::setVariable("Boost version", oss.str()); credits::setLibraryCredits("boost", "Boost " + oss.str()); oss.str(std::string()); oss << GLM_VERSION_MAJOR << '.' << GLM_VERSION_MINOR << '.' << GLM_VERSION_PATCH << '.' << GLM_VERSION_REVISION; CrashHandler::setVariable("GLM version", oss.str()); credits::setLibraryCredits("math", "GLM " + oss.str()); oss.str(std::string()); oss << zlibVersion(); CrashHandler::setVariable("zlib version (headers)", ZLIB_VERSION); CrashHandler::setVariable("zlib version (runtime)", oss.str()); credits::setLibraryCredits("deflate", "zlib " + oss.str()); credits::setLibraryCredits("image", "stb_image"); } // Also intialize the logging system early as we might need it Logger::initialize(); CrashHandler::registerCrashCallback(Logger::quickShutdown); Logger::add(new logger::CriticalErrorDialog); // Parse the command line and process options ExitStatus status = parseCommandLine(argc, argv); platform::initializeTime(); benchmark::begin(benchmark::Startup); // Setup user, config and data directories if(status == RunProgram) { status = fs::paths.init(); } if(status == RunProgram) { // Configure the crash report location CrashHandler::setReportLocation(fs::paths.user / "crashes"); CrashHandler::deleteOldReports(/* nb to keep = */1); // Now that data directories are initialized, create a log file { fs::path logFile = fs::paths.user / "arx.log"; Logger::add(new logger::File(logFile)); CrashHandler::addAttachedFile(logFile); } profiler::initialize(); // 14: Start the game already! LogInfo << "Starting " << arx_name << ' ' << arx_version; runGame(); } benchmark::shutdown(); // Shutdown the logging system // If there has been a critical error, a dialog will be shown now Logger::shutdown(); CrashHandler::shutdown(); return (status == ExitFailure) ? EXIT_FAILURE : EXIT_SUCCESS; }
Common::Error SciEngine::run() { _resMan = new ResourceManager(); assert(_resMan); _resMan->addAppropriateSources(); _resMan->init(); // TODO: Add error handling. Check return values of addAppropriateSources // and init. We first have to *add* sensible return values, though ;). /* if (!_resMan) { warning("No resources found, aborting"); return Common::kNoGameDataFoundError; } */ // Reset, so that error()s before SoundCommandParser is initialized wont cause a crash _soundCmd = NULL; // Add the after market GM patches for the specified game, if they exist _resMan->addNewGMPatch(_gameId); _gameObjectAddress = _resMan->findGameObject(); _scriptPatcher = new ScriptPatcher(); SegManager *segMan = new SegManager(_resMan, _scriptPatcher); // Read user option for forcing hires graphics // Only show/selectable for: // - King's Quest 6 CD // - King's Quest 6 CD demo // - Gabriel Knight 1 CD // - Police Quest 4 CD // TODO: Check, if Gabriel Knight 1 floppy supports high resolution // // Gabriel Knight 1 on Mac is hi-res only, so it should NOT get this option. // Confirmed by [md5] and originally by clone2727. if (Common::checkGameGUIOption(GAMEOPTION_HIGH_RESOLUTION_GRAPHICS, ConfMan.get("guioptions"))) { // GAMEOPTION_HIGH_RESOLUTION_GRAPHICS is available for the currently detected game, // so read the user option now. // We need to do this, because the option's default is "true", but we don't want "true" // for any game that does not have this option. _forceHiresGraphics = ConfMan.getBool("enable_high_resolution_graphics"); } if (getSciVersion() < SCI_VERSION_2) { // Initialize the game screen _gfxScreen = new GfxScreen(_resMan); _gfxScreen->enableUndithering(ConfMan.getBool("disable_dithering")); } else { _gfxScreen = nullptr; } _kernel = new Kernel(_resMan, segMan); _kernel->init(); _features = new GameFeatures(segMan, _kernel); // Only SCI0, SCI01 and SCI1 EGA games used a parser _vocabulary = (getSciVersion() <= SCI_VERSION_1_EGA_ONLY) ? new Vocabulary(_resMan, false) : NULL; // Also, XMAS1990 apparently had a parser too. Refer to http://forums.scummvm.org/viewtopic.php?t=9135 if (getGameId() == GID_CHRISTMAS1990) _vocabulary = new Vocabulary(_resMan, false); _gamestate = new EngineState(segMan); _eventMan = new EventManager(_resMan->detectFontExtended()); #ifdef ENABLE_SCI32 if (getSciVersion() >= SCI_VERSION_2_1_EARLY) { _audio32 = new Audio32(_resMan); } else #endif _audio = new AudioPlayer(_resMan); #ifdef ENABLE_SCI32 if (getSciVersion() >= SCI_VERSION_2) { _video32 = new Video32(segMan, _eventMan); } #endif _sync = new Sync(_resMan, segMan); // Create debugger console. It requires GFX and _gamestate to be initialized _console = new Console(this); // The game needs to be initialized before the graphics system is initialized, as // the graphics code checks parts of the seg manager upon initialization (e.g. for // the presence of the fastCast object) if (!initGame()) { /* Initialize */ warning("Game initialization failed: Aborting..."); // TODO: Add an "init failed" error? return Common::kUnknownError; } // we try to find the super class address of the game object, we can't do that earlier const Object *gameObject = segMan->getObject(_gameObjectAddress); if (!gameObject) { warning("Could not get game object, aborting..."); return Common::kUnknownError; } script_adjust_opcode_formats(); // Must be called after game_init(), as they use _features _kernel->loadKernelNames(_features); // Load our Mac executable here for icon bar palettes and high-res fonts loadMacExecutable(); // Initialize all graphics related subsystems initGraphics(); // Sound must be initialized after graphics because SysEx transfers at the // start of the game must pump the event loop to avoid making the OS think // that ScummVM is hanged, and pumping the event loop requires GfxCursor to // be initialized _soundCmd = new SoundCommandParser(_resMan, segMan, _kernel, _audio, _features->detectDoSoundType()); syncSoundSettings(); syncIngameAudioOptions(); // Patch in our save/restore code, so that dialogs are replaced patchGameSaveRestore(); setLauncherLanguage(); // Check whether loading a savestate was requested int directSaveSlotLoading = ConfMan.getInt("save_slot"); if (directSaveSlotLoading >= 0) { _gamestate->_delayedRestoreGame = true; _gamestate->_delayedRestoreGameId = directSaveSlotLoading; _gamestate->_delayedRestoreFromLauncher = true; // Jones only initializes its menus when restarting/restoring, thus set // the gameIsRestarting flag here before initializing. Fixes bug #6536. if (g_sci->getGameId() == GID_JONES) _gamestate->gameIsRestarting = GAMEISRESTARTING_RESTORE; } // Show any special warnings for buggy scripts with severe game bugs, // which have been patched by Sierra if (getGameId() == GID_LONGBOW) { // Longbow 1.0 has a buggy script which prevents the game // from progressing during the Green Man riddle sequence. // A patch for this buggy script has been released by Sierra, // and is necessary to complete the game without issues. // The patched script is included in Longbow 1.1. // Refer to bug #3036609. Resource *buggyScript = _resMan->findResource(ResourceId(kResourceTypeScript, 180), 0); if (buggyScript && (buggyScript->size == 12354 || buggyScript->size == 12362)) { showScummVMDialog("A known buggy game script has been detected, which could " "prevent you from progressing later on in the game, during " "the sequence with the Green Man's riddles. Please, apply " "the latest patch for this game by Sierra to avoid possible " "problems"); } } if (getGameId() == GID_KQ7 && ConfMan.getBool("subtitles")) { showScummVMDialog("Subtitles are enabled, but subtitling in King's" " Quest 7 was unfinished and disabled in the release" " version of the game. ScummVM allows the subtitles" " to be re-enabled, but because they were removed from" " the original game, they do not always render" " properly or reflect the actual game speech." " This is not a ScummVM bug -- it is a problem with" " the game's assets."); } // Show a warning if the user has selected a General MIDI device, no GM patch exists // (i.e. patch 4) and the game is one of the known 8 SCI1 games that Sierra has provided // after market patches for in their "General MIDI Utility". if (_soundCmd->getMusicType() == MT_GM && !ConfMan.getBool("native_mt32")) { if (!_resMan->findResource(ResourceId(kResourceTypePatch, 4), 0)) { switch (getGameId()) { case GID_ECOQUEST: case GID_HOYLE3: case GID_LSL1: case GID_LSL5: case GID_LONGBOW: case GID_SQ1: case GID_SQ4: case GID_FAIRYTALES: showScummVMDialog("You have selected General MIDI as a sound device. Sierra " "has provided after-market support for General MIDI for this " "game in their \"General MIDI Utility\". Please, apply this " "patch in order to enjoy MIDI music with this game. Once you " "have obtained it, you can unpack all of the included *.PAT " "files in your ScummVM extras folder and ScummVM will add the " "appropriate patch automatically. Alternatively, you can follow " "the instructions in the READ.ME file included in the patch and " "rename the associated *.PAT file to 4.PAT and place it in the " "game folder. Without this patch, General MIDI music for this " "game will sound badly distorted."); break; default: break; } } } if (gameHasFanMadePatch()) { showScummVMDialog("Your game is patched with a fan made script patch. Such patches have " "been reported to cause issues, as they modify game scripts extensively. " "The issues that these patches fix do not occur in ScummVM, so you are " "advised to remove this patch from your game folder in order to avoid " "having unexpected errors and/or issues later on."); } runGame(); ConfMan.flushToDisk(); return Common::kNoError; }
Common::Error SciEngine::run() { g_eventRec.registerRandomSource(_rng, "sci"); // Assign default values to the config manager, in case settings are missing ConfMan.registerDefault("sci_originalsaveload", "false"); ConfMan.registerDefault("native_fb01", "false"); ConfMan.registerDefault("windows_cursors", "false"); // Windows cursors for KQ6 Windows _resMan = new ResourceManager(); assert(_resMan); _resMan->addAppropriateSources(); _resMan->init(); // TODO: Add error handling. Check return values of addAppropriateSources // and init. We first have to *add* sensible return values, though ;). /* if (!_resMan) { warning("No resources found, aborting"); return Common::kNoGameDataFoundError; } */ // Reset, so that error()s before SoundCommandParser is initialized wont cause a crash _soundCmd = NULL; // Add the after market GM patches for the specified game, if they exist _resMan->addNewGMPatch(_gameId); _gameObjectAddress = _resMan->findGameObject(); _gameSuperClassAddress = NULL_REG; SegManager *segMan = new SegManager(_resMan); // Initialize the game screen _gfxScreen = new GfxScreen(_resMan); _gfxScreen->debugUnditherSetState(ConfMan.getBool("disable_dithering")); // Create debugger console. It requires GFX to be initialized _console = new Console(this); _kernel = new Kernel(_resMan, segMan); _features = new GameFeatures(segMan, _kernel); // Only SCI0, SCI01 and SCI1 EGA games used a parser _vocabulary = (getSciVersion() <= SCI_VERSION_1_EGA) ? new Vocabulary(_resMan, false) : NULL; // Also, XMAS1990 apparently had a parser too. Refer to http://forums.scummvm.org/viewtopic.php?t=9135 if (getGameId() == GID_CHRISTMAS1990) _vocabulary = new Vocabulary(_resMan, false); _audio = new AudioPlayer(_resMan); _gamestate = new EngineState(segMan); _eventMan = new EventManager(_resMan->detectFontExtended()); // The game needs to be initialized before the graphics system is initialized, as // the graphics code checks parts of the seg manager upon initialization (e.g. for // the presence of the fastCast object) if (!initGame()) { /* Initialize */ warning("Game initialization failed: Aborting..."); // TODO: Add an "init failed" error? return Common::kUnknownError; } // we try to find the super class address of the game object, we can't do that earlier const Object *gameObject = segMan->getObject(_gameObjectAddress); if (!gameObject) { warning("Could not get game object, aborting..."); return Common::kUnknownError; } _gameSuperClassAddress = gameObject->getSuperClassSelector(); script_adjust_opcode_formats(); // Must be called after game_init(), as they use _features _kernel->loadKernelNames(_features); _soundCmd = new SoundCommandParser(_resMan, segMan, _kernel, _audio, _features->detectDoSoundType()); syncSoundSettings(); syncIngameAudioOptions(); // Initialize all graphics related subsystems initGraphics(); debug("Emulating SCI version %s\n", getSciVersionDesc(getSciVersion())); // Patch in our save/restore code, so that dialogs are replaced patchGameSaveRestore(); setLauncherLanguage(); // Check whether loading a savestate was requested int directSaveSlotLoading = ConfMan.getInt("save_slot"); if (directSaveSlotLoading >= 0) { // call GameObject::play (like normally) initStackBaseWithSelector(SELECTOR(play)); // We set this, so that the game automatically quit right after init _gamestate->variables[VAR_GLOBAL][4] = TRUE_REG; _gamestate->_executionStackPosChanged = false; run_vm(_gamestate); // As soon as we get control again, actually restore the game reg_t restoreArgv[2] = { NULL_REG, make_reg(0, directSaveSlotLoading) }; // special call (argv[0] is NULL) kRestoreGame(_gamestate, 2, restoreArgv); // this indirectly calls GameObject::init, which will setup menu, text font/color codes etc. // without this games would be pretty badly broken } // Show any special warnings for buggy scripts with severe game bugs, // which have been patched by Sierra if (getGameId() == GID_LONGBOW) { // Longbow 1.0 has a buggy script which prevents the game // from progressing during the Green Man riddle sequence. // A patch for this buggy script has been released by Sierra, // and is necessary to complete the game without issues. // The patched script is included in Longbow 1.1. // Refer to bug #3036609. Resource *buggyScript = _resMan->findResource(ResourceId(kResourceTypeScript, 180), 0); if (buggyScript && (buggyScript->size == 12354 || buggyScript->size == 12362)) { showScummVMDialog("A known buggy game script has been detected, which could " "prevent you from progressing later on in the game, during " "the sequence with the Green Man's riddles. Please, apply " "the latest patch for this game by Sierra to avoid possible " "problems"); } } // Show a warning if the user has selected a General MIDI device, no GM patch exists // (i.e. patch 4) and the game is one of the known 8 SCI1 games that Sierra has provided // after market patches for in their "General MIDI Utility". if (_soundCmd->getMusicType() == MT_GM && !ConfMan.getBool("native_mt32")) { if (!_resMan->findResource(ResourceId(kResourceTypePatch, 4), 0)) { switch (getGameId()) { case GID_ECOQUEST: case GID_HOYLE3: case GID_LSL1: case GID_LSL5: case GID_LONGBOW: case GID_SQ1: case GID_SQ4: case GID_FAIRYTALES: showScummVMDialog("You have selected General MIDI as a sound device. Sierra " "has provided after-market support for General MIDI for this " "game in their \"General MIDI Utility\". Please, apply this " "patch in order to enjoy MIDI music with this game. Once you " "have obtained it, you can unpack all of the included *.PAT " "files in your ScummVM extras folder and ScummVM will add the " "appropriate patch automatically. Alternatively, you can follow " "the instructions in the READ.ME file included in the patch and " "rename the associated *.PAT file to 4.PAT and place it in the " "game folder. Without this patch, General MIDI music for this " "game will sound badly distorted."); break; default: break; } } } if (gameHasFanMadePatch()) { showScummVMDialog("Your game is patched with a fan made script patch. Such patches have " "been reported to cause issues, as they modify game scripts extensively. " "The issues that these patches fix do not occur in ScummVM, so you are " "advised to remove this patch from your game folder in order to avoid " "having unexpected errors and/or issues later on."); } runGame(); ConfMan.flushToDisk(); return Common::kNoError; }
//------------------------------------------------------------------------- void mainLoop() { beginFrame(); readKeys(); switch(m_gameState) { case GSTATE_PreFrontEnd: m_scrollText = 0; m_userKeyBits = 0; m_timer = 0; m_lives = 3; m_willy.position.x = 29*8; m_willy.position.y = 64+8; m_willy.direction = 1; m_score = 0; m_oldScore = 0; m_gameState = GSTATE_FrontEnd; renderFrontEnd(FERState_PreRender); drawScores(); case GSTATE_FrontEnd: { char feState; if(!m_userKeyBits) { if(++m_timer > FETime) { m_timer = 0; m_gameState = GSTATE_TextScroll; m_scrollText = (char*)szIntroText; feState = FERState_PreTextScroll; } else { feState = FERState_TitleFlash; } } else { m_gameState = GSTATE_PrePreIngame; feState = FERState_Cleanup; } renderFrontEnd(feState); break; } case GSTATE_TextScroll: { char feState = FERState_NOP; if(!m_userKeyBits) { if(++m_timer > ScrollTimer) { if(!*(++m_scrollText)) { m_gameState = GSTATE_PreDemo; feState = FERState_Cleanup; } m_timer = 0; } } else { m_gameState = GSTATE_PrePreIngame; feState = FERState_Cleanup; } renderFrontEnd(feState); break; } case GSTATE_PreDemo: m_timer = 0; m_level = LEVEL_Central_Cavern; prepLevel(); m_gameState = GSTATE_Demo; case GSTATE_Demo: { if(m_userKeyBits) m_gameState = GSTATE_PreFrontEnd; else { runGame(); if(++m_timer > DemoTime) { m_timer = 0; if(LEVEL_The_Final_Barrier < ++m_level) m_gameState = GSTATE_PreFrontEnd; else prepLevel(); } } break; } case GSTATE_PrePreIngame: m_level = LEVEL_Central_Cavern; m_gameState = GSTATE_PreIngame; case GSTATE_PreIngame: m_userKeyBits = 0; m_hMotion = 0; prepLevel(); m_gameState = GSTATE_Ingame; case GSTATE_Ingame: { char state = runGame(); if(ColDie == state) m_gameState = GSTATE_PreDied; else if(ColDoor == state) m_gameState = GSTATE_PreBeatLevel; break; } case GSTATE_PreBeatLevel: m_gameState = GSTATE_BeatLevel; case GSTATE_BeatLevel: m_score += 24; drawScores(); m_airAmount -= 2 * AirScaler; if(m_airAmount <= 0) { m_airAmount = 0; if(LEVEL_The_Final_Barrier != m_level) { ++m_level; m_gameState = GSTATE_PreIngame; } else { m_gameState = GSTATE_Won; } } renderFrame(); break; case GSTATE_PreDied: --m_lives; undrawLife(); renderFrontEnd(FERState_FlashColour); if(!m_lives) m_gameState = GSTATE_PreLost; else m_gameState = GSTATE_PreIngame; break; case GSTATE_PreLost: m_level = LEVEL_The_Final_Barrier+1; setupLostScreen(); prepLevel(); m_gameState = GSTATE_Lost; case GSTATE_Lost: if(renderLostScreen()) m_gameState = GSTATE_PreFrontEnd; break; case GSTATE_Won: m_gameState = GSTATE_PreFrontEnd; break; } syncEndFrame(); }
int main(int argc, char *argv[]) { int doScale=0; // 0=Undefined, 1=320x240, -1=OpenGL, >1=SwScale char* dumpPack=NULL; int state=1; //Game, Menu, Editor, Quit int sdlVideoModeFlags = SDL_SWSURFACE; #ifdef PSP //Note to PSP porter, please test if HW is actually faster, Wizznic does a lot of memory-manipulation in the screen-surface, each call might initiate a full copy back/forth from video memory. Remove comment when read. :) sdlVideoModeFlags = (SDL_HWSURFACE | SDL_DOUBLEBUF |SDL_HWACCEL); SetupCallbacks();//Callbacks actifs scePowerSetClockFrequency(333,333,166); #endif // #ifdef WIN32 //Redirect stdout to console on windows, so we can see what's going in. // FILE *stream; // stream = freopen("CON", "w", stdout); // #endif //Print welcome message printf( "Wizznic "VERSION_STRING". GPLv3 or newer Copyleft 2010-2013\n\n"); //initialize path strings initUserPaths(); //Tell where stuff's at. printf("Directories:\n Settings: %s\n DLC: %s\n Highscores: %s\n Editorlevels: %s\n Datafiles: %s\n\n", \ getConfigDir(), getUsrPackDir(), getHighscoreDir(), getUserLevelDir(), (!strlen(DATADIR))?".":DATADIR); //Print the command line parameters printf("Command-line parameters:\n"STR_VID_OPTIONS); //Quit if user wants help if( argc > 1 && ( strcmp(argv[1], "-h")==0 || strcmp(argv[1], "--help")==0 || strcmp(argv[1], "-help")==0 )) { printf("Please see readme.txt or http://wizznic.org/ for more help.\n"); return(0); } //Read settings printf("Loading settings...\n"); initSettings(); #if defined(WITH_OPENGL) //We start by enabling glScaling if it was enabled in settings, it can then be overwritten by command line options. if( setting()->glEnable && doScale==0 ) doScale=-1; #endif //Set scaling setting()->scaleFactor=1.0; atexit(SDL_Quit); //Init SDL if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK | SDL_INIT_TIMER ) <0 ) { printf("SDL_Init failed: %s\n",SDL_GetError()); return(-1); } //Setup display #if defined (GP2X) || defined (PSP) || defined (WIZ) SDL_Surface* screen = SDL_SetVideoMode(SCREENW,SCREENH,16, sdlVideoModeFlags); #else SDL_Surface* screen=NULL; int i; for( i=0; i < argc; i++ ) { if( strcmp( argv[i], "-sw" ) == 0 ) { setting()->glEnable=0; doScale=0; saveSettings(); } else if( strcmp( argv[i], "-gl" ) == 0 ) { setting()->glEnable=1; doScale=-1; saveSettings(); } else if( strcmp( argv[i], "-z" ) == 0 ) { if( i+1 < argc ) { doScale = atoi( argv[i+1] ); setting()->glEnable=0; i++; saveSettings(); } else { printf(" -z requires zoom level ( -z 2 for example ).\n"); return(1); } } else if( strcmp( argv[i], "-f" ) == 0 ) { setting()->fullScreen=1; saveSettings(); } else if( strcmp( argv[i], "-w" ) == 0 ) { setting()->fullScreen=0; saveSettings(); } else if( strcmp( argv[i], "-glheight" ) == 0 ) { if( i+1 < argc ) { setting()->glHeight = atoi( argv[i+1] ); setting()->glEnable=1; doScale=-1; i++; printf("Setting OpenGL window height to %i.\n", setting()->glHeight); saveSettings(); } else { printf(" -glheight requires an argument (-1 or size in pixels).\n"); return(1); } } else if( strcmp( argv[i], "-glwidth" ) == 0 ) { if( i+1 < argc ) { setting()->glWidth = atoi( argv[i+1] ); setting()->glEnable=1; doScale=-1; i++; printf("Setting OpenGL window width to %i.\n", setting()->glWidth); saveSettings(); } else { printf(" -glwidth requires an argument (-1 or size in pixels).\n"); return(1); } } else if( strcmp( argv[i], "-glfilter" ) == 0 ) { if( i+1 < argc ) { setting()->glFilter=atoi(argv[i+1]); printf("OpenGL texture filtering set to %s.\n", (setting()->glFilter)?"Smooth":"Off"); i++; saveSettings(); } else { printf("-glfilter requires 0 or 1 as argument.\n"); return(1); } } else if( strcmp( argv[i] , "-d" ) == 0 ) { if( argc == 3 && i < argc+1 ) { dumpPack = malloc( sizeof(char)*strlen(argv[i+1])+1 ); strcpy( dumpPack, argv[i+1] ); doScale=0; setting()->glEnable=0; i++; } else { printf("-d requires a packname, and must not be used with other parameters.\n"); return(1); } } else if( strcmp( argv[i], "-rift") == 0 ) { setting()->glWidth = 1280; setting()->glHeight = 800; setting()->glEnable=1; setting()->rift=1; doScale=-1; } else if( i > 0 ) { printf("\nError: Invalid argument '%s', quitting.\n", argv[i]); return(1); } } if( setting()->fullScreen ) { sdlVideoModeFlags |= SDL_FULLSCREEN; } if(doScale) { //Hardware accelerated scaling if( doScale == -1 ) { #ifdef HAVE_ACCELERATION printf("Enabling platform specific accelerated scaling.\n"); screen = platformInitAccel(sdlVideoModeFlags); if( !screen ) { printf("Failed to set platform accelerated scaling, falling back to software window.\n"); screen=swScreen(SDL_SWSURFACE); doScale=0; } #else printf("\nError:\n Not compiled with hardware-scaling support, don't give me -z -1\n Exiting...\n"); return(-1); #endif } else if( doScale > 0 ) { #ifdef WANT_SWSCALE //Set up software scaling printf("Enabling slow software-based scaling to %ix%i.\n",320*doScale, 240*doScale); screen = swScaleInit(sdlVideoModeFlags,doScale); #else printf("\nError:\n I don't support software scaling, don't give me any -z options\n Exiting...\n"); return(-1); #endif } } else { screen=swScreen(sdlVideoModeFlags); doScale=0; } printf("Scaling factor: %f\n", setting()->scaleFactor); if( screen == NULL ) { printf("ERROR: Couldn't init video.\n"); return(-1); } //Set window title SDL_WM_SetCaption("Wizznic!", "Wizznic!"); //Set window icon SDL_Surface* icon = IMG_Load( DATADIR"data/wmicon.png"); SDL_WM_SetIcon(icon, NULL); SDL_FreeSurface(icon); #endif setting()->bpp = screen->format->BytesPerPixel; setAlphaCol( setting()->bpp ); printf("Screen surface using %i bytes per pixel.\n",setting()->bpp); //Open Joysticks (for wiz) if (SDL_NumJoysticks() > 0) SDL_JoystickOpen(0); //Hide mouse cursor SDL_ShowCursor(SDL_DISABLE); //Load fonts txtInit(); //Load sounds if(!initSound()) { printf("Couldn't init sound.\n"); return(-1); } //Menu Graphics if(!initMenu(screen)) { printf("Couldn't load menu graphics.\n"); return(-1); } //Init controls initControls(); //Init stats statsInit(); //Init packs packInit(); //Scan userlevels dir makeUserLevelList(screen); //Init particles initParticles(screen); //Seed the pseudo random number generator (for particles 'n' stuff) srand( (int)time(NULL) ); #if defined(PC) //Need to dump level-screenshots? if(dumpPack) { printf("Dumping level-images for pack: %s\n", dumpPack); dumplevelimages(screen, dumpPack, 0); return(0); } #endif //init starfield initStars(screen); //Init pointer initPointer(screen); printf("Applying settings..\n"); //Apply settings (has to be done after packs are inited) applySettings(); //Set Pack packSetByPath( setting()->packDir ); #if defined( PLATFORM_SUPPORTS_STATSUPLOAD ) if( (setting()->uploadStats) && !(setting()->firstRun) ) { statsUpload(0,0,0,0,0,"check",1, &(setting()->session) ); statsUpload(0,0,0,0,0,"q_solved",1, &(setting()->solvedWorldWide) ); //DLC only works when stats-uploading is enabled so we can use the same nag-screen. dlcCheckOnline(); } #endif printf("Setting Music...\n"); //Start playing music (has to be done after readong settings) soundSetMusic(); //Initialize credits initCredits(screen); initTransition(); #if SCREENW != 320 || SCREENH != 240 SDL_Rect *borderSrcRect = malloc(sizeof(SDL_Rect)); SDL_Surface* border = loadImg( BORDER_IMAGE ); if( border ) { printf("Border image loaded.\n"); borderSrcRect->x=(border->w-SCREENW)/2; borderSrcRect->y=(border->h-SCREENH)/2; borderSrcRect->w=SCREENW; borderSrcRect->h=SCREENH; SDL_BlitSurface( border, borderSrcRect, screen, NULL ); SDL_FreeSurface(border); } else { printf("Could not load border image: %s\n", BORDER_IMAGE); SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0,0,0)); } free(borderSrcRect); borderSrcRect=NULL; #endif int lastTick; while(state!=STATEQUIT) { lastTick=SDL_GetTicks(); frameStart(); if(runControls()) state=STATEQUIT; switch(state) { case STATEPLAY: state = runGame(screen); break; case STATEMENU: state = runMenu(screen); break; case STATEEDIT: state=runEditor(screen); break; } drawPointer(screen); soundRun(screen,state); runTransition(screen); if(setting()->showFps) drawFPS(screen); switch( doScale ) { #if defined(HAVE_ACCELERATION) case -1: platformDrawScaled(screen); break; #endif case 0: SDL_Flip(screen); break; #if defined(WANT_SWSCALE) default: swScale(screen,doScale); break; #else default: state=STATEQUIT; break; #endif } #if defined(CRUDE_TIMING) //Oh how I loathe this, is there no better way? while(SDL_GetTicks()-lastTick <= PLATFORM_CRUDE_TIMING_TICKS) { //Burn, burn baby burn! } #else int t=SDL_GetTicks()-lastTick; if(t < 20) { SDL_Delay( 20 -t); } #endif } #if defined(PLATFORM_NEEDS_EXIT) platformExit(); #endif SDL_Quit(); return(0); }
int main() { ////////////////////////////////////////////////////////////////// ////Loads core files in for game processes coreLoad(Window); coreLoad(Time); coreLoad(Input); coreLoad(Camera); coreLoad(Factory); coreLoad(Asset); ////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////// ////Loads system files in systemLoad(TransformUpdate); systemLoad(Rendering); systemLoad(textRenderSys); systemLoad(trafficSys); systemLoad(collisionPrep); systemLoad(CollisionDetection); systemLoad(StaticCollision); systemLoad(collisionResponse); systemLoad(RigidbodyDynamics); systemLoad(TankDynamics); systemLoad(LifeTimeDynamics); systemLoad(collisionRender); ////////////////////////////////////////////////////////////////// initCore();//Main Game Loop ////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////// ////////Files Loaded in for textures and shaders files ///Shaders core(Asset).loadShader("Flat", "./shaders/simpleShader.vert", "./shaders/simpleShader.frag"); core(Asset).loadShader("Texture", "./shaders/simpleShader.vert", "./shaders/textureShader.frag"); core(Asset).loadShader("FontShader", "./shaders/simpleShader.vert", "./shaders/fontShader.frag"); ///Texture Files //Track core(Asset).loadTexture("Track", "./texture/Track.png"); //Car Images core(Asset).loadTexture("Car1texture", "./texture/car.png"); core(Asset).loadTexture("Car2texture", "./texture/car2.png"); core(Asset).loadTexture("Car1Turret", "./texture/carTank.png"); core(Asset).loadTexture("Car2Turret", "./texture/car2Tank.png"); //Animations core(Asset).loadTexture("Walking", "./texture/WalkingAnimation.png", 4, 6); core(Asset).loadTexture("Raka", "./texture/Raka.png", 2, 5); core(Asset).loadTexture("Garren", "./texture/GARREN.bmp", 10, 12); core(Asset).loadTexture("Draven", "./texture/SPINNERS.bmp", 4, 4); core(Asset).loadTexture("Milk", "./texture/CANTMILK.bmp", 4, 6); core(Asset).loadTexture("Font", "./texture/font2.png", 8, 16); core(Asset).loadTexture("Light", "./texture/trafficLight.png", 1, 3); core(Asset).loadTexture("Flag", "./texture/FLAG.bmp", 2, 2); ////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////// //////Vertex for game objects ///Font Vertex font_vertexQ[4] = { { {-.5, .5, 0, 1 }, { 0, 1, 1, 0 }, { 0, 0 } }, { { .5, .5, 0, 1 }, { 0, 1, 1, 0 }, { 1, 0 } }, { { .5,-.5, 0, 1 }, { 0, 1, 1, 0 }, { 1, 1 } }, { {-.5,-.5, 0, 1 }, { 0, 1, 1, 0 }, { 0, 1 } } }; ///Walking Vertex Animation_vertQ[4] = { { { core(Window).width() / 2, core(Window).height() / 2, 0, 1 }, { 0, 1, 1, 0 }, { 0, 0 } }, { { 0, core(Window).height() / 2, 0, 1 }, { 0, 1, 1, 0 }, { 1, 0 } }, { { 0, 0, 0, 1 }, { 0, 1, 1, 0 }, { 1, 1 } }, { { core(Window).width() / 2, 0, 0, 1 }, { 0, 1, 1, 0 }, { 0, 1 } } }; ///Track Vertex Track_vertQ[4] = { { { core(Window).width(), core(Window).height(), 0, 1 }, { 0, 1, 1, 0 }, { 0, 0 } }, { { 0, core(Window).height(), 0, 1 }, { 0, 1, 1, 0 }, { 1, 0 } }, { { 0, 0, 0, 1 }, { 0, 1, 1, 0 }, { 1, 1 } }, { { core(Window).width(), 0, 0, 1 }, { 0, 1, 1, 0 }, { 0, 1 } } }; ///Car Vertex Car_vertexQ[4] = { { { -15, 30, 0, 1 }, { 0, 1, 1, 0 }, { 0, 0 } }, { { 15, 30, 0, 1 }, { 0, 1, 1, 0 }, { 1, 0 } }, { { 15, -30, 0, 1 }, { 0, 1, 1, 0 }, { 1, 1 } }, { {-15,-30, 0, 1 }, { 0, 1, 1, 0 }, { 0, 1 } } }; ///Turret Vertex Turret[4] = { { {-10, 10, 0, 1 }, { 1, 0, 1, 0 }, { 0, 0 } }, { { 10, 10, 0, 1 }, { 0, 1, 0, 1 }, { 1, 0 } }, { { 10,-10, 0, 1 }, { 1, 0, 1, 0 }, { 1, 1 } }, { {-10,-10, 0, 1 }, { 0, 1, 0, 1 }, { 0, 1 } } }; ///Bullet Vertex Bullet[4] = { { {-5, 5, 0, 1 }, { 1, 0, 1, 0 }, { 0, 0 } }, { { 5, 5, 0, 1 }, { 0, 1, 0, 1 }, { 1, 0 } }, { { 5,-5, 0, 1 }, { 1, 0, 1, 0 }, { 1, 1 } }, { {-5,-5, 0, 1 }, { 0, 1, 0, 1 }, { 0, 1 } } }; ///Light Vertex Light[4] = { { { -30, 70, 0, 1 }, { 1, 0, 1, 0 }, { 0, 0 } }, { { 30, 70, 0, 1 }, { 0, 1, 0, 1 }, { 1, 0 } }, { { 30, -70, 0, 1 }, { 1, 0, 1, 0 }, { 1, 1 } }, { { -30, -70, 0, 1 }, { 0, 1, 0, 1 }, { 0, 1 } } }; ///Flag Vertex Flag[4] = { { {-290, 170, 0, 1 }, { 1, 0, 1, 0 }, { 0, 0 } }, { { 290, 170, 0, 1 }, { 0, 1, 0, 1 }, { 1, 0 } }, { { 290,-170, 0, 1 }, { 1, 0, 1, 0 }, { 1, 1 } }, { {-290,-170, 0, 1 }, { 0, 1, 0, 1 }, { 0, 1 } } }; ////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////// ///////Triangles for objects ///font Triangle quad[2] = { { 0, 1, 2 }, { 0, 2, 3 } }; ////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////// //////Meshes core(Asset).loadMesh("Bullet", Bullet, 4, quad, 2); core(Asset).loadMesh("Turret", Turret, 4, quad, 2); core(Asset).loadMesh("Car", Car_vertexQ, 4, quad, 2); core(Asset).loadMesh("Anime", Animation_vertQ, 4, quad, 2); core(Asset).loadMesh("Quad", font_vertexQ, 4, quad, 2); core(Asset).loadMesh("TrackMesh", Track_vertQ, 4, quad, 2); core(Asset).loadMesh("lightMesh", Light, 4, quad, 2); core(Asset).loadMesh("flagMesh", Flag, 4, quad, 2); ////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////// //////Factory Entities Loading in ////BackGround core(Factory).makeBG(0, 0); ////Cars auto p1 = core(Factory).MakeTank(790, 620, 1); //Car1 auto p2 = core(Factory).MakeTank(790, 560, 2, 'I', 'K', 'J', 'L', 'U', 'O', 'N'); //Car2 ////Car Names core(Factory).makeText(0, 0, "P1",16,24,p1->transform); //Car1 Name core(Factory).makeText(0, 0, "P2", 16, 24, p2->transform); //Car2 Name ////Game borders core(Factory).MakeBorder(70, core(Window).height() - 65, vec3Make(1, 0, 0)); core(Factory).MakeBorder(70, core(Window).height() - 65, vec3Make(0, -1, 0)); core(Factory).MakeBorder(core(Window).width() - 45, 65, vec3Make(-1, 0, 0)); core(Factory).MakeBorder(core(Window).width() - 45, 65, vec3Make(0, 1, 0)); ////track hit markers //core(Factory).makeLine(725, 590); core(Factory).makeCenter(core(Window).width()/2, core(Window).height() / 2); ////Hud info core(Factory).makeLight(core(Window).width() / 2, core(Window).height() / 2, core(Factory).makeGate(760, 590, vec3Make(1, 0, 0)), core(Factory).makeGate(820, 590, vec3Make(-1, 0, 0))); ////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////// runGame(); //end of game loop }
int main(int argc, char* argv[]){ bool small = false; //if true, program run with the -s mod int h, w; //height and width of the board int cycles=5000; //number of cycles to run the current seed int row, col; //size of the terminal int waitMS; //time to wait in micro seconds (1,000,000 = 1 sec) between cycles parseEntryArgs(argc, argv, h, w, waitMS, small); //parse cmd args initscr(); //start nCurses noecho(); //set no echo curs_set(0); //hide cursor getmaxyx(stdscr,row,col); //get size of terminal int menuStartRow = 3 + (h/2); //start row for menus (half way down board) int boardStartColumn = (col - w) / 2; //start column for board bool bpass = false; //set to false until terminal is correct size if (small == true && row > 25 && col > 81){ //going to run with -s bpass = true; } else if(small == false && row > 53 && col > 151){ //going to run without -s bpass = true; } if(bpass == true){ //terminal is correct size char mch; do{ clear(); printHeader(col,row); printMenu(menuStartRow, col); refresh(); GameOfLife game(h, w); //initialize gameOfLife object game.setLiveDeadChars('X',' '); //set symbols game.initVectors(); //setup vectors switch(mch = getch()){ case 'r':{ //generate random seed game.setInitParamsRandom(); //set seed to random runGame(game, boardStartColumn, col, waitMS, cycles); //run seed break;} case 'u':{ //use presets std::string fileName = "seeds/"; clear(); printHeader(col,row); if (runPresetMenu(game, fileName, menuStartRow, col)==true){ game.setInitParams(fileName); runGame(game, boardStartColumn, col, waitMS, cycles); } break;} case 's':{ clear(); printHeader(col,row); printSettings(waitMS, menuStartRow, col, small); break;} case 'e':{ break;} default: break; } }while(mch != 'e'); } else{ //terminal is too small curs_set(1); //show cursor endwin(); //turn off nCurses std::cout << "\nPlease resize the terminal to at least 54 rows x 152 columns." << "\nYour current terminal size is:" << "\n\tRows: " << row << "\n\tColumns: " << col << "\nAlternatively, run the program with cmd -s" << " (minimum terminal size: 26 rows X 82 columns)" << "\n\t./GameOfLife -s\n" << std::endl; return 1; } curs_set(1); //show cursor endwin(); //turn off nCurses return 0; }