• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ScalableGame类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TenantService类代码示例发布时间:2022-05-22
下一篇:
Java FileUploadBase类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap