From b25ccd8bb385863365813b077e04b6e29007aa48 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Mon, 5 Sep 2016 04:54:11 -0400 Subject: [PATCH] v0.4.2: fog of war now adjusts with brightness again also adjsuted brightness to be on a scale of -2 to 2, instead of prior -2 to 4 --- .../shatteredpixeldungeon/FogOfWar.java | 31 +++++++++++++------ .../ShatteredPixelDungeon.java | 6 ++-- .../scenes/GameScene.java | 13 -------- .../windows/WndSettings.java | 2 +- 4 files changed, 25 insertions(+), 27 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/FogOfWar.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/FogOfWar.java index 4364979c9..a0c70b3e9 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/FogOfWar.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/FogOfWar.java @@ -36,10 +36,21 @@ import java.nio.IntBuffer; public class FogOfWar extends Image { - private static final int VISIBLE = 0x00000000; - private static final int VISITED = 0xcc000000; - private static final int MAPPED = 0xcc442211; - private static final int INVISIBLE = 0xFF000000; + private static final int VISIBLE[] = new int[]{0xAA000000, 0x55000000, //-2 and -1 brightness + 0x00000000, //0 brightness + 0x00000000, 0x00000000}; //1 and 2 brightness + + private static final int VISITED[] = new int[]{0xEE000000, 0xDD000000, + 0xCC000000, + 0x99000000, 0x66000000}; + + private static final int MAPPED[] = new int[]{0xEE442211, 0xDD442211, + 0xCC442211, + 0x99442211, 0x66442211}; + + private static final int INVISIBLE[]= new int[]{0xFF000000, 0xFF000000, + 0xFF000000, + 0xFF000000, 0xFF000000}; private int pWidth; private int pHeight; @@ -102,27 +113,29 @@ public class FogOfWar extends Image { FogTexture fog = (FogTexture)texture; + int brightness = ShatteredPixelDungeon.brightness() + 2; + for (int i=updating.top; i < updating.bottom; i++) { int cell = (pWidth - 1) * i + updating.left; fog.pixels.position((width2) * i + updating.left); for (int j=updating.left; j < updating.right; j++) { if (cell < pWidth || cell >= Dungeon.level.length() || j == 0 || j == pWidth-1) { - fog.pixels.put(INVISIBLE); + fog.pixels.put(INVISIBLE[brightness]); } else if (visible[cell] && visible[cell - (pWidth - 1)] && visible[cell - 1] && visible[cell - (pWidth - 1) - 1]) { - fog.pixels.put(VISIBLE); + fog.pixels.put(VISIBLE[brightness]); } else if (visited[cell] && visited[cell - (pWidth - 1)] && visited[cell - 1] && visited[cell - (pWidth - 1) - 1]) { - fog.pixels.put(VISITED); + fog.pixels.put(VISITED[brightness]); } else if (mapped[cell] && mapped[cell - (pWidth - 1)] && mapped[cell - 1] && mapped[cell - (pWidth - 1) - 1]) { - fog.pixels.put(MAPPED); + fog.pixels.put(MAPPED[brightness]); } else { - fog.pixels.put(INVISIBLE); + fog.pixels.put(INVISIBLE[brightness]); } cell++; } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ShatteredPixelDungeon.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ShatteredPixelDungeon.java index 4e2495aad..a998d825f 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ShatteredPixelDungeon.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ShatteredPixelDungeon.java @@ -387,13 +387,11 @@ public class ShatteredPixelDungeon extends Game { public static void brightness( int value ) { Preferences.INSTANCE.put( Preferences.KEY_BRIGHTNESS, value ); - if (scene() instanceof GameScene) { - ((GameScene)scene()).brightness( value ); - } + GameScene.updateFog(); } public static int brightness() { - return Preferences.INSTANCE.getInt( Preferences.KEY_BRIGHTNESS, 0, -2, 4 ); + return Preferences.INSTANCE.getInt( Preferences.KEY_BRIGHTNESS, 0, -2, 2 ); } public static void language(Languages lang) { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java index 644b709b9..76ac228ba 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java @@ -238,8 +238,6 @@ public class GameScene extends PixelScene { fog = new FogOfWar( Dungeon.level.width(), Dungeon.level.height() ); add( fog ); - brightness( ShatteredPixelDungeon.brightness() ); - spells = new Group(); add( spells ); @@ -512,17 +510,6 @@ public class GameScene extends PixelScene { selectItem( null, WndBag.Mode.ALL, null ); } } - - public void brightness( int value ) { - float shift; - if (value >= 0) - shift = value/2f; - else - shift = value/3f; - - fog.am = 1f + shift; - fog.aa = 0f - shift; - } public void addCustomTile( CustomTileVisual visual){ customTiles.add( visual.create() ); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndSettings.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndSettings.java index 05e52926d..7bd0f62d9 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndSettings.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndSettings.java @@ -135,7 +135,7 @@ public class WndSettings extends WndTabbed { } OptionSlider brightness = new OptionSlider(Messages.get(this, "brightness"), - Messages.get(this, "dark"), Messages.get(this, "bright"), -2, 4) { + Messages.get(this, "dark"), Messages.get(this, "bright"), -2, 2) { @Override protected void onChange() { ShatteredPixelDungeon.brightness(getSelectedValue());