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

The following examples show how to use org.newdawn.slick.GameContainer#setVSync() . 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: Options.java    From opsu with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void selectItem(int index, GameContainer container) {
	targetFPSindex = index;

	int fps = getTargetFPS();
	boolean vsync = (fps == 60);
	container.setTargetFrameRate(fps);
	if (container.isVSyncRequested() != vsync) {
		container.setVSync(vsync);
	}
}
 
Example 2
Source File: MorphShapeTest.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * @see BasicGame#init(GameContainer)
 */
public void init(GameContainer container) throws SlickException {
	a = new Rectangle(100,100,50,200);
	a = a.transform(Transform.createRotateTransform(0.1f,100,100));
	b = new Rectangle(200,100,50,200);
	b = b.transform(Transform.createRotateTransform(-0.6f,100,100));
	c = new Rectangle(300,100,50,200);
	c = c.transform(Transform.createRotateTransform(-0.2f,100,100));
	
	morph = new MorphShape(a);
	morph.addShape(b);
	morph.addShape(c);
	
	container.setVSync(true);
}
 
Example 3
Source File: MorphSVGTest.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * @see BasicGame#init(GameContainer)
 */
public void init(GameContainer container) throws SlickException {
	base = InkscapeLoader.load("testdata/svg/walk1.svg");
	morph = new SVGMorph(base);
	morph.addStep(InkscapeLoader.load("testdata/svg/walk2.svg"));
	morph.addStep(InkscapeLoader.load("testdata/svg/walk3.svg"));
	morph.addStep(InkscapeLoader.load("testdata/svg/walk4.svg"));
	
	container.setVSync(true);
}
 
Example 4
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
		);
	}
}
 
Example 5
Source File: GeomUtilTest.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * @see BasicGame#init(GameContainer)
 */
public void init(GameContainer container) throws SlickException {
	util.setListener(this);
	init();
	container.setVSync(true);
}