v0.8.1: refactored fog of war to use LibGDX pixmaps
This commit is contained in:
@@ -21,10 +21,12 @@
|
||||
|
||||
package com.shatteredpixel.shatteredpixeldungeon.tiles;
|
||||
|
||||
import com.badlogic.gdx.graphics.Pixmap;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.SPDSettings;
|
||||
import com.watabou.gltextures.BufferTexture;
|
||||
import com.watabou.gltextures.SmartTexture;
|
||||
import com.watabou.gltextures.TextureCache;
|
||||
import com.watabou.glwrap.Texture;
|
||||
import com.watabou.noosa.Image;
|
||||
import com.watabou.noosa.NoosaScript;
|
||||
import com.watabou.noosa.NoosaScriptNoLighting;
|
||||
@@ -109,8 +111,12 @@ public class FogOfWar extends Image {
|
||||
float size = DungeonTilemap.SIZE / PIX_PER_TILE;
|
||||
width = width2 * size;
|
||||
height = height2 * size;
|
||||
|
||||
BufferTexture tx = new BufferTexture(width2, height2);
|
||||
|
||||
//TODO might be nice to compartmentalize the pixmap access and modification into texture/texturecache
|
||||
Pixmap px = new Pixmap(width2, height2, Pixmap.Format.RGBA8888);
|
||||
px.setBlending(Pixmap.Blending.None);
|
||||
px.fill();
|
||||
SmartTexture tx = new SmartTexture(px, Texture.LINEAR, Texture.CLAMP, false);
|
||||
TextureCache.add(FogOfWar.class, tx);
|
||||
texture( tx );
|
||||
|
||||
@@ -182,7 +188,7 @@ public class FogOfWar extends Image {
|
||||
}
|
||||
}
|
||||
|
||||
BufferTexture fog = (BufferTexture) texture;
|
||||
Pixmap fog = texture.bitmap;
|
||||
|
||||
int cell;
|
||||
|
||||
@@ -273,11 +279,7 @@ public class FogOfWar extends Image {
|
||||
|
||||
}
|
||||
|
||||
if (updating.size() == 1 && !fullUpdate){
|
||||
fog.update(updating.get(0).top * PIX_PER_TILE, updating.get(0).bottom * PIX_PER_TILE);
|
||||
} else {
|
||||
fog.update();
|
||||
}
|
||||
texture.bitmap(fog);
|
||||
|
||||
}
|
||||
|
||||
@@ -298,31 +300,19 @@ public class FogOfWar extends Image {
|
||||
}
|
||||
}
|
||||
|
||||
private void fillLeft( BufferTexture fog, int x, int y, int color){
|
||||
for (int i = 0; i < PIX_PER_TILE; i++){
|
||||
fog.pixels.position(((y * PIX_PER_TILE)+i)*width2 + x * PIX_PER_TILE);
|
||||
for (int j = 0; j < PIX_PER_TILE/2; j++) {
|
||||
fog.pixels.put(color);
|
||||
}
|
||||
}
|
||||
private void fillLeft( Pixmap fog, int x, int y, int color){
|
||||
fog.setColor((color << 8) | (color >>> 24));
|
||||
fog.fillRectangle(x * PIX_PER_TILE, y*PIX_PER_TILE, PIX_PER_TILE/2, PIX_PER_TILE);
|
||||
}
|
||||
|
||||
private void fillRight( BufferTexture fog, int x, int y, int color){
|
||||
for (int i = 0; i < PIX_PER_TILE; i++){
|
||||
fog.pixels.position(((y * PIX_PER_TILE)+i)*width2 + x * PIX_PER_TILE + PIX_PER_TILE/2);
|
||||
for (int j = PIX_PER_TILE/2; j < PIX_PER_TILE; j++) {
|
||||
fog.pixels.put(color);
|
||||
}
|
||||
}
|
||||
private void fillRight( Pixmap fog, int x, int y, int color){
|
||||
fog.setColor((color << 8) | (color >>> 24));
|
||||
fog.fillRectangle(x * PIX_PER_TILE + PIX_PER_TILE/2, y*PIX_PER_TILE, PIX_PER_TILE/2, PIX_PER_TILE);
|
||||
}
|
||||
|
||||
private void fillCell( BufferTexture fog, int x, int y, int color){
|
||||
for (int i = 0; i < PIX_PER_TILE; i++){
|
||||
fog.pixels.position(((y * PIX_PER_TILE)+i)*width2 + x * PIX_PER_TILE);
|
||||
for (int j = 0; j < PIX_PER_TILE; j++) {
|
||||
fog.pixels.put(color);
|
||||
}
|
||||
}
|
||||
private void fillCell( Pixmap fog, int x, int y, int color){
|
||||
fog.setColor((color << 8) | (color >>> 24));
|
||||
fog.fillRectangle(x * PIX_PER_TILE, y*PIX_PER_TILE, PIX_PER_TILE, PIX_PER_TILE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user