From 2fb508c83565f676c4a09e195803d3b5c75d37a7 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Sun, 4 Oct 2015 05:17:01 -0400 Subject: [PATCH] v0.3.2: significantly refactored custom tile visuals --- .../shatteredpixeldungeon/levels/Level.java | 2 +- .../levels/painters/WeakFloorPainter.java | 16 ++++++- .../scenes/GameScene.java | 2 +- .../{sprites => ui}/CustomTileVisual.java | 45 +++---------------- 4 files changed, 22 insertions(+), 43 deletions(-) rename src/com/shatteredpixel/shatteredpixeldungeon/{sprites => ui}/CustomTileVisual.java (65%) diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java b/src/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java index 02650fd1d..43d5b7d62 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java @@ -71,7 +71,7 @@ import com.shatteredpixel.shatteredpixeldungeon.mechanics.ShadowCaster; import com.shatteredpixel.shatteredpixeldungeon.plants.BlandfruitBush; import com.shatteredpixel.shatteredpixeldungeon.plants.Plant; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; -import com.shatteredpixel.shatteredpixeldungeon.sprites.CustomTileVisual; +import com.shatteredpixel.shatteredpixeldungeon.ui.CustomTileVisual; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; import com.watabou.noosa.Game; diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/levels/painters/WeakFloorPainter.java b/src/com/shatteredpixel/shatteredpixeldungeon/levels/painters/WeakFloorPainter.java index f31652b8b..c37c53b44 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/levels/painters/WeakFloorPainter.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/levels/painters/WeakFloorPainter.java @@ -25,7 +25,7 @@ import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.levels.Level; import com.shatteredpixel.shatteredpixeldungeon.levels.Room; import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; -import com.shatteredpixel.shatteredpixeldungeon.sprites.CustomTileVisual; +import com.shatteredpixel.shatteredpixeldungeon.ui.CustomTileVisual; import com.watabou.utils.Point; import com.watabou.utils.Random; @@ -68,8 +68,20 @@ public class WeakFloorPainter extends Painter { well = new Point( Random.Int( 2 ) == 0 ? room.left + 1 : room.right - 1, room.top+2 ); } set(level, well, Terrain.CHASM); - CustomTileVisual vis = new CustomTileVisual(Assets.WEAK_FLOOR, Dungeon.depth/5, 0, 1, 1); + CustomTileVisual vis = new HiddenWell(); vis.pos(well.x, well.y); level.customTiles.add(vis); } + + public static class HiddenWell extends CustomTileVisual{ + + { + tx = Assets.WEAK_FLOOR; + txX = Dungeon.depth/5; + txY = 0; + + tileW = tileH = 1; + } + + } } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java b/src/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java index b95fb304c..a797b4e95 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java @@ -32,7 +32,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.bags.WandHolster; import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTeleportation; import com.shatteredpixel.shatteredpixeldungeon.levels.traps.Trap; -import com.shatteredpixel.shatteredpixeldungeon.sprites.CustomTileVisual; +import com.shatteredpixel.shatteredpixeldungeon.ui.CustomTileVisual; import com.shatteredpixel.shatteredpixeldungeon.sprites.TrapSprite; import com.shatteredpixel.shatteredpixeldungeon.ui.LootIndicator; import com.shatteredpixel.shatteredpixeldungeon.ui.ResumeIndicator; diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/sprites/CustomTileVisual.java b/src/com/shatteredpixel/shatteredpixeldungeon/ui/CustomTileVisual.java similarity index 65% rename from src/com/shatteredpixel/shatteredpixeldungeon/sprites/CustomTileVisual.java rename to src/com/shatteredpixel/shatteredpixeldungeon/ui/CustomTileVisual.java index ee21e8444..906e28ff8 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/sprites/CustomTileVisual.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/ui/CustomTileVisual.java @@ -18,7 +18,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see */ -package com.shatteredpixel.shatteredpixeldungeon.sprites; +package com.shatteredpixel.shatteredpixeldungeon.ui; import com.shatteredpixel.shatteredpixeldungeon.levels.Level; import com.watabou.noosa.Image; @@ -27,27 +27,13 @@ import com.watabou.utils.Bundle; public class CustomTileVisual extends Image implements Bundlable { - private static final int TILE_SIZE = 16; + protected static final int TILE_SIZE = 16; - private String tx; - private int txX, txY; + protected String tx; //string for resource file + protected int txX, txY; //position(in tiles) within resource file - private int tileX, tileY, tileW, tileH; - - public CustomTileVisual(){ - super(); - } - - public CustomTileVisual(String tx, int txX, int txY, int tileW, int tileH){ - super(); - - this.tx = tx; - this.txX = txX; - this.txY = txY; - - this.tileW = tileW; - this.tileH = tileH; - } + protected int tileX, tileY; //x and y coords for texture within a level + protected int tileW, tileH; //width and height in tiles public void pos(int pos) { pos( pos%Level.WIDTH, pos/Level.WIDTH ); @@ -68,37 +54,18 @@ public class CustomTileVisual extends Image implements Bundlable { return this; } - private static final String TX = "tx"; - private static final String TX_X= "txX"; - private static final String TX_Y= "txY"; - private static final String TILE_X = "tileX"; private static final String TILE_Y = "tileY"; - private static final String TILE_W = "tileW"; - private static final String TILE_H = "tileH"; - @Override public void restoreFromBundle(Bundle bundle) { - tx = bundle.getString(TX); - txX = bundle.getInt(TX_X); - txY = bundle.getInt(TX_Y); - tileX = bundle.getInt(TILE_X); tileY = bundle.getInt(TILE_Y); - tileW = bundle.getInt(TILE_W); - tileH = bundle.getInt(TILE_H); } @Override public void storeInBundle(Bundle bundle) { - bundle.put(TX, tx); - bundle.put(TX_X, txX); - bundle.put(TX_Y, txY); - bundle.put(TILE_X, tileX); bundle.put(TILE_Y, tileY); - bundle.put(TILE_W, tileW); - bundle.put(TILE_H, tileH); } }