Beispiel #1
0
void WitcherEngine::init() {
	LoadProgress progress(15);

	progress.step("Declare languages");
	declareLanguages();

	if (evaluateLanguage(true, _languageText, _languageVoice))
		status("Setting the language to %s text + %s voices",
				LangMan.getLanguageName(_languageText).c_str(),
				LangMan.getLanguageName(_languageVoice).c_str());
	else
		throw Common::Exception("Failed to detect this game's language");

	progress.step("Loading user game config");
	initConfig();

	initResources(progress);
	if (EventMan.quitRequested())
		return;

	progress.step("Loading game cursors");
	initCursors();
	if (EventMan.quitRequested())
		return;

	progress.step("Initializing internal game config");
	initGameConfig();

	progress.step("Initializing Lua subsystem");
	initLua();

	progress.step("Successfully initialized the engine");
}
Beispiel #2
0
	void HexagonGame::newGame(const string& mId, bool mFirstPlay, float mDifficultyMult)
	{
		initFlashEffect();

		firstPlay = mFirstPlay;
		setLevelData(assets.getLevelData(mId), mFirstPlay);
		difficultyMult = mDifficultyMult;

		// Audio cleanup
		assets.stopSounds(); stopLevelMusic();
		assets.playSound("go.ogg"); playLevelMusic();

		if(Config::getMusicSpeedDMSync())
		{
			auto current(assets.getMusicPlayer().getCurrent());
			if(current != nullptr) current->setPitch(pow(difficultyMult, 0.12f));
		}

		// Events cleanup
		messageText.setString("");
		eventTimeline.clear(); eventTimeline.reset();
		messageTimeline.clear(); messageTimeline.reset();

		// Manager cleanup
		manager.clear();
		factory.createPlayer();

		// Timeline cleanup
		timeline.clear(); timeline.reset();
		effectTimelineManager.clear();
		mustChangeSides = false;

		// FPSWatcher reset
		fpsWatcher.reset();
		if(Config::getOfficial()) fpsWatcher.enable();

		// LUA context and game status cleanup
		status = HexagonGameStatus{};
		if(!mFirstPlay) runLuaFunction<void>("onUnload");
		lua = Lua::LuaContext{};
		initLua();
		runLuaFile(levelData->luaScriptPath);
		runLuaFunction<void>("onInit");
		runLuaFunction<void>("onLoad");
		restartId = mId;
		restartFirstTime = false;
		setSides(levelStatus.sides);

		// Reset zoom
		overlayCamera.setView({{Config::getWidth() / 2.f, Config::getHeight() / 2.f}, Vec2f(Config::getWidth(), Config::getHeight())});
		backgroundCamera.setView({ssvs::zeroVec2f, {Config::getWidth() * Config::getZoomFactor(), Config::getHeight() * Config::getZoomFactor()}});
		backgroundCamera.setRotation(0);

		// 3D Cameras cleanup
		depthCameras.clear();
		auto depth(styleData._3dDepth);
		if(depth > Config::get3DMaxDepth()) depth = Config::get3DMaxDepth();
		for(auto i(0u); i < depth; ++i) depthCameras.push_back({window, {}});
	}
Beispiel #3
0
int main(int argc, char* argv[])
{
  SetupCallbacks();
  #ifdef DEBUG
    usbStorage();
  #endif

  strcpy(cwd,argv[0]);
  cwd[strlen(cwd)-strlen("/eboot.pbp")] = '\0';

  configLoad();
  initLanguage();
  initAudio();
  initLua();
  initGame();
  initDisp();

  sceKernelSleepThread();
  return 0;
}
Beispiel #4
0
static lua_State *initLuaState(GList *scriptList) {

   GList *nextScript = scriptList;
   lua_State *L = NULL;

   while (NULL != nextScript) {

      /* only initialize lua state if we have something to execute */
      if (NULL == L) {
         L = luaL_newstate();
         initLua(L);
      }

      if (loadScript(L, (char *)dstrview((dstring_t)nextScript->data))) {
         primeLua(L);
      }

      nextScript = g_list_next(nextScript);
   }

   return L;
}
Beispiel #5
0
void TestGame2::init() {
        initAssets();
        initScene();
        initLua();
}
Beispiel #6
0
void DXDB_main() { //NOTE: must come after rdbLoad()
    if (!initLua(NULL)) exit(-1);
}
Beispiel #7
0
	void HexagonGame::newGame(const string& mId, bool mFirstPlay, float mDifficultyMult)
	{
		firstPlay = mFirstPlay;
		setLevelData(getLevelData(mId), mFirstPlay);
		difficultyMult = mDifficultyMult;

		// Audio cleanup
		stopAllSounds();
		playSound("go.ogg");
		stopLevelMusic();
		playLevelMusic();

		// Events cleanup
		clearMessage();

		for(auto eventPtr : eventPtrs) delete eventPtr;
		eventPtrs.clear();

		while(!eventPtrQueue.empty()) { delete eventPtrQueue.front(); eventPtrQueue.pop(); }
		eventPtrQueue = queue<EventData*>{};

		// Game status cleanup
		status = HexagonGameStatus{};
		restartId = mId;
		restartFirstTime = false;
		setSides(levelData.getSides());

		// Manager cleanup
		manager.clear();
		factory.createPlayer();

		// Timeline cleanup
		timeline.clear(); timeline.reset();
		messageTimeline.clear(); messageTimeline.reset();
		effectTimelineManager.clear();

		// FPSWatcher reset
		fpsWatcher.reset();
		if(getOfficial()) fpsWatcher.enable();

		// LUA context cleanup
		if(!mFirstPlay) runLuaFunction<void>("onUnload");
		lua = Lua::LuaContext{};
		initLua();
		runLuaFile(levelData.getValueString("lua_file"));
		runLuaFunction<void>("onLoad");

		// Random rotation direction
		if(getRnd(0, 100) > 50) setRotationSpeed(getRotationSpeed() * -1);

		// Reset zoom
		overlayCamera.setView({{getWidth() / 2.f, getHeight() / 2.f}, sf::Vector2f(getWidth(), getHeight())});
		backgroundCamera.setView({{0, 0}, {getWidth() * getZoomFactor(), getHeight() * getZoomFactor()}});
		backgroundCamera.setRotation(0);

		// 3D Cameras cleanup
		depthCameras.clear();
		unsigned int depth{styleData.get3DDepth()};
		if(depth > get3DMaxDepth()) depth = get3DMaxDepth();
		for(unsigned int i{0}; i < depth; ++i) depthCameras.push_back({window, {}});
	}