All Downloads are FREE. Search and download functionalities are using the official Maven repository.

mmb.engine.texture.TextureDrawer Maven / Gradle / Ivy

Go to download

Dependency for the MultiMachineBuilder, a voxel game about building an industrial empire in a finite world. THIS RELEASE IS NOT PLAYABLE. To play the game, donwload from >ITCH.IO LINK HERE< or >GH releases link here<

The newest version!
/**
 * 
 */
package mmb.engine.texture;

import java.awt.Graphics;
import java.awt.image.BufferedImage;

import javax.swing.Icon;
import javax.swing.ImageIcon;

import mmb.NN;
import mmb.Nil;
import mmb.engine.block.BlockEntry;

/**
 * A basic textured block drawer
 * @author oskar
 */
public class TextureDrawer implements BlockDrawer {
	/** The image which is drawn */
	@NN public final BufferedImage img;
	/** The LOD color */
	private int LOD = -1;
	@NN private final Icon icon;
	/**
	 * Creates a texture drawer
	 * @param img2 the image to be drawn
	 */
	public TextureDrawer(BufferedImage img2) {
		this.img = img2;
		icon = new ImageIcon(img);
	}
	@Override
	public void draw(@Nil BlockEntry ent, int x, int y, Graphics g, int w, int h) {
		g.drawImage(img, x, y, w, h, null);
	}
	@Override
	public Icon toIcon() {
		return icon;
	}
	@Override
	public int LOD() {
		if(LOD < 0) 
			LOD = LODs.calcLOD(img);
		return LOD;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy