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


Java Graphics.drawImage方法代碼示例

本文整理匯總了Java中org.newdawn.slick.Graphics.drawImage方法的典型用法代碼示例。如果您正苦於以下問題:Java Graphics.drawImage方法的具體用法?Java Graphics.drawImage怎麽用?Java Graphics.drawImage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.newdawn.slick.Graphics的用法示例。


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

示例1: render

import org.newdawn.slick.Graphics; //導入方法依賴的package包/類
/**
 * @see org.newdawn.slick.BasicGame#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)
 */
public void render(GameContainer container, Graphics g) {
	g.drawString("T - TGA Snapshot", 10,50);
	g.drawString("J - JPG Snapshot", 10,70);
	g.drawString("P - PNG Snapshot", 10,90);

	g.setDrawMode(Graphics.MODE_ADD);
	g.drawImage(copy, 200, 300);
	g.setDrawMode(Graphics.MODE_NORMAL);
	
	g.drawString(message, 10,400);
	g.drawRect(200,0,400,300);
	g.translate(400, 250);
	fire.render();
	this.g = g;
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:19,代碼來源:ImageOutTest.java

示例2: render

import org.newdawn.slick.Graphics; //導入方法依賴的package包/類
/**
 * @see org.newdawn.slick.BasicGame#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)
 */
public void render(GameContainer container, Graphics g) {
	g.drawString("R - Toggle Rotationg",10,50);
	g.drawImage(image1, 100, 236);
	g.drawImage(image2, 600, 236);
	
	g.translate(0, -150);
	g.rotate(400, 300, ang);
	g.texture(shape, image2);
	g.texture(shape, image1, fill);
	g.resetTransform();
	
	g.translate(0, 150);
	g.rotate(400, 300, ang);
	g.texture(poly, image2);
	g.texture(poly, image1, fill);
	g.resetTransform();
}
 
開發者ID:IngSW-unipv,項目名稱:Progetto-C,代碼行數:21,代碼來源:GradientImageTest.java

示例3: render

import org.newdawn.slick.Graphics; //導入方法依賴的package包/類
/**
 * @see org.newdawn.slick.BasicGame#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)
 */
public void render(GameContainer container, Graphics g) throws SlickException {
	g.scale(2,2);
	g.fillRect(0, 0, 800, 600, back, 0, 0);
	g.resetTransform();
	
	g.drawImage(image,100,100);
	image.draw(100,200,80,200);
	
	font.drawString(100,200,"Text Drawn before the callable");
	
	SlickCallable callable = new SlickCallable() {
		protected void performGLOperations() throws SlickException {
			renderGL();
		}
	};
	callable.call();
	
	homer.draw(450,250,80,200);
	font.drawString(150,300,"Text Drawn after the callable");
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:24,代碼來源:SlickCallableTest.java

示例4: render

import org.newdawn.slick.Graphics; //導入方法依賴的package包/類
@Override
public void render(Graphics g, long cTime) {
	// Render all the player's active weapons.
	getActiveWeapons().stream().forEach(w -> w.render(g, cTime));
	
	Image image = getImage();
	if(image != null) {
		g.rotate(position.x, position.y, (float)Math.toDegrees(theta));
		g.drawImage(image, (position.x - (image.getWidth() / 2)), 
						   (position.y - (image.getHeight() / 2)));
		g.resetTransform();
	} else {
		// Draw a shape to represent the missing player image.
		g.setColor(Color.red);
		g.fillOval((position.x - 20), (position.y - 20), 40, 40);
	}
}
 
開發者ID:packetpirate,項目名稱:Generic-Zombie-Shooter-Redux,代碼行數:18,代碼來源:Player.java

示例5: render

import org.newdawn.slick.Graphics; //導入方法依賴的package包/類
@Override
public void render(Graphics g, long cTime) {
	// Render all projectiles.
	projectiles.stream().filter(p -> p.isAlive(cTime)).forEach(p -> p.render(g, cTime));
	
	// Render the turret base.
	Image base = AssetManager.getManager().getImage(Turret.TURRET_IMAGE).getSubImage(0, 0, 48, 48);
	if(base != null) g.drawImage(base, (position.x - 24.0f), (position.y - 24.0f));
	
	// Render the sentry's laser sight.
	float facing = theta;
	float dist = ((target != null) && target.isAlive(cTime)) ? Math.min(Turret.FIRING_RANGE, Calculate.Distance(position, target.getPosition())) : Turret.FIRING_RANGE;
	g.setColor(Turret.TURRET_LASER);
	g.setLineWidth(2.0f);
	g.drawLine(position.x, position.y, 
			   (position.x + ((float)Math.cos(facing) * dist)), 
			   (position.y + ((float)Math.sin(facing) * dist)));
	g.setLineWidth(1.0f);
	
	// Render the rotated turret head.
	Image head = AssetManager.getManager().getImage(Turret.TURRET_IMAGE).getSubImage(48, 0, 48, 48);
	if(head != null) {
		g.rotate(position.x, position.y, (float)Math.toDegrees(theta + (float)(Math.PI / 2)));
		g.drawImage(head, (position.x - 24.0f), (position.y - 24.0f));
		g.resetTransform();
	}
}
 
開發者ID:packetpirate,項目名稱:Generic-Zombie-Shooter-Redux,代碼行數:28,代碼來源:Turret.java

示例6: render

import org.newdawn.slick.Graphics; //導入方法依賴的package包/類
/**
 * @see org.newdawn.slick.state.BasicGameState#render(org.newdawn.slick.GameContainer, org.newdawn.slick.state.StateBasedGame, org.newdawn.slick.Graphics)
 */
public void render(GameContainer container, StateBasedGame game, Graphics g) {
	g.setFont(font);
	g.setColor(Color.green);
	g.drawString("This is State 2", 200, 50);
	
	g.rotate(400,300,ang);
	g.drawImage(image,400-(image.getWidth()/2),300-(image.getHeight()/2));
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:12,代碼來源:TestState2.java

示例7: render

import org.newdawn.slick.Graphics; //導入方法依賴的package包/類
public void render(GameContainer container, Graphics g) throws SlickException {
   g.setColor(Color.white);
   g.drawString("Endianness is " + endian, 10, 100);
   
   g.drawString("Image below should be red", 10, 200);
   g.drawImage(fromRed, 10, 220);
   g.drawString("Image below should be blue", 410, 200);
   g.drawImage(fromBlue, 410, 220);
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:10,代碼來源:ImageBufferEndianTest.java

示例8: render

import org.newdawn.slick.Graphics; //導入方法依賴的package包/類
@Override
public void render(GameContainer gc, StateBasedGame game, Graphics g) throws SlickException {
	Image deathScreen = assets.getImage("GZS_DeathScreen");
	if(deathScreen != null) {
		g.drawImage(deathScreen, 
					0.0f, 0.0f, Globals.WIDTH, Globals.HEIGHT, 
					0.0f, 0.0f, deathScreen.getWidth(), deathScreen.getHeight());
	}
	
	menuButton.render(g);
	exitButton.render(g);
}
 
開發者ID:packetpirate,項目名稱:Generic-Zombie-Shooter-Redux,代碼行數:13,代碼來源:GameOverState.java

示例9: render

import org.newdawn.slick.Graphics; //導入方法依賴的package包/類
@Override
public void render(GameContainer gc, StateBasedGame game, Graphics g) throws SlickException {
	Image background = assets.getImage("GZS_Background02");
	
	g.resetTransform();
	g.clear();
	
	if(background != null) g.drawImage(background, 0.0f, 0.0f, Globals.WIDTH, Globals.HEIGHT, 0.0f, 0.0f, background.getWidth(), background.getHeight());
	
	gameStart.render(g);
	credits.render(g);
	exit.render(g);
}
 
開發者ID:packetpirate,項目名稱:Generic-Zombie-Shooter-Redux,代碼行數:14,代碼來源:MenuState.java

示例10: render

import org.newdawn.slick.Graphics; //導入方法依賴的package包/類
public void render(Graphics g) {
	Image img = AssetManager.getManager().getImage(image);
	if(img == null) {
		// Draw the text representing the button.
		UnicodeFont fnt = AssetManager.getManager().getFont(FONT_NAME); 
		Color color = mouseOver() ? DEFAULT_HOVER : DEFAULT_TEXT;
		
		g.setColor(color);
		g.setFont(fnt);
		g.drawString(text, position.x, position.y);
	} else g.drawImage(img, position.x, position.y);
}
 
開發者ID:packetpirate,項目名稱:Generic-Zombie-Shooter-Redux,代碼行數:13,代碼來源:MenuButton.java

示例11: render

import org.newdawn.slick.Graphics; //導入方法依賴的package包/類
/**
 * Render the current frame of the animation.
 * @param g The graphics context used for drawing.
 * @param position The position to render the animation at.
 * @param size The size to override the size of the image with.
 */
public void render(Graphics g, Pair<Float> position, Pair<Float> size) {
	Image image = getImage();
	if(image != null) {
		float tlx = position.x - (size.x / 2);
		float tly = position.y - (size.y / 2);
		g.drawImage(image, 
					tlx, tly, (tlx + size.x), (tly + size.y), 
					srcPos.x, srcPos.y, (srcPos.x + srcSize.x), (srcPos.y + srcSize.y));
		g.resetTransform();
	}
}
 
開發者ID:packetpirate,項目名稱:Generic-Zombie-Shooter-Redux,代碼行數:18,代碼來源:Animation.java

示例12: render

import org.newdawn.slick.Graphics; //導入方法依賴的package包/類
/**
 * @see org.newdawn.slick.BasicGame#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)
 */
public void render(GameContainer container, Graphics g) {
	original.draw(0,0,new Color(1,1,1,0.4f));
	
	image.draw(x,y);
	imageX.draw(x+400,y);
	imageY.draw(x,y+300);
	scaledSub.draw(x+300,y+300);
	
	bigSheet.getSprite(7, 5).draw(50,10);
	g.setColor(Color.white);
	g.drawRect(50,10,64,64);
	g.rotate(x+400, y+165, ang);
	g.drawImage(sub, x+300, y+100);
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:18,代碼來源:BigImageTest.java

示例13: render

import org.newdawn.slick.Graphics; //導入方法依賴的package包/類
@Override
public void render(Graphics g, long cTime) {
	// Draw using position as center.
	Image button = AssetManager.getManager().getImage(image);
	if(button != null) g.drawImage(button, (position.x - (button.getWidth() / 2)), (position.y - (button.getHeight() / 2)));
}
 
開發者ID:packetpirate,項目名稱:Generic-Zombie-Shooter-Redux,代碼行數:7,代碼來源:TransactionButton.java

示例14: render

import org.newdawn.slick.Graphics; //導入方法依賴的package包/類
/**
 * @see org.newdawn.slick.BasicGame#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)
 */
public void render(GameContainer container, Graphics g) throws SlickException {
	g.setColor(Color.white);
	
	g.setAntiAlias(true);
	for (int x=0;x<360;x+=10) {
		g.drawLine(700,100,(int) (700+(Math.cos(Math.toRadians(x))*100)),
						   (int) (100+(Math.sin(Math.toRadians(x))*100)));
	}
	g.setAntiAlias(false);
	
	g.setColor(Color.yellow);
	g.drawString("The Graphics Test!", 300, 50);
	g.setColor(Color.white);
	g.drawString("Space - Toggles clipping", 400, 80);
	g.drawString("Frame rate capped to 100", 400, 120);
	
	if (clip) {
		g.setColor(Color.gray);
		g.drawRect(100,260,400,100);
		g.setClip(100,260,400,100);
	}

	g.setColor(Color.yellow);
	g.translate(100, 120);
	g.fill(poly);
	g.setColor(Color.blue);
	g.setLineWidth(3);
	g.draw(poly);
	g.setLineWidth(1);
	g.translate(0, 230);
	g.draw(poly);
	g.resetTransform();
	
	g.setColor(Color.magenta);
	g.drawRoundRect(10, 10, 100, 100, 10);
	g.fillRoundRect(10, 210, 100, 100, 10);
	
	g.rotate(400, 300, ang);
	g.setColor(Color.green);
	g.drawRect(200,200,200,200);
	g.setColor(Color.blue);
	g.fillRect(250,250,100,100);

	g.drawImage(image, 300,270);
	
	g.setColor(Color.red);
	g.drawOval(100,100,200,200);
	g.setColor(Color.red.darker());
	g.fillOval(300,300,150,100);
	g.setAntiAlias(true);
	g.setColor(Color.white);
	g.setLineWidth(5.0f);
	g.drawOval(300,300,150,100);
	g.setAntiAlias(true);
	g.resetTransform();
	
	if (clip) {
		g.clearClip();
	}
}
 
開發者ID:IngSW-unipv,項目名稱:Progetto-C,代碼行數:64,代碼來源:GraphicsTest.java

示例15: render

import org.newdawn.slick.Graphics; //導入方法依賴的package包/類
@Override
public void render(GameContainer gc, StateBasedGame game, Graphics g) throws SlickException {
	Player player = Globals.player;
	
	g.resetTransform();
	g.clear();
	
	Image background = assets.getImage("GZS_Background6");
	g.drawImage(background, 0.0f, 0.0f, Globals.WIDTH, Globals.HEIGHT, 0.0f, 0.0f, background.getWidth(), background.getHeight());
	
	player.render(g, time);

	Iterator<Entry<String, Entity>> it = entities.entrySet().iterator();
	while(it.hasNext()) {
		Map.Entry<String, Entity> pair = (Map.Entry<String, Entity>) it.next();
		pair.getValue().render(g, time);
	}
	
	/*
	// Draw the "shadow layer".
	g.clearAlphaMap();
	GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
	g.setDrawMode(Graphics.MODE_ALPHA_MAP);
	
	g.setColor(new Color(1.0f, 1.0f, 1.0f, 0.85f));
	g.fillRect(0.0f, 0.0f, Globals.WIDTH, Globals.HEIGHT);

	AssetManager.getManager().getImage("GZS_LightAlphaMap").drawCentered(Globals.player.getPosition().x, Globals.player.getPosition().y);
	
	GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
	g.setDrawMode(Graphics.MODE_ALPHA_BLEND);
	
	g.setColor(Color.black);
	g.fillRect(0.0f, 0.0f, Globals.WIDTH, Globals.HEIGHT);
	
	g.setDrawMode(Graphics.MODE_NORMAL);*/
	
	hud.render(g, player, time);
	
	if(paused) {
		g.setColor(Color.white);
		int w = GameState.FONT_PAUSE.getWidth("Paused");
		int h = GameState.FONT_PAUSE.getHeight();
		FontUtils.drawCenter(GameState.FONT_PAUSE, "Paused", 
							 ((Globals.WIDTH / 2) - (w / 2)), ((Globals.HEIGHT / 2) - (h / 2)), w);
	}
	
	if(consoleOpen) console.render(g, time);
}
 
開發者ID:packetpirate,項目名稱:Generic-Zombie-Shooter-Redux,代碼行數:50,代碼來源:GameState.java


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