Advertisement
Guest User

Slick Java Poneymove Cuboid

a guest
Feb 17th, 2013
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.87 KB | None | 0 0
  1.     public static void render(GameContainer arg0, Graphics arg1) {
  2.         arg1.setBackground(Color.black);
  3.        
  4.         if(reload) { arg1.clearAlphaMap(); reload = false; }
  5.        
  6.        
  7.         if(lights.size() > 0) {
  8.             for (int i=0; i< SeeinLights.size(); i++) {
  9.                 Light light = SeeinLights.get(i);
  10.                
  11.                 //set up our alpha map for the light
  12.                 arg1.setDrawMode(Graphics.MODE_ALPHA_MAP);
  13.                 //clear the alpha map before we draw to it...
  14.                
  15.                
  16.                 //centre the light
  17.                 int alphaW = (int)(alphaMap.getWidth() * light.scale);
  18.                 int alphaH = (int)(alphaMap.getHeight() * light.scale);
  19.                 int alphaX = (int)((light.x - alphaW/2f) - xscroll);
  20.                 int alphaY = (int)(light.y - alphaH/2f);
  21.                
  22.                 if(alphaX > -(arg0.getWidth() / 2)) {
  23.                
  24.                 //we apply the light alpha here; RGB will be ignored
  25.                 sharedColor.a = light.alpha;
  26.      
  27.                 //draw the alpha map
  28.                 alphaMap.draw(alphaX, alphaY, alphaW, alphaH, sharedColor);
  29.                 //start blending in our tiles
  30.                 arg1.setDrawMode(Graphics.MODE_ALPHA_BLEND);
  31.      
  32.                 //we'll clip to the alpha rectangle, since anything outside of it will be transparent
  33.                 arg1.setClip(alphaX, alphaY, alphaW, alphaH);
  34.                
  35.                 light.tint.bind();
  36.                 }
  37.  
  38.                 Block.air.texture.draw(-50, -50, arg0.getWidth() + 100, arg0.getHeight() + 100);
  39.                
  40.                 // Rendering the map
  41.                 if(!map.isEmpty()) {
  42.                     int min_x = (int) (xscroll / Constantes.BLOCK_W);
  43.                     int max_x = (int) ((xscroll + arg0.getWidth()) / Constantes.BLOCK_W) + 1;
  44.                    
  45.                     if(min_x < 0) min_x = 0;
  46.                    
  47.                     for(int x = min_x; x < max_x; ++x) {
  48.                         for(int y = 0; y < map.get(x).size(); ++y) {
  49.                             int POSITION_X = (x * Block.width) - (int)xscroll;
  50.                             int POSITION_Y = (int) ((y * Block.height) - yscroll);
  51.        
  52.                             map.get(x).get(y).texture.draw(POSITION_X, POSITION_Y);
  53.                         }
  54.                     }
  55.                 }
  56.             arg1.clearClip();
  57.             }
  58.         }
  59.        
  60.     arg1.setDrawMode(Graphics.MODE_NORMAL);
  61.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement