當前位置: 首頁>>代碼示例>>Java>>正文


Java StateBasedGame類代碼示例

本文整理匯總了Java中org.newdawn.slick.state.StateBasedGame的典型用法代碼示例。如果您正苦於以下問題:Java StateBasedGame類的具體用法?Java StateBasedGame怎麽用?Java StateBasedGame使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


StateBasedGame類屬於org.newdawn.slick.state包,在下文中一共展示了StateBasedGame類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: update

import org.newdawn.slick.state.StateBasedGame; //導入依賴的package包/類
@Override
public void update(GameContainer gc, StateBasedGame game, int delta) throws SlickException {
	percentLoaded = (float)AssetManager.assetsLoaded() / (float)AssetManager.assetsToLoad();
	if(AssetManager.assetsLoaded() == AssetManager.assetsToLoad()) {
		game.addState(new MenuState());
		game.addState(new GameState());
		game.addState(new ShopState());
		game.addState(new TrainState());
		game.addState(new GameOverState());
		game.addState(new CreditsState());
		game.addState(new BlankState());
		
		game.init(gc);
		game.enterState(MenuState.ID); // we're done loading
	}
}
 
開發者ID:packetpirate,項目名稱:Generic-Zombie-Shooter-Redux,代碼行數:17,代碼來源:LoadingState.java

示例2: postRender

import org.newdawn.slick.state.StateBasedGame; //導入依賴的package包/類
/**
 * @see org.newdawn.slick.state.transition.Transition#postRender(org.newdawn.slick.state.StateBasedGame, org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)
 */
public void postRender(StateBasedGame game, GameContainer container, Graphics g) throws SlickException {
	g.translate(container.getWidth()/2, container.getHeight()/2);
	g.scale(scale,scale);
	g.rotate(0, 0, ang);
	g.translate(-container.getWidth()/2, -container.getHeight()/2);
	if (background != null) {
		Color c = g.getColor();
		g.setColor(background);
		g.fillRect(0,0,container.getWidth(),container.getHeight());
		g.setColor(c);
	}
	prev.render(container, game, g);
	g.translate(container.getWidth()/2, container.getHeight()/2);
	g.rotate(0, 0, -ang);
	g.scale(1/scale,1/scale);
	g.translate(-container.getWidth()/2, -container.getHeight()/2);
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:21,代碼來源:RotateTransition.java

示例3: enter

import org.newdawn.slick.state.StateBasedGame; //導入依賴的package包/類
@Override
public void enter(GameContainer gc, StateBasedGame game) {
	exit = false;
	
	if(Globals.player.getInventory().getCapacity() != inventorySize) {
		// Inventory size has changed. Re-build inventory layout.
		inventorySize = Globals.player.getInventory().getCapacity();
		int cols = SHOP_COLS;
		int rows = (int)(Math.ceil((float)inventorySize / (float)cols));
		if(inventoryBoxes == null) {
			inventoryBoxes = new Rectangle[rows][cols];
		}
		
		for(int r = 0; r < rows; r++) {
			for(int c = 0; c < cols; c++) {
				float x = INVENTORY_CONTAINER.x + 3.0f + ((c * ITEM_BOX_SIZE) + (c * 2.0f));
				float y = INVENTORY_CONTAINER.y + 3.0f + ((r * ITEM_BOX_SIZE) + (c * 2.0f));
				inventoryBoxes[r][c] = new Rectangle(x, y, ITEM_BOX_SIZE, ITEM_BOX_SIZE);
			}
		}
	}
}
 
開發者ID:packetpirate,項目名稱:Generic-Zombie-Shooter-Redux,代碼行數:23,代碼來源:ShopState.java

示例4: preRender

import org.newdawn.slick.state.StateBasedGame; //導入依賴的package包/類
/**
 * @see org.newdawn.slick.state.transition.Transition#preRender(org.newdawn.slick.state.StateBasedGame, org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)
 */
public void preRender(StateBasedGame game, GameContainer container,
		Graphics g) throws SlickException {
	prev.render(container, game, g);
	
	MaskUtil.defineMask();
	for (int i=0;i<blobs.size();i++) {
		((Blob) blobs.get(i)).render(g);
	}
	MaskUtil.finishDefineMask();

	MaskUtil.drawOnMask();
	if (background != null) {
		Color c = g.getColor();
		g.setColor(background);
		g.fillRect(0,0,container.getWidth(),container.getHeight());
		g.setColor(c);
	}
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:22,代碼來源:BlobbyTransition.java

示例5: update

import org.newdawn.slick.state.StateBasedGame; //導入依賴的package包/類
/**
 * @see org.newdawn.slick.state.transition.Transition#update(org.newdawn.slick.state.StateBasedGame, org.newdawn.slick.GameContainer, int)
 */
public void update(StateBasedGame game, GameContainer container, int delta)
		throws SlickException {
	if (blobs.size() == 0) {
		for (int i=0;i<blobCount;i++) {
			blobs.add(new Blob(container));
		}
	}
	
	for (int i=0;i<blobs.size();i++) {
		((Blob) blobs.get(i)).update(delta);
	}
	
	timer -= delta;
	if (timer < 0) {
		finish = true;
	}
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:21,代碼來源:BlobbyTransition.java

示例6: init

import org.newdawn.slick.state.StateBasedGame; //導入依賴的package包/類
@Override
public void init(GameContainer gc, StateBasedGame game) throws SlickException {
	shopBoxes = new Rectangle[SHOP_ROWS][SHOP_COLS];
	for(int r = 0; r < SHOP_ROWS; r++) {
		for(int c = 0; c < SHOP_COLS; c++) {
			float x = SHOP_CONTAINER.x + 3.0f + ((c * ITEM_BOX_SIZE) + (c * 2.0f));
			float y = SHOP_CONTAINER.y + 3.0f + ((r * ITEM_BOX_SIZE) + (c * 2.0f));
			shopBoxes[r][c] = new Rectangle(x, y, ITEM_BOX_SIZE, ITEM_BOX_SIZE);
		}
	}
	
	inventoryBoxes = null;
	selected = null;
	selectedInInventory = false;
	
	buyButton = new TransactionButton(new Pair<Float>((float)((Globals.WIDTH / 2) - 58.0f), (Globals.HEIGHT - 70.0f)), TransactionButton.Type.BUY);
	sellButton = new TransactionButton(new Pair<Float>((float)((Globals.WIDTH / 2) + 58.0f), (Globals.HEIGHT - 70.0f)), TransactionButton.Type.SELL);
	
	inventorySize = 0;
	exit = false;
}
 
開發者ID:packetpirate,項目名稱:Generic-Zombie-Shooter-Redux,代碼行數:22,代碼來源:ShopState.java

示例7: showSunCollected

import org.newdawn.slick.state.StateBasedGame; //導入依賴的package包/類
/**
 * Draw sun collected
 * @param gc	GameContainer
 * @param sbg	StateBasedGame
 * @param g	Graphics
 * @throws SlickException
 */
public static void showSunCollected(GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException {
	float iconPosX = 10 * PZGUI.getResolutionRateWidth();
	float iconPosY = 5  * PZGUI.getResolutionRateHeight();
	float iconW = 80 * PZGUI.getResolutionRateWidth();
	float iconH = 80 * PZGUI.getResolutionRateHeight();

	float textPosX = 120 * PZGUI.getResolutionRateWidth();
	float textPosY = 22  * PZGUI.getResolutionRateHeight();

	float posX = 60 * PZGUI.getResolutionRateWidth();
	float posY = 20 * PZGUI.getResolutionRateHeight();
	float W = 150 * PZGUI.getResolutionRateWidth();
	float H = 45  * PZGUI.getResolutionRateHeight();

	g.setColor(new Color(0, 0, 0, 150));
	g.fillRoundRect(posX, posY, W, H, 20);
	SunUI.drawIcon(iconPosX, iconPosY, iconW, iconH);

	sunView.render(textPosX, textPosY, SunUI.getSunCollected().toString(), Color.white);
	g.setColor(new Color(255, 255, 255));
}
 
開發者ID:hungthuanmk,項目名稱:HCMIU_PlantsAndZombies,代碼行數:29,代碼來源:PlayUI.java

示例8: render

import org.newdawn.slick.state.StateBasedGame; //導入依賴的package包/類
@Override
public void render(GameContainer gc, StateBasedGame game, Graphics g) throws SlickException {
	g.resetTransform();
	g.clear();
	
	float lw = 400.0f;
	float lh = 50.0f;
	float lx = (Globals.WIDTH / 2) - (lw / 2);
	float ly = (Globals.HEIGHT / 2) - (lh / 2);
	float loadWidth = lw * percentLoaded;
	
	g.setColor(new Color(0x808080));
	g.fillRect(lx, ly, lw, lh);
	g.setColor(new Color(0x9B2111));
	g.fillRect(lx, ly, loadWidth, lh);
	g.setColor(Color.white);
	g.drawRect(lx, ly, lw, lh);
	
	g.setColor(Color.white);
	UnicodeFont uni = assets.getFont("PressStart2P-Regular_large");
	if(uni != null) {
		g.setFont(uni);
		FontUtils.drawCenter(uni, "Loading...", ((Globals.WIDTH / 2) - 200), (int)(ly - uni.getLineHeight() - 10), (int)lw, g.getColor());
	}
}
 
開發者ID:packetpirate,項目名稱:Generic-Zombie-Shooter-Redux,代碼行數:26,代碼來源:LoadingState.java

示例9: preRender

import org.newdawn.slick.state.StateBasedGame; //導入依賴的package包/類
/**
 * @see org.newdawn.slick.state.transition.Transition#preRender(org.newdawn.slick.state.StateBasedGame, org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)
 */
public void preRender(StateBasedGame game, GameContainer container,
		Graphics g) throws SlickException {
	if (moveBackDone) {
		g.translate(xp1,yp1);
		g.scale(scale1, scale1);
		g.setClip((int) xp1,(int) yp1,(int) (scale1*container.getWidth()),(int) (scale1*container.getHeight()));
		prev.render(container, game, g);
		g.resetTransform();
		g.clearClip();
	}
	
	g.translate(xp2,yp2);
	g.scale(scale2, scale2);
	g.setClip((int) xp2,(int) yp2,(int) (scale2*container.getWidth()),(int) (scale2*container.getHeight()));
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:19,代碼來源:SelectTransition.java

示例10: postRender

import org.newdawn.slick.state.StateBasedGame; //導入依賴的package包/類
/**
 * @see org.newdawn.slick.state.transition.Transition#postRender(org.newdawn.slick.state.StateBasedGame, org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)
 */
public void postRender(StateBasedGame game, GameContainer container, Graphics g) {
	Color old = g.getColor();
	g.setColor(color);
	
	g.fillRect(0, 0, container.getWidth()*2, container.getHeight()*2);
	g.setColor(old);
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:11,代碼來源:FadeInTransition.java

示例11: init

import org.newdawn.slick.state.StateBasedGame; //導入依賴的package包/類
@Override
public void init(GameContainer gc, StateBasedGame game) throws SlickException {
	assets = AssetManager.getManager();
	
	gc.setMouseCursor(assets.getImage("GZS_Crosshair"), 16, 16);
	
	Globals.player = new Player();
	entities = new ConcurrentHashMap<String, Entity>();
	
	reset(gc);
}
 
開發者ID:packetpirate,項目名稱:Generic-Zombie-Shooter-Redux,代碼行數:12,代碼來源:GameState.java

示例12: postRender

import org.newdawn.slick.state.StateBasedGame; //導入依賴的package包/類
/**
 * @see org.newdawn.slick.state.transition.Transition#postRender(org.newdawn.slick.state.StateBasedGame, org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)
 */
public void postRender(StateBasedGame game, GameContainer container, Graphics g) throws SlickException {
	g.resetTransform();
	
	if (!moveBackDone) {
		g.translate(xp1,yp1);
		g.scale(scale1, scale1);
		g.setClip((int) xp1,(int) yp1,(int) (scale1*container.getWidth()),(int) (scale1*container.getHeight()));
		prev.render(container, game, g);
		g.resetTransform();
		g.clearClip();
	}
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:16,代碼來源:SelectTransition.java

示例13: update

import org.newdawn.slick.state.StateBasedGame; //導入依賴的package包/類
/**
 * @see org.newdawn.slick.state.transition.Transition#update(org.newdawn.slick.state.StateBasedGame, org.newdawn.slick.GameContainer, int)
 */
public void update(StateBasedGame game, GameContainer container, int delta)
		throws SlickException {
	offset += delta * 1f;
	if (offset > container.getHeight() / 2) {
		finish = true;
	}
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:11,代碼來源:VerticalSplitTransition.java

示例14: update

import org.newdawn.slick.state.StateBasedGame; //導入依賴的package包/類
/**
 * @see org.newdawn.slick.state.transition.Transition#update(org.newdawn.slick.state.StateBasedGame, org.newdawn.slick.GameContainer, int)
 */
public void update(StateBasedGame game, GameContainer container, int delta)
		throws SlickException {
	ang += delta * 0.5f;
	if (ang > 500) {
		finish = true;
	}
	scale -= delta * 0.001f;
	if (scale < 0) {
		scale = 0;
	}
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:15,代碼來源:RotateTransition.java

示例15: update

import org.newdawn.slick.state.StateBasedGame; //導入依賴的package包/類
/**
 * @see org.newdawn.slick.state.transition.Transition#update(org.newdawn.slick.state.StateBasedGame, org.newdawn.slick.GameContainer, int)
 */
public void update(StateBasedGame game, GameContainer container, int delta)
		throws SlickException {
	offset += delta * 1f;
	if (offset > container.getWidth() / 2) {
		finish = true;
	}
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:11,代碼來源:HorizontalSplitTransition.java


注:本文中的org.newdawn.slick.state.StateBasedGame類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。