⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gfx.java

📁 how to make a game using java.
💻 JAVA
字号:
// GAMELIB - Gfx
// (C)2002 [Imperial Snowman Soft]

package GameLib;

import java.awt.*;
import java.applet.*;

public class Gfx
{
	protected Component	comp;
	protected Image		offImage, offBGImage;
	protected Graphics	offG;

	public Gfx(Component component, Color color)
	{
		comp = component;
		offImage = comp.createImage(comp.size().width,
			comp.size().height);
		
		offBGImage = comp.createImage(comp.size().width, 
			comp.size().height);
		
		Graphics bgG = offBGImage.getGraphics();
		bgG.setColor(color);
		bgG.fillRect(0, 0, comp.size().width, comp.size().height);
		
		offG = offImage.getGraphics();
	}

	public Gfx(Component component, Image backImg)
	{
		comp = component;
		offImage = comp.createImage(comp.size().width,
			comp.size().height);
		offBGImage = backImg;

		offG = offImage.getGraphics();
	}


	public void setBGImage(Image backImg)
	{
		offBGImage = backImg;
	}

	public Image getBGImage()
	{
		return (offBGImage);
	}

	public void drawImage(Image img, int x, int y)
	{
		offG.drawImage(img, x, y, comp);
	}

	public void cls(Color color)
	{
		offG.setColor(color);
		offG.fillRect(0, 0, comp.size().width, comp.size().height);
	}

	public void cls()
	{
		offG.drawImage(offBGImage, 0, 0, comp);
	}


	public void refresh()
	{
		comp.getGraphics().drawImage(offImage, 0, 0, comp);
	}

	public Image getOffImage()
	{
		return (offImage);
	}	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -