Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void render(GameContainer arg0, Graphics arg1) {
- arg1.setBackground(Color.black);
- if(reload) { arg1.clearAlphaMap(); reload = false; }
- if(lights.size() > 0) {
- for (int i=0; i< SeeinLights.size(); i++) {
- Light light = SeeinLights.get(i);
- //set up our alpha map for the light
- arg1.setDrawMode(Graphics.MODE_ALPHA_MAP);
- //clear the alpha map before we draw to it...
- //centre the light
- int alphaW = (int)(alphaMap.getWidth() * light.scale);
- int alphaH = (int)(alphaMap.getHeight() * light.scale);
- int alphaX = (int)((light.x - alphaW/2f) - xscroll);
- int alphaY = (int)(light.y - alphaH/2f);
- if(alphaX > -(arg0.getWidth() / 2)) {
- //we apply the light alpha here; RGB will be ignored
- sharedColor.a = light.alpha;
- //draw the alpha map
- alphaMap.draw(alphaX, alphaY, alphaW, alphaH, sharedColor);
- //start blending in our tiles
- arg1.setDrawMode(Graphics.MODE_ALPHA_BLEND);
- //we'll clip to the alpha rectangle, since anything outside of it will be transparent
- arg1.setClip(alphaX, alphaY, alphaW, alphaH);
- light.tint.bind();
- }
- Block.air.texture.draw(-50, -50, arg0.getWidth() + 100, arg0.getHeight() + 100);
- // Rendering the map
- if(!map.isEmpty()) {
- int min_x = (int) (xscroll / Constantes.BLOCK_W);
- int max_x = (int) ((xscroll + arg0.getWidth()) / Constantes.BLOCK_W) + 1;
- if(min_x < 0) min_x = 0;
- for(int x = min_x; x < max_x; ++x) {
- for(int y = 0; y < map.get(x).size(); ++y) {
- int POSITION_X = (x * Block.width) - (int)xscroll;
- int POSITION_Y = (int) ((y * Block.height) - yscroll);
- map.get(x).get(y).texture.draw(POSITION_X, POSITION_Y);
- }
- }
- }
- arg1.clearClip();
- }
- }
- arg1.setDrawMode(Graphics.MODE_NORMAL);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement