Java Code Examples for org.newdawn.slick.GameContainer#setMusicVolume()

The following examples show how to use org.newdawn.slick.GameContainer#setMusicVolume() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Utils.java    From opsu with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Initializes game settings and class data.
 * @param container the game container
 * @param game the game object
 */
public static void init(GameContainer container, StateBasedGame game) {
	input = container.getInput();
	int width = container.getWidth();
	int height = container.getHeight();

	// game settings
	container.setTargetFrameRate(Options.getTargetFPS());
	container.setVSync(Options.getTargetFPS() == 60);
	container.setMusicVolume(Options.getMusicVolume() * Options.getMasterVolume());
	container.setShowFPS(false);
	container.getInput().enableKeyRepeat();
	container.setAlwaysRender(true);
	container.setUpdateOnlyWhenVisible(false);

	// record OpenGL version
	ErrorHandler.setGlString();

	// calculate UI scale
	GameImage.init(width, height);

	// create fonts
	try {
		Fonts.init();
	} catch (Exception e) {
		ErrorHandler.error("Failed to load fonts.", e, true);
	}

	// load skin
	Options.loadSkin();

	// initialize game images
	for (GameImage img : GameImage.values()) {
		if (img.isPreload())
			img.setDefaultImage();
	}

	// initialize game mods
	GameMod.init(width, height);

	// initialize playback buttons
	PlaybackSpeed.init(width, height);

	// initialize hit objects
	HitObject.init(width, height);

	// initialize download nodes
	DownloadNode.init(width, height);

	// initialize UI components
	UI.init(container, game);

	// build user list
	UserList.create();

	// initialize user button
	UserButton.init(width, height);

	// warn about software mode
	if (((Container) container).isSoftwareMode()) {
		UI.getNotificationManager().sendNotification(
			"WARNING:\n" +
			"Running in OpenGL software mode.\n" +
			"You may experience severely degraded performance.\n\n" +
			"This can usually be resolved by updating your graphics drivers.",
			Color.red
		);
	}
}