Ejemplo n.º 1
0
void Game::quit()
{
	m_running = false;

	// Save configuration to settings file
	IniParser config;
	config.seek_section("Wallbreaker");
	config.set("highscore",  Settings::highscore);
	config.set("app_width",  m_window.getSize().x);
	config.set("app_height", m_window.getSize().y);
	config.set("sound",      SoundSystem::isSoundEnabled());
	config.set("music",      SoundSystem::isMusicEnabled());
	config.save(m_app_dir + WB_SETTINGS_FILE);
}
Ejemplo n.º 2
0
void Game::init(const std::string& path)
{
	// Set application directory
	size_t last_dir = path.find_last_of("/\\");
	m_app_dir = path.substr(0, last_dir + 1);
	if (m_app_dir.empty())
		m_app_dir = "./";

	// Init resources search directory
	Resources::setSearchPath(m_app_dir + "/resources/");

	// Init levels
	std::cout << "* loading levels from " << WB_LEVEL_FILE << std::endl;
	LevelManager::getInstance().openFromFile(m_app_dir + WB_LEVEL_FILE);

	// Init GUI module
	gui::Theme::loadFont(m_app_dir + "/resources/images/font.png");

	SoundSystem::openMusicFromFile(m_app_dir + "/resources/musics/evolution_sphere.ogg");

	// Load configuration from settings file
	IniParser config;
	std::cout << "* loading settings from " << WB_SETTINGS_FILE << std::endl;
	if (config.load(m_app_dir + WB_SETTINGS_FILE))
	{
		config.seek_section("Wallbreaker");
		size_t app_width = config.get("app_width", APP_WIDTH * 2);
		size_t app_height = config.get("app_height", APP_HEIGHT * 2);
		setResolution(app_width, app_height);

		Settings::highscore = config.get("highscore", 0);

		SoundSystem::enableSound(config.get("sound", true));
		SoundSystem::enableMusic(config.get("music", true));
	}
	else
	{
		setResolution(APP_WIDTH * 2, APP_HEIGHT * 2);
	}

	SoundSystem::playMusic();
}