当前位置: 首页>>代码示例>>Java>>正文


Java ScalableGame类代码示例

本文整理汇总了Java中org.newdawn.slick.ScalableGame的典型用法代码示例。如果您正苦于以下问题:Java ScalableGame类的具体用法?Java ScalableGame怎么用?Java ScalableGame使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ScalableGame类属于org.newdawn.slick包,在下文中一共展示了ScalableGame类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initAppContainer

import org.newdawn.slick.ScalableGame; //导入依赖的package包/类
/**
 * Create the window in which to place the game!
 * 
 * @param fullscreen
 *            true if you want to create a fullscreen game.
 */
public void initAppContainer(boolean fullscreen) {
	ScalableGame scalableGame = new ScalableGame(this,
			Constants.GAME_WIDTH, Constants.GAME_HEIGHT, true);

	try {
		gameContainer = new AppGameContainer(scalableGame);
		gameContainer.setVerbose(Constants.DEBUG);
		gameContainer.setTargetFrameRate(120);
		gameContainer.setShowFPS(false);
		gameContainer.setIcons(new String[] { "res/menu/ContainerIcon.tga",
				"res/menu/ContainerTabIcon.tga",
				"res/menu/ContainerTabIcon2.tga" });
		this.setAppFullScreen(fullscreen);
	} catch (SlickException e) {
		e.printStackTrace();
	}
}
 
开发者ID:verath,项目名称:ESCP,代码行数:24,代码来源:StateController.java

示例2: main

import org.newdawn.slick.ScalableGame; //导入依赖的package包/类
public static void main(String[] args) {
	try {
		AppGameContainer app = new AppGameContainer(
				new ScalableGame(new Main(TITLE), GamePanel.WIDTH, GamePanel.HEIGHT));

		int screenWidth = app.getScreenWidth();
		int screenHeight = app.getScreenHeight();

		while (GamePanel.WIDTH * GamePanel.SCALE >= screenWidth
				|| GamePanel.HEIGHT * GamePanel.SCALE >= screenHeight) {
			GamePanel.SCALE--;
		}
		GamePanel.SCALE--;

		app.setDisplayMode(GamePanel.WIDTH * GamePanel.SCALE, GamePanel.HEIGHT * GamePanel.SCALE, false); // frame
		// resolution
		app.setTargetFrameRate(max_fps); // frame rate lock
		app.setVSync(true); // enable vsync

		app.setShowFPS(false); // show/hide fps counter

		app.start();

		return;
	} catch (SlickException e) {
		e.printStackTrace();
	}
}
 
开发者ID:Timbals,项目名称:YellowSquare,代码行数:29,代码来源:Main.java

示例3: startMonkeyShines

import org.newdawn.slick.ScalableGame; //导入依赖的package包/类
/**
 * Starts the actual game either in fullscreen or not. Game always runs in 640x480 resolution
 * internally, whether or not it is scaled visually.
 * <p/>
 * Returning false here indicates the game is already running and another instance won't start
 * (so a user couldn't alt-tab to the other JFrame for the main menu and open another world).
 * If the game is not running, this will return true indicating that <strong> it already ran</strong>.
 * This is a blocking method... once called, control will not return until the user exits the game.
 * <p/>
 * More critical failures to run the game are found in the generated SlickException
 * @param world
 * 		the actual world to play
 * @param fullScreen
 * 		{@code true} to use fullscreen, {@code false} not to.
 * @return
 * @throws SlickException
 */
public static boolean startMonkeyShines(FrozenWorld world, KeyBindingsSlick keyBindings, boolean fullScreen) 
	throws SlickException
{
	if (SlickMonkeyShines.running)
	{
		return false;
	}
	
	SlickMonkeyShines.running = true;
	SlickMonkeyShines monkeyShines = new SlickMonkeyShines(world,  keyBindings);
	
	AppGameContainer bonzoContainer = new AppGameContainer(
		new ScalableGame(
			monkeyShines,
			GameConstants.SCREEN_WIDTH, 
			GameConstants.SCREEN_HEIGHT + GameConstants.UI_HEIGHT));
	monkeyShines.setQuitAction(() -> {
		monkeyShines.closeRequested();
		bonzoContainer.exit();
	});
	
	// TODO separate video settings so that both full/non full screen can use variety of size settings.
	ScreenSize resolution = fullScreen 
		? ScreenSize.getLargestResolution()
		: VideoSettings.getResolution();
		
	bonzoContainer.setDisplayMode(
		resolution.getWidth(),
		resolution.getHeight(),
		fullScreen);
	
	bonzoContainer.setIcon("resources/graphics/ms_launch.png");
	
	// This game was never set up with the ability to calculate things using a delta of time between
	// updating game logic. Easiest solution currently is to just clamp the speed to the exact speed it
	// should run, which shouldn't have a problem on modern systems given how simple the game is.
	bonzoContainer.setMinimumLogicUpdateInterval(GameConstants.GAME_SPEED);
	bonzoContainer.setTargetFrameRate(GameConstants.FRAMES_PER_SECOND);
	bonzoContainer.setForceExit(false);

	try {
		bonzoContainer.start();
	// This code doesn't continue until game ends.
	} finally {
		monkeyShines.destroySounds();
		SlickMonkeyShines.running = false;
	}
	
	bonzoContainer.destroy();
	
	// This is VERY important! If the texture cache is not cleared, then if the user
	// starts another game the textures from the previous game will collide with the textures
	// from the... it's basically a fucking mess. Comment this out to see something cool when
	// choosing another world but otherwise keep this in.
	InternalTextureLoader.get().clear();
	
	return true;
}
 
开发者ID:ErikaRedmark,项目名称:monkey-shines-java-port,代码行数:76,代码来源:SlickMonkeyShinesStart.java


注:本文中的org.newdawn.slick.ScalableGame类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。