Guest User

Untitled

a guest
Jul 28th, 2012
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.80 KB | None | 0 0
  1. public class GrassBlock extends Block {
  2.    
  3.     public GrassBlock(int xx, int yy) {
  4.         x = xx;
  5.         y = yy;
  6.        
  7.         System.out.println("rendering grass at "+x+","+y);
  8.        
  9.         try {
  10.             blockTexture = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/grass.png"));
  11.         } catch (IOException ex) {
  12.         }
  13.     }
  14.    
  15. }
  16.  
  17. public class Block {
  18.    
  19.     protected int blockWidth = 30;
  20.     protected int blockHeight = 30;
  21.  
  22.     public int x = 0;
  23.     public int y = 0;
  24.    
  25.     public Texture blockTexture;
  26.    
  27.     public void draw() {
  28.         blockTexture.bind();
  29.        
  30.         GL11.glBegin(GL11.GL_QUADS);
  31.             GL11.glVertex2f(x, y);
  32.            
  33.             GL11.glVertex2f(x + blockWidth, y);
  34.            
  35.             GL11.glVertex2f(x + blockWidth, y + blockHeight);
  36.            
  37.             GL11.glVertex2f(x, y + blockHeight);
  38.            
  39.             GL11.glVertex2f(x, y);
  40.         GL11.glEnd();
  41.     }
  42.    
  43. }
Advertisement
Add Comment
Please, Sign In to add comment