/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package test;
import java.awt.Canvas;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
/**
*
* @author cvleonardo
*/
public class Cubo extends Canvas {
protected BufferedImage sprite;
private int valC;
String col = "";
String colorCubo = "";
public String color = "";
private String[] imagen = {color};
private int altoCubo;
private int anchoCubo;
private int posX;
private int posY = 31;
public Cubo(int posX, int posY, String colorCubo) {
this.posX = posX;
this.posY = posY;
this.colorCubo = colorCubo;
imagen[0] = color;
int pos = 0;
cargaSprite(imagen[pos]);
anchoCubo = sprite.getHeight();
altoCubo = sprite.getWidth();
}
protected final void cargaSprite(String imagen) {
try {
java.net.URL url = getClass().getClassLoader().getResource("res/" + colorCubo);
sprite = ImageIO.read(url);
} catch (java.net.MalformedURLException e) {
e.printStackTrace();
} catch (java.io.IOException e) {
e.printStackTrace();
}
}
public void paintCubo(Graphics g) {
g.drawImage(sprite, posX, posY, this);
}
}
martes, 10 de febrero de 2009
Suscribirse a:
Enviar comentarios (Atom)
No hay comentarios:
Publicar un comentario