void ScummEngine::setCameraFollows(Actor *a, bool setCamera) { int t, i; camera._mode = kFollowActorCameraMode; camera._follows = a->_number; if (!a->isInCurrentRoom()) { startScene(a->getRoom(), 0, 0); camera._mode = kFollowActorCameraMode; camera._cur.x = a->_pos.x; setCameraAt(camera._cur.x, 0); } t = a->_pos.x / 8 - _screenStartStrip; if (t < camera._leftTrigger || t > camera._rightTrigger || setCamera == true) setCameraAt(a->_pos.x, 0); for (i = 1; i < _numActors; i++) { if (_actors[i].isInCurrentRoom()) _actors[i]._needRedraw = true; } runInventoryScript(0); }
void SceneManager::m_switchScene() { if (curScene != nullptr) endScene(); Scene* newScene = makeActiveScene(m_nextScene); if (newScene) curScene = newScene; else curScene = new uth::DefaultScene(); startScene(); m_pendingSceneSwitch = false; }
Common::Error SherlockEngine::run() { // Initialize the engine initialize(); // Flag for whether to show original saves dialog rather than the ScummVM GMM _showOriginalSavesDialog = ConfMan.getBool("originalsaveload"); // If requested, load a savegame instead of showing the intro if (ConfMan.hasKey("save_slot")) { int saveSlot = ConfMan.getInt("save_slot"); if (saveSlot >= 0 && saveSlot <= MAX_SAVEGAME_SLOTS) _loadGameSlot = saveSlot; } if (_loadGameSlot != -1) { _saves->loadGame(_loadGameSlot); _loadGameSlot = -1; } else { do showOpening(); while (!shouldQuit() && !_interactiveFl); } while (!shouldQuit()) { // Prepare for scene, and handle any game-specific scenes. This allows // for game specific cutscenes or mini-games that aren't standard scenes startScene(); if (shouldQuit()) break; // Clear the screen _screen->clear(); // Reset UI flags _ui->reset(); // Reset the data for the player character (Sherlock) _people->reset(); // Initialize and load the scene. _scene->selectScene(); // Scene handling loop sceneLoop(); } return Common::kNoError; }
void ScummEngine_v0::o_loadRoomWithEgo() { Actor_v0 *a; int obj, room, x, y, dir; obj = fetchScriptByte(); room = fetchScriptByte(); a = (Actor_v0 *)derefActor(VAR(VAR_EGO), "o_loadRoomWithEgo"); //0x634F if (a->_miscflags & kActorMiscFlagFreeze) { stopObjectCode(); return; } // The original interpreter sets the actors new room X/Y to the last rooms X/Y // This fixes a problem with MM: script 158 in room 12, the 'Oomph!' script // This scripts runs before the actor position is set to the correct room entry location a->putActor(a->getPos().x, a->getPos().y, room); _egoPositioned = false; startScene(a->_room, a, obj); getObjectXYPos(obj, x, y, dir); AdjustBoxResult r = a->adjustXYToBeInBox(x, y); x = r.x; y = r.y; a->putActor(x, y, _currentRoom); camera._dest.x = camera._cur.x = a->getPos().x; setCameraAt(a->getPos().x, a->getPos().y); setCameraFollows(a); _fullRedraw = true; resetSentence(); if (x >= 0 && y >= 0) { a->startWalkActor(x, y, -1); } }
void ScummEngine_v0::o_endCutscene() { vm.cutSceneStackPointer = 0; VAR(VAR_OVERRIDE) = 0; vm.cutSceneScript[0] = 0; vm.cutScenePtr[0] = 0; setMode(vm.cutSceneData[0]); if (_currentMode == kModeKeypad) { startScene(vm.cutSceneData[2], 0, 0); // in contrast to the normal keypad behavior we unfreeze scripts here unfreezeScripts(); } else { unfreezeScripts(); actorFollowCamera(VAR(VAR_EGO)); // set mode again to have the freeze mode right setMode(vm.cutSceneData[0]); _redrawSentenceLine = true; } }
void ScummEngine_v7::setCameraFollows(Actor *a, bool setCamera) { byte oldfollow = camera._follows; int ax, ay; camera._follows = a->_number; VAR(VAR_CAMERA_FOLLOWED_ACTOR) = a->_number; if (!a->isInCurrentRoom()) { startScene(a->getRoom(), 0, 0); } ax = ABS(a->_pos.x - camera._cur.x); ay = ABS(a->_pos.y - camera._cur.y); if (ax > VAR(VAR_CAMERA_THRESHOLD_X) || ay > VAR(VAR_CAMERA_THRESHOLD_Y) || ax > (_screenWidth / 2) || ay > (_screenHeight / 2)) { setCameraAt(a->_pos.x, a->_pos.y); } if (a->_number != oldfollow) runInventoryScript(0); }
/** * Save the function's contents to an XML document * * @param doc The QDomDocument to save to */ bool EFX::saveXML(QDomDocument* doc, QDomElement* wksp_root) { QDomElement root; QDomElement tag; QDomElement subtag; QDomText text; QString str; Q_ASSERT(doc != NULL); Q_ASSERT(wksp_root != NULL); /* Function tag */ root = doc->createElement(KXMLQLCFunction); wksp_root->appendChild(root); root.setAttribute(KXMLQLCFunctionID, id()); root.setAttribute(KXMLQLCFunctionType, Function::typeToString(m_type)); root.setAttribute(KXMLQLCFunctionName, name()); /* Fixtures */ QListIterator <EFXFixture*> it(m_fixtures); while (it.hasNext() == true) it.next()->saveXML(doc, &root); /* Propagation mode */ tag = doc->createElement(KXMLQLCEFXPropagationMode); root.appendChild(tag); text = doc->createTextNode(propagationModeToString(m_propagationMode)); tag.appendChild(text); /* Speed bus */ tag = doc->createElement(KXMLQLCBus); root.appendChild(tag); tag.setAttribute(KXMLQLCBusRole, KXMLQLCBusFade); str.setNum(busID()); text = doc->createTextNode(str); tag.appendChild(text); /* Direction */ tag = doc->createElement(KXMLQLCFunctionDirection); root.appendChild(tag); text = doc->createTextNode(Function::directionToString(m_direction)); tag.appendChild(text); /* Run order */ tag = doc->createElement(KXMLQLCFunctionRunOrder); root.appendChild(tag); text = doc->createTextNode(Function::runOrderToString(m_runOrder)); tag.appendChild(text); /* Algorithm */ tag = doc->createElement(KXMLQLCEFXAlgorithm); root.appendChild(tag); text = doc->createTextNode(algorithm()); tag.appendChild(text); /* Width */ tag = doc->createElement(KXMLQLCEFXWidth); root.appendChild(tag); str.setNum(width()); text = doc->createTextNode(str); tag.appendChild(text); /* Height */ tag = doc->createElement(KXMLQLCEFXHeight); root.appendChild(tag); str.setNum(height()); text = doc->createTextNode(str); tag.appendChild(text); /* Rotation */ tag = doc->createElement(KXMLQLCEFXRotation); root.appendChild(tag); str.setNum(rotation()); text = doc->createTextNode(str); tag.appendChild(text); /* Start function */ tag = doc->createElement(KXMLQLCEFXStartScene); root.appendChild(tag); str.setNum(startScene()); text = doc->createTextNode(str); tag.appendChild(text); if (startSceneEnabled() == true) tag.setAttribute(KXMLQLCFunctionEnabled, KXMLQLCTrue); else tag.setAttribute(KXMLQLCFunctionEnabled, KXMLQLCFalse); /* Stop function */ tag = doc->createElement(KXMLQLCEFXStopScene); root.appendChild(tag); str.setNum(stopScene()); text = doc->createTextNode(str); tag.appendChild(text); if (stopSceneEnabled() == true) tag.setAttribute(KXMLQLCFunctionEnabled, KXMLQLCTrue); else tag.setAttribute(KXMLQLCFunctionEnabled, KXMLQLCFalse); /******************************************** * X-Axis ********************************************/ tag = doc->createElement(KXMLQLCEFXAxis); root.appendChild(tag); tag.setAttribute(KXMLQLCFunctionName, KXMLQLCEFXX); /* Offset */ subtag = doc->createElement(KXMLQLCEFXOffset); tag.appendChild(subtag); str.setNum(xOffset()); text = doc->createTextNode(str); subtag.appendChild(text); /* Frequency */ subtag = doc->createElement(KXMLQLCEFXFrequency); tag.appendChild(subtag); str.setNum(xFrequency()); text = doc->createTextNode(str); subtag.appendChild(text); /* Phase */ subtag = doc->createElement(KXMLQLCEFXPhase); tag.appendChild(subtag); str.setNum(xPhase()); text = doc->createTextNode(str); subtag.appendChild(text); /******************************************** * Y-Axis ********************************************/ tag = doc->createElement(KXMLQLCEFXAxis); root.appendChild(tag); tag.setAttribute(KXMLQLCFunctionName, KXMLQLCEFXY); /* Offset */ subtag = doc->createElement(KXMLQLCEFXOffset); tag.appendChild(subtag); str.setNum(yOffset()); text = doc->createTextNode(str); subtag.appendChild(text); /* Frequency */ subtag = doc->createElement(KXMLQLCEFXFrequency); tag.appendChild(subtag); str.setNum(yFrequency()); text = doc->createTextNode(str); subtag.appendChild(text); /* Phase */ subtag = doc->createElement(KXMLQLCEFXPhase); tag.appendChild(subtag); str.setNum(yPhase()); text = doc->createTextNode(str); subtag.appendChild(text); return true; }
Common::Error MadsEngine::run() { // Set up the graphics mode initGraphics(320, 200, false); // Necessary pre-initialisation _resourceManager = new MADSResourceManager(this); // Set up needed common functionality MadsM4Engine::run(); _palette->setMadsSystemPalette(); _mouse->init("cursor.ss", NULL); _mouse->setCursorNum(0); // Load MADS data files MadsGlobals *globs = (MadsGlobals *)_globals; globs->loadMadsVocab(); // vocab.dat globs->loadQuotes(); // quotes.dat globs->loadMadsMessagesInfo(); // messages.dat globs->loadMadsObjects(); // Setup globals globs->_config.easyMouse = true; globs->_config.invObjectsStill = false; globs->_config.textWindowStill = false; globs->_config.storyMode = 1; // Naughty globs->_config.screenFades = 0; // Test code to dump all messages to the console //for (int i = 0; i < _globals->getMessagesSize(); i++) //debugCN(kDebugCore, "%s\n----------\n", _globals->loadMessage(i)); if (getGameType() == GType_RexNebular) { MadsGameLogic::initialiseGlobals(); _scene = NULL; loadMenu(MAIN_MENU); } else { // Test code _scene = new MadsScene(this); startScene(FIRST_SCENE); RGBList *_bgPalData; _scene->loadBackground(FIRST_SCENE, &_bgPalData); _palette->addRange(_bgPalData); _scene->translate(_bgPalData); _scene->show(); _font->setFont(FONT_MAIN_MADS); _font->current()->setColors(2, 1, 3); _font->current()->writeString(_scene->getBackgroundSurface(), "Testing the M4/MADS ScummVM engine", 5, 160, 310, 2); _font->current()->writeString(_scene->getBackgroundSurface(), "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 5, 180, 310, 2); if (getGameType() == GType_DragonSphere) { //_scene->showMADSV2TextBox("Test", 10, 10, NULL); } _mouse->cursorOn(); } _viewManager->systemHotkeys().add(Common::KEYCODE_ESCAPE, &escapeHotkeyHandler); _viewManager->systemHotkeys().add(Common::KEYCODE_KP_MULTIPLY, &textviewHotkeyHandler); uint32 nextFrame = g_system->getMillis(); while (!_events->quitFlag) { eventHandler(); if (g_system->getMillis() >= nextFrame) { nextFrame = g_system->getMillis() + GAME_FRAME_DELAY; ++_currentTimer; // Call the updateState method of all views _viewManager->updateState(); // Refresh the display _viewManager->refreshAll(); } g_system->delayMillis(10); if (globals()->dialogType != DIALOG_NONE) showDialog(); } return Common::kNoError; }
/* =============================================== Desc: Precondition: Postcondition: =============================================== */ void myGlutDisplay(void) { static float scale = 0.1; // Set our background color that the screen refreshes too glClearColor(0.1f, 0.1f, 0.2f, 1.0f); // Which bit planes get cleared glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Set up glMatrixMode(GL_MODELVIEW); // Give us a default matrix to start our scene from glLoadIdentity(); //glScalef(scale,scale,scale); if(startTheScene==false){ glTranslatef( view_pos[0], view_pos[1]-2, -view_pos[2]-6 ); } /* Perform camera transformations Each camera funtion will be called after a certain amount of time has elapsed. You are free to implement your own camera functions! *** Be Creative! *** */ if(startTheScene==true){ // Output the time to the console, just a a director would have time // running on the camera. cout << difftime(time(NULL),start) << "s : "; if(difftime(time(NULL),start) <= 2){ std::cout << "orthogonal" << endl; camera1->orthogonal(-1,1,-1,1,1,10); // Get a unit perspective from above } else if(difftime(time(NULL),start) > 2 && difftime(time(NULL),start) <= 6){ std::cout << "Close Up" << endl; // Close up shot on the T-Rex camera1->closeUp(trex->getXPosition(), trex->getYPosition(),trex->getZPosition(), 1,10); } else if(difftime(time(NULL),start) > 6 && difftime(time(NULL),start) <= 10){ std::cout << "follow cam" << endl; //camera1->perspective(105,.75,1,10); // Get the regular perspective camera1->follow(jeep->getXPosition(), jeep->getYPosition(),jeep->getZPosition(), 0, 0, 0, 0, 0, 0); // attach the camera to the t-rex } else if(difftime(time(NULL),start) > 10 && difftime(time(NULL),start) <= 14){ std::cout << "spin cam" << endl; // Spin around a point in space. // Radius is fixed, but could be adjusted. // Y height may also need to be adjusted. camera1->spinAroundPoint(jeep->getXPosition(),jeep->getYPosition()-2,jeep->getZPosition(),2); } else{ startTheScene=false; resetScene(); } } glMultMatrixf(view_rotate); if (filled) { glEnable(GL_POLYGON_OFFSET_FILL); glColor3f(0.5, 0.5, 0.5); glPolygonMode(GL_FRONT, GL_FILL); startScene(); } // Set our scene to a wireframe mode. if (wireframe) { glDisable(GL_POLYGON_OFFSET_FILL); glColor3f(1.0, 1.0, 1.0); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); startScene(); } if(grid){ draw_grid(); } glutSwapBuffers(); }