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
This commit is contained in:
parent
6afff9f71b
commit
b25ccd8bb3
|
@ -36,10 +36,21 @@ import java.nio.IntBuffer;
|
||||||
|
|
||||||
public class FogOfWar extends Image {
|
public class FogOfWar extends Image {
|
||||||
|
|
||||||
private static final int VISIBLE = 0x00000000;
|
private static final int VISIBLE[] = new int[]{0xAA000000, 0x55000000, //-2 and -1 brightness
|
||||||
private static final int VISITED = 0xcc000000;
|
0x00000000, //0 brightness
|
||||||
private static final int MAPPED = 0xcc442211;
|
0x00000000, 0x00000000}; //1 and 2 brightness
|
||||||
private static final int INVISIBLE = 0xFF000000;
|
|
||||||
|
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 pWidth;
|
||||||
private int pHeight;
|
private int pHeight;
|
||||||
|
@ -102,27 +113,29 @@ public class FogOfWar extends Image {
|
||||||
|
|
||||||
FogTexture fog = (FogTexture)texture;
|
FogTexture fog = (FogTexture)texture;
|
||||||
|
|
||||||
|
int brightness = ShatteredPixelDungeon.brightness() + 2;
|
||||||
|
|
||||||
for (int i=updating.top; i < updating.bottom; i++) {
|
for (int i=updating.top; i < updating.bottom; i++) {
|
||||||
int cell = (pWidth - 1) * i + updating.left;
|
int cell = (pWidth - 1) * i + updating.left;
|
||||||
fog.pixels.position((width2) * i + updating.left);
|
fog.pixels.position((width2) * i + updating.left);
|
||||||
for (int j=updating.left; j < updating.right; j++) {
|
for (int j=updating.left; j < updating.right; j++) {
|
||||||
if (cell < pWidth || cell >= Dungeon.level.length() || j == 0 || j == pWidth-1) {
|
if (cell < pWidth || cell >= Dungeon.level.length() || j == 0 || j == pWidth-1) {
|
||||||
fog.pixels.put(INVISIBLE);
|
fog.pixels.put(INVISIBLE[brightness]);
|
||||||
} else
|
} else
|
||||||
if (visible[cell] && visible[cell - (pWidth - 1)] &&
|
if (visible[cell] && visible[cell - (pWidth - 1)] &&
|
||||||
visible[cell - 1] && visible[cell - (pWidth - 1) - 1]) {
|
visible[cell - 1] && visible[cell - (pWidth - 1) - 1]) {
|
||||||
fog.pixels.put(VISIBLE);
|
fog.pixels.put(VISIBLE[brightness]);
|
||||||
} else
|
} else
|
||||||
if (visited[cell] && visited[cell - (pWidth - 1)] &&
|
if (visited[cell] && visited[cell - (pWidth - 1)] &&
|
||||||
visited[cell - 1] && visited[cell - (pWidth - 1) - 1]) {
|
visited[cell - 1] && visited[cell - (pWidth - 1) - 1]) {
|
||||||
fog.pixels.put(VISITED);
|
fog.pixels.put(VISITED[brightness]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (mapped[cell] && mapped[cell - (pWidth - 1)] &&
|
if (mapped[cell] && mapped[cell - (pWidth - 1)] &&
|
||||||
mapped[cell - 1] && mapped[cell - (pWidth - 1) - 1]) {
|
mapped[cell - 1] && mapped[cell - (pWidth - 1) - 1]) {
|
||||||
fog.pixels.put(MAPPED);
|
fog.pixels.put(MAPPED[brightness]);
|
||||||
} else {
|
} else {
|
||||||
fog.pixels.put(INVISIBLE);
|
fog.pixels.put(INVISIBLE[brightness]);
|
||||||
}
|
}
|
||||||
cell++;
|
cell++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -387,13 +387,11 @@ public class ShatteredPixelDungeon extends Game {
|
||||||
|
|
||||||
public static void brightness( int value ) {
|
public static void brightness( int value ) {
|
||||||
Preferences.INSTANCE.put( Preferences.KEY_BRIGHTNESS, value );
|
Preferences.INSTANCE.put( Preferences.KEY_BRIGHTNESS, value );
|
||||||
if (scene() instanceof GameScene) {
|
GameScene.updateFog();
|
||||||
((GameScene)scene()).brightness( value );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int brightness() {
|
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) {
|
public static void language(Languages lang) {
|
||||||
|
|
|
@ -238,8 +238,6 @@ public class GameScene extends PixelScene {
|
||||||
fog = new FogOfWar( Dungeon.level.width(), Dungeon.level.height() );
|
fog = new FogOfWar( Dungeon.level.width(), Dungeon.level.height() );
|
||||||
add( fog );
|
add( fog );
|
||||||
|
|
||||||
brightness( ShatteredPixelDungeon.brightness() );
|
|
||||||
|
|
||||||
spells = new Group();
|
spells = new Group();
|
||||||
add( spells );
|
add( spells );
|
||||||
|
|
||||||
|
@ -512,17 +510,6 @@ public class GameScene extends PixelScene {
|
||||||
selectItem( null, WndBag.Mode.ALL, null );
|
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){
|
public void addCustomTile( CustomTileVisual visual){
|
||||||
customTiles.add( visual.create() );
|
customTiles.add( visual.create() );
|
||||||
|
|
|
@ -135,7 +135,7 @@ public class WndSettings extends WndTabbed {
|
||||||
}
|
}
|
||||||
|
|
||||||
OptionSlider brightness = new OptionSlider(Messages.get(this, "brightness"),
|
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
|
@Override
|
||||||
protected void onChange() {
|
protected void onChange() {
|
||||||
ShatteredPixelDungeon.brightness(getSelectedValue());
|
ShatteredPixelDungeon.brightness(getSelectedValue());
|
||||||
|
|
Loading…
Reference in New Issue
Block a user