v0.8.1: fog of war is no longer a power of 2 texture

This commit is contained in:
Evan Debenham 2020-05-18 21:06:38 -04:00
parent e49eb27a12
commit a1cdafe76c

View File

@ -109,20 +109,18 @@ public class FogOfWar extends Image {
} }
float size = DungeonTilemap.SIZE / PIX_PER_TILE; float size = DungeonTilemap.SIZE / PIX_PER_TILE;
width = width2 * size; width = pWidth * size;
height = height2 * size; height = pHeight * size;
//TODO might be nice to compartmentalize the pixmap access and modification into texture/texturecache //TODO might be nice to compartmentalize the pixmap access and modification into texture/texturecache
Pixmap px = new Pixmap(width2, height2, Pixmap.Format.RGBA8888); Pixmap px = new Pixmap(pWidth, pHeight, Pixmap.Format.RGBA8888);
px.setBlending(Pixmap.Blending.None); px.setBlending(Pixmap.Blending.None);
px.fill(); px.fill();
SmartTexture tx = new SmartTexture(px, Texture.LINEAR, Texture.CLAMP, false); SmartTexture tx = new SmartTexture(px, Texture.LINEAR, Texture.CLAMP, false);
TextureCache.add(FogOfWar.class, tx); TextureCache.add(FogOfWar.class, tx);
texture( tx ); texture( tx );
scale.set( scale.set( size, size );
DungeonTilemap.SIZE / PIX_PER_TILE,
DungeonTilemap.SIZE / PIX_PER_TILE);
toUpdate = new ArrayList<>(); toUpdate = new ArrayList<>();
toUpdate.add(new Rect(0, 0, mapWidth, mapHeight)); toUpdate.add(new Rect(0, 0, mapWidth, mapHeight));
@ -193,9 +191,9 @@ public class FogOfWar extends Image {
int cell; int cell;
for (Rect update : updating) { for (Rect update : updating) {
for (int i = update.top; i <= update.bottom; i++) { for (int i = update.top; i < update.bottom; i++) {
cell = mapWidth * i + update.left; cell = mapWidth * i + update.left;
for (int j = update.left; j <= update.right; j++) { for (int j = update.left; j < update.right; j++) {
if (cell >= Dungeon.level.length()) continue; //do nothing if (cell >= Dungeon.level.length()) continue; //do nothing