Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- OUTPUT: http://i.imgur.com/jv5xR.png
- import org.lwjgl.opengl.GL11;
- import org.newdawn.slick.opengl.Texture;
- abstract class Block {
- private Texture texture;
- protected int x;
- protected int y;
- protected BlockType type;
- private static int blockWidth = 25;
- private static int blockHeight = 25;
- public void setTexture(Texture tex) {
- this.texture = tex;
- }
- public void draw() {
- texture.bind();
- int realX = x * blockWidth;
- int realY = y * blockHeight;
- int textureW = blockWidth;
- int textureH = blockHeight;
- GL11.glBegin(GL11.GL_QUADS);
- GL11.glTexCoord2f(0, 0);
- GL11.glVertex2f(realX, realY);
- GL11.glTexCoord2f(1, 0);
- GL11.glVertex2f(realX + textureW, realY);
- GL11.glTexCoord2f(1, 1);
- GL11.glVertex2f(realX + textureW, realY + textureH);
- GL11.glTexCoord2f(0, 1);
- GL11.glVertex2f(realX, realY + textureH);
- GL11.glEnd();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement