Example #1
0
	GameResources::GameResources(AppService& appService)
	{
		Sound& sound = appService.getSound();
		Console& console = appService.getConsole();
		TextureManager& textureManager = appService.getTextureManager();

		console.printLine("\n===Initializing game resources===");
		console.printLine("\n...Weapon initialization");
		Weapon::initialize(sound, textureManager);
		console.printLine("...Building water-list");
		Water::initialize(sound, appService.getTextureManager());
		console.printLine("...Loading game sounds");
		roundStartSound = sound.loadSample("sound/game/round-start.wav");
		gameOverSound = sound.loadSample("sound/game/game-over.wav");
		console.printLine(Format("...Loading block meta data: {0}") << D6_FILE_BLOCK_META);
		blockMeta = Block::loadMeta(D6_FILE_BLOCK_META);
		console.printLine(Format("...Loading block textures: {0}") << D6_TEXTURE_BLOCK_PATH);
		blockTextures = textureManager.load(D6_TEXTURE_BLOCK_PATH, TextureFilter::LINEAR, true);
		console.printLine(Format("...Loading background textures: {0}") << D6_TEXTURE_BCG_PATH);
		bcgTextures = textureManager.load(D6_TEXTURE_BCG_PATH, TextureFilter::LINEAR, true);
		console.printLine(Format("...Loading explosion textures: {0}") << D6_TEXTURE_EXPL_PATH);
		explosionTextures = textureManager.load(D6_TEXTURE_EXPL_PATH, TextureFilter::NEAREST, true);
		console.printLine(Format("...Loading bonus textures: {0}") << D6_TEXTURE_EXPL_PATH);
		bonusTextures = textureManager.load(D6_TEXTURE_BONUS_PATH, TextureFilter::LINEAR, true);
		console.printLine(Format("...Loading elevator textures: {0}") << D6_TEXTURE_ELEVATOR_PATH);
		elevatorTextures = textureManager.load(D6_TEXTURE_ELEVATOR_PATH, TextureFilter::LINEAR, true);

		console.printLine(Format("...Loading fire textures: {0}") << D6_TEXTURE_FIRE_PATH);
		for (const FireType& fireType : FireType::values())
		{
			TextureList texture = textureManager.load(Format("{0}{1,3|0}/") << D6_TEXTURE_FIRE_PATH << fireType.getId(), TextureFilter::LINEAR, true);
			fireTextures[fireType.getId()] = texture;

			glBindTexture(GL_TEXTURE_2D, texture.at(2).getId());
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
		}

		console.printLine("\n...Bonus initialization");
		BonusType::initialize(bonusTextures);
	}
	void ConsoleCommands::registerCommands(Console& console, AppService& appService, Menu& menu, GameSettings& gameSettings)
	{
		SDL_version sdlVersion;
		std::string verStr = D6_L("version");

		// Print application info
		console.printLine(D6_L("\n===Application information==="));
		console.printLine(Format("{0} {1}: {2}") << APP_NAME << verStr << APP_VERSION);
		SDL_GetVersion(&sdlVersion);
		console.printLine(Format("SDL {0}: {1}.{2}.{3}") << verStr << sdlVersion.major << sdlVersion.minor << sdlVersion.patch);
		const SDL_version* mixVersion = Mix_Linked_Version();
		console.printLine(Format("SDL_mixer {0}: {1}.{2}.{3}") << verStr << mixVersion->major << mixVersion->minor << mixVersion->patch);
		console.printLine(D6_L("Language: english"));

		// Set some console functions
		console.setLast(15);
		console.registerCommand("switch_render_mode", [&gameSettings](Console& con, const Console::Arguments& args) {
			toggleRenderMode(con, args, gameSettings);
		});
		console.registerCommand("show_fps", [&gameSettings](Console& con, const Console::Arguments& args) {
			toggleShowFps(con, args, gameSettings);
		});
		console.registerCommand("gl_info", openGLInfo);
		console.registerCommand("lang", language);
		console.registerCommand("volume", [&appService](Console& con, const Console::Arguments& args) {
			volume(con, args, appService.getSound());
		});
		console.registerCommand("rounds", [&gameSettings](Console& con, const Console::Arguments& args) {
			maxRounds(con, args, gameSettings);
		});
		console.registerCommand("ghosts", [&gameSettings](Console& con, const Console::Arguments& args) {
			ghostMode(con, args, gameSettings);
		});
		console.registerCommand("music", [&menu](Console& con, const Console::Arguments& args) {
			musicOnOff(con, args, menu);
		});
		console.registerCommand("joy_scan", [&menu](Console& con, const Console::Arguments& args) {
			joyScan(con, args, menu);
		});
		console.registerCommand("skin", [&menu](Console& con, const Console::Arguments& args) {
			loadSkin(con, args, menu);
		});
		console.registerCommand("gun", enableWeapon);
		console.registerCommand("start_ammo_range", [&gameSettings](Console& con, const Console::Arguments& args) {
			ammoRange(con, args, gameSettings);
		});
	}
Example #3
0
	Menu::Menu(AppService& appService)
		: appService(appService), font(appService.getFont()), video(appService.getVideo()),
		sound(appService.getSound()), controlsManager(appService.getInput()), playMusic(false)
	{}