fixed buggy controls

v5stable
Ondřej Hruška 10 years ago
parent ecbb2c8615
commit 78035ced7a
  1. 4
      src/mightypork/gamecore/render/Render.java
  2. 3
      src/mightypork/gamecore/resources/fonts/Glyphs.java
  3. 2
      src/mightypork/gamecore/resources/fonts/impl/CachedFont.java
  4. 2
      src/mightypork/rogue/Res.java
  5. 7
      src/mightypork/rogue/screens/menu/MenuLayer.java
  6. 6
      src/mightypork/rogue/world/PlayerControl.java
  7. 6
      src/mightypork/rogue/world/entity/modules/EntityModulePosition.java
  8. 1
      src/mightypork/rogue/world/gen/LevelGenerator.java
  9. 4
      src/mightypork/rogue/world/gen/MapTheme.java
  10. 4
      src/mightypork/rogue/world/gen/ScratchMap.java
  11. 18
      src/mightypork/rogue/world/gen/rooms/AbstractRectRoom.java
  12. 12
      src/mightypork/rogue/world/gui/MapView.java
  13. 2
      src/mightypork/rogue/world/gui/Minimap.java
  14. 22
      src/mightypork/rogue/world/gui/interaction/MIPClickPathfWalk.java
  15. 28
      src/mightypork/rogue/world/gui/interaction/MIPKeyWalk.java
  16. 35
      src/mightypork/rogue/world/gui/interaction/MIPMouseWalk.java
  17. 7
      src/mightypork/rogue/world/gui/interaction/MIPTileClick.java
  18. 6
      src/mightypork/rogue/world/gui/interaction/MapInteractionPlugin.java
  19. 1
      src/mightypork/rogue/world/tile/TileGenData.java
  20. 3
      src/mightypork/rogue/world/tile/Tiles.java
  21. 1
      src/mightypork/rogue/world/tile/renderers/LockedDoorRenderer.java
  22. 29
      src/mightypork/rogue/world/tile/tiles/SecretDoorTile.java

@ -455,9 +455,9 @@ public class Render {
final RectDigest q = quad.digest(); final RectDigest q = quad.digest();
final RectDigest u = txquad.uvs.digest(); final RectDigest u = txquad.uvs.digest();
final double offs = 0.0001;// hack to avoid white stitching double offs = 0.0001;// hack to avoid white stitching
double tL = u.left + offs, tR = u.right - offs, tT = u.top + offs, tB = u.bottom - offs; double tL = u.left+offs, tR = u.right-offs, tT = u.top+offs, tB = u.bottom-offs;
// handle flip // handle flip
if (txquad.isFlippedY()) { if (txquad.isFlippedY()) {

@ -8,7 +8,6 @@ package mightypork.gamecore.resources.fonts;
*/ */
public class Glyphs { public class Glyphs {
public static final String space = " ";
public static final String latin = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; public static final String latin = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
public static final String latin_extra = "ŒÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜŸÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿĚŠČŘŽŤŇĎŮěščřžťňďůŁłđ"; public static final String latin_extra = "ŒÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜŸÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿĚŠČŘŽŤŇĎŮěščřžťňďůŁłđ";
public static final String numbers = "0123456789"; public static final String numbers = "0123456789";
@ -17,7 +16,7 @@ public class Glyphs {
public static final String symbols = "[]{}#$%&§*+/<=>@\\^_|~°"; public static final String symbols = "[]{}#$%&§*+/<=>@\\^_|~°";
public static final String symbols_extra = "¥€£¢`ƒ†‡ˆ‰•¤¦¨ªº¹²³¬­¯±´µ¶·¸¼½¾×÷™©­®→↓←↑"; public static final String symbols_extra = "¥€£¢`ƒ†‡ˆ‰•¤¦¨ªº¹²³¬­¯±´µ¶·¸¼½¾×÷™©­®→↓←↑";
public static final String basic = space + latin + numbers + punctuation + symbols; public static final String basic = latin + numbers + punctuation + symbols;
public static final String extra = latin_extra + punctuation_extra + symbols_extra; public static final String extra = latin_extra + punctuation_extra + symbols_extra;
public static final String all = basic + extra; public static final String all = basic + extra;

@ -88,7 +88,7 @@ public class CachedFont implements GLFont {
*/ */
public CachedFont(java.awt.Font font, boolean antialias, FilterMode filter, String chars) public CachedFont(java.awt.Font font, boolean antialias, FilterMode filter, String chars)
{ {
this(font, antialias, filter, chars.toCharArray()); this(font, antialias, filter, (" "+chars).toCharArray());
} }

@ -49,7 +49,7 @@ public final class Res {
private static void loadFonts() private static void loadFonts()
{ {
fonts.loadFont("polygon_pixel", new DeferredFont("/res/font/PolygonPixel5x7Standard.ttf", Glyphs.basic, 16)); fonts.loadFont("polygon_pixel", new DeferredFont("/res/font/PolygonPixel5x7Standard.ttf", Glyphs.basic, 16));
fonts.loadFont("press_start", new DeferredFont("/res/font/PressStart2P.ttf", Glyphs.basic, 16)); fonts.loadFont("press_start", new DeferredFont("/res/font/PressStart2P.ttf", Glyphs.latin, 16));
// aliases based on concrete usage // aliases based on concrete usage
fonts.addAlias("default", "polygon_pixel"); fonts.addAlias("default", "polygon_pixel");

@ -11,8 +11,10 @@ import mightypork.gamecore.gui.screens.Screen;
import mightypork.gamecore.gui.screens.ScreenLayer; import mightypork.gamecore.gui.screens.ScreenLayer;
import mightypork.gamecore.util.math.color.pal.COMMODORE; import mightypork.gamecore.util.math.color.pal.COMMODORE;
import mightypork.gamecore.util.math.color.pal.PAL16; import mightypork.gamecore.util.math.color.pal.PAL16;
import mightypork.gamecore.util.math.color.pal.RGB;
import mightypork.gamecore.util.math.constraints.num.Num; import mightypork.gamecore.util.math.constraints.num.Num;
import mightypork.gamecore.util.math.constraints.rect.Rect; import mightypork.gamecore.util.math.constraints.rect.Rect;
import mightypork.gamecore.util.math.constraints.vect.Vect;
import mightypork.rogue.Res; import mightypork.rogue.Res;
@ -40,7 +42,8 @@ class MenuLayer extends ScreenLayer {
root.add(layout); root.add(layout);
int r = 0; int r = 0;
final TextPainter tp = new TextPainter(Res.getFont("main_menu_title"), AlignX.CENTER, COMMODORE.PURPLE, "Rogue!"); final TextPainter tp = new TextPainter(Res.getFont("main_menu_title"), AlignX.CENTER, COMMODORE.PURPLE, "Rats");
tp.setShadow(RGB.BLACK.withAlpha(0.6), Vect.make(tp.height().div(16)));
layout.put(tp, r, 0, 3, 1); layout.put(tp, r, 0, 3, 1);
r += 5; r += 5;
@ -62,7 +65,7 @@ class MenuLayer extends ScreenLayer {
// bouncy text button // bouncy text button
btn = new MenuButton("Bouncy Cubes Test", PAL16.CLOUDBLUE); btn = new MenuButton("Bouncy", PAL16.CLOUDBLUE);
btn.setAction(new Action() { btn.setAction(new Action() {
@Override @Override

@ -38,7 +38,7 @@ public abstract class PlayerControl {
}; };
private Entity getPlayerEntity() public Entity getPlayerEntity()
{ {
if (getWorld2() == null) return null; if (getWorld2() == null) return null;
@ -103,16 +103,14 @@ public abstract class PlayerControl {
return getLevel().getTile(getCoord().add(side)).isWalkable(); return getLevel().getTile(getCoord().add(side)).isWalkable();
} }
public boolean clickTile(Step side) public boolean clickTile(Step side)
{ {
return clickTile(getCoord().add(side)); return clickTile(getCoord().add(side));
} }
public boolean clickTile(Coord pos) public boolean clickTile(Coord pos)
{ {
if (pos.dist(getCoord()) > 8) return false; // too far if(pos.dist(getCoord()) > 8) return false; // too far
return getLevel().getTile(pos).onClick(); return getLevel().getTile(pos).onClick();
} }

@ -204,5 +204,11 @@ public class EntityModulePosition extends EntityModule {
{ {
return entityPos.getVisualPos(); return entityPos.getVisualPos();
} }
public boolean isMoving()
{
return walking;
}
} }

@ -4,6 +4,7 @@ package mightypork.rogue.world.gen;
import java.util.Random; import java.util.Random;
import mightypork.gamecore.util.math.algo.Coord; import mightypork.gamecore.util.math.algo.Coord;
import mightypork.rogue.world.gen.rooms.DeadEndRoom;
import mightypork.rogue.world.gen.rooms.Rooms; import mightypork.rogue.world.gen.rooms.Rooms;
import mightypork.rogue.world.gen.themes.ThemeBrick; import mightypork.rogue.world.gen.themes.ThemeBrick;
import mightypork.rogue.world.level.Level; import mightypork.rogue.world.level.Level;

@ -21,7 +21,7 @@ public interface MapTheme {
TileModel passage(); TileModel passage();
TileModel secretDoor(); TileModel secretDoor();
} }

@ -42,8 +42,8 @@ public class ScratchMap {
@Override @Override
public boolean isAccessible(Coord pos) public boolean isAccessible(Coord pos)
{ {
if (!isIn(pos)) return false; if(!isIn(pos)) return false;
final Tile t = get(pos); Tile t = get(pos);
return t.isPotentiallyWalkable() || (t.genData.protection != TileProtectLevel.STRONG); return t.isPotentiallyWalkable() || (t.genData.protection != TileProtectLevel.STRONG);
} }

@ -21,15 +21,15 @@ public abstract class AbstractRectRoom implements RoomBuilder {
{ {
// half width, half height actually // half width, half height actually
final Coord innerSize = getInnerSize(rand); final Coord innerSize = getInnerSize(rand);
final int width = 2 + innerSize.x; final int width = 2+innerSize.x;
final int height = 2 + innerSize.y; final int height = 2+innerSize.y;
final int wLow = width / 2; int wLow = width/2;
final int wHigh = width - wLow; int wHigh = width - wLow;
final int hLow = height / 2; int hLow = height/2;
final int hHigh = height - hLow; int hHigh = height - hLow;
final Coord min = new Coord(center.x - wLow, center.y - hLow); final Coord min = new Coord(center.x-wLow, center.y-hLow);
final Coord max = new Coord(center.x + wHigh, center.y + hHigh); final Coord max = new Coord(center.x + wHigh, center.y + hHigh);
if (!map.isClear(min.add(-1, -1), max)) return null; if (!map.isClear(min.add(-1, -1), max)) return null;
@ -48,8 +48,8 @@ public abstract class AbstractRectRoom implements RoomBuilder {
protected void placeDoors(ScratchMap map, MapTheme theme, Random rand, Coord min, Coord max) protected void placeDoors(ScratchMap map, MapTheme theme, Random rand, Coord min, Coord max)
{ {
final int width = max.x - min.x; int width = max.x - min.x;
final int height = max.y - min.y; int height = max.y - min.y;
for (int i = 0, j = 0; i <= getDoorCount(rand) && j < 100; j++) { // j is to prevent inf loop for (int i = 0, j = 0; i <= getDoorCount(rand) && j < 100; j++) { // j is to prevent inf loop
final Coord door = min.copy(); final Coord door = min.copy();

@ -1,6 +1,7 @@
package mightypork.rogue.world.gui; package mightypork.rogue.world.gui;
import java.util.HashSet;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.Set; import java.util.Set;
@ -21,6 +22,7 @@ import mightypork.rogue.world.WorldProvider;
import mightypork.rogue.world.WorldRenderer; import mightypork.rogue.world.WorldRenderer;
import mightypork.rogue.world.entity.modules.EntityMoveListener; import mightypork.rogue.world.entity.modules.EntityMoveListener;
import mightypork.rogue.world.gui.interaction.MapInteractionPlugin; import mightypork.rogue.world.gui.interaction.MapInteractionPlugin;
import mightypork.rogue.world.tile.Tile;
/** /**
@ -71,7 +73,7 @@ public class MapView extends InputComponent implements KeyListener, MouseButtonL
public void onStepFinished() public void onStepFinished()
{ {
for (final MapInteractionPlugin p : plugins) { for (final MapInteractionPlugin p : plugins) {
if (p.onStepEnd(this, pc)) break; if(p.onStepEnd(this, pc)) break;
} }
} }
@ -80,7 +82,7 @@ public class MapView extends InputComponent implements KeyListener, MouseButtonL
public void onPathFinished() public void onPathFinished()
{ {
for (final MapInteractionPlugin p : plugins) { for (final MapInteractionPlugin p : plugins) {
if (p.onStepEnd(this, pc)) break; if(p.onStepEnd(this, pc)) break;
} }
} }
@ -89,7 +91,7 @@ public class MapView extends InputComponent implements KeyListener, MouseButtonL
public void onPathInterrupted() public void onPathInterrupted()
{ {
for (final MapInteractionPlugin p : plugins) { for (final MapInteractionPlugin p : plugins) {
if (p.onStepEnd(this, pc)) break; if(p.onStepEnd(this, pc)) break;
} }
} }
@ -100,7 +102,7 @@ public class MapView extends InputComponent implements KeyListener, MouseButtonL
if (!event.isOver(this)) return; if (!event.isOver(this)) return;
for (final MapInteractionPlugin p : plugins) { for (final MapInteractionPlugin p : plugins) {
if (p.onClick(this, pc, event.getPos(), event.getButton(), event.isDown())) { if(p.onClick(this, pc, event.getPos(), event.getButton(), event.isDown())) {
event.consume(); event.consume();
break; break;
} }
@ -112,7 +114,7 @@ public class MapView extends InputComponent implements KeyListener, MouseButtonL
public void receive(KeyEvent event) public void receive(KeyEvent event)
{ {
for (final MapInteractionPlugin p : plugins) { for (final MapInteractionPlugin p : plugins) {
if (p.onKey(this, pc, event.getKey(), event.isDown())) break; if(p.onKey(this, pc, event.getKey(), event.isDown())) break;
} }
if (event.getKey() == Keys.Z) { if (event.getKey() == Keys.Z) {

@ -34,7 +34,7 @@ public class Minimap extends InputComponent implements MouseButtonListener {
Color.pushAlpha(translucency); Color.pushAlpha(translucency);
final Level lvl = WorldProvider.get().getCurrentLevel(); final Level lvl = WorldProvider.get().getCurrentLevel();
unit = (int) Math.min(Math.max(2, Math.ceil((height().value() / 2) / (lvl.getHeight() + 2))), 6); unit = (int) Math.min(Math.max(2, Math.ceil((height().value() / 2) / (lvl.getHeight() + 2))), 10);
final Entity e = WorldProvider.get().getPlayerEntity(); final Entity e = WorldProvider.get().getPlayerEntity();
final Vect plCoord = e.pos.getVisualPos(); final Vect plCoord = e.pos.getVisualPos();

@ -1,6 +1,7 @@
package mightypork.rogue.world.gui.interaction; package mightypork.rogue.world.gui.interaction;
import mightypork.gamecore.input.InputSystem;
import mightypork.gamecore.util.math.algo.Coord; import mightypork.gamecore.util.math.algo.Coord;
import mightypork.gamecore.util.math.constraints.vect.Vect; import mightypork.gamecore.util.math.constraints.vect.Vect;
import mightypork.rogue.world.PlayerControl; import mightypork.rogue.world.PlayerControl;
@ -14,12 +15,13 @@ public class MIPClickPathfWalk implements MapInteractionPlugin {
@Override @Override
public void update(MapView view, PlayerControl player, double delta) public void update(MapView view, PlayerControl pc, double delta)
{ {
// if (InputSystem.isMouseButtonDown(BTN)) { if(pc.getPlayerEntity().pos.isMoving()) return;
// if (InputSystem.isMouseButtonDown(BTN)) {
// troToNav(view, player, InputSystem.getMousePos());
// } troToNav(view, pc, InputSystem.getMousePos());
}
} }
@ -30,13 +32,13 @@ public class MIPClickPathfWalk implements MapInteractionPlugin {
return troToNav(view, player, mouse); return troToNav(view, player, mouse);
} }
private boolean troToNav(MapView view, PlayerControl player, Vect mouse) private boolean troToNav(MapView view, PlayerControl player, Vect mouse)
{ {
final Coord clicked = view.toWorldPos(mouse); final Coord clicked = view.toWorldPos(mouse);
final Tile t = player.getLevel().getTile(clicked); Tile t = player.getLevel().getTile(clicked);
if (!t.isWalkable() || !t.isExplored()) return false; if (!t.isWalkable() || !t.isExplored()) return false;
player.navigateTo(clicked); player.navigateTo(clicked);
@ -49,8 +51,8 @@ public class MIPClickPathfWalk implements MapInteractionPlugin {
{ {
return false; return false;
} }
@Override @Override
public boolean onStepEnd(MapView mapView, PlayerControl player) public boolean onStepEnd(MapView mapView, PlayerControl player)
{ {

@ -12,6 +12,10 @@ import mightypork.rogue.world.gui.MapView;
public class MIPKeyWalk implements MapInteractionPlugin { public class MIPKeyWalk implements MapInteractionPlugin {
private static final int[] keys = { Keys.LEFT, Keys.RIGHT, Keys.UP, Keys.DOWN };
private static final Step[] sides = { Sides.W, Sides.E, Sides.N, Sides.S };
@Override @Override
public boolean onStepEnd(MapView view, PlayerControl player) public boolean onStepEnd(MapView view, PlayerControl player)
{ {
@ -29,27 +33,32 @@ public class MIPKeyWalk implements MapInteractionPlugin {
@Override @Override
public boolean onKey(MapView view, PlayerControl player, int key, boolean down) public boolean onKey(MapView view, PlayerControl player, int key, boolean down)
{ {
if (down) return walkByKey(player); if(down) return false; // not interested
for (int i = 0; i < 4; i++) {
if (key == keys[i]) {
return player.clickTile(sides[i]);
}
}
return false; return false;
} }
private boolean walkByKey(PlayerControl player) private boolean walkByKey(PlayerControl pc)
{ {
final int[] keys = { Keys.LEFT, Keys.RIGHT, Keys.UP, Keys.DOWN }; if(pc.getPlayerEntity().pos.isMoving()) return false;
final Step[] sides = { Sides.W, Sides.E, Sides.N, Sides.S };
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
if (InputSystem.isKeyDown(keys[i])) { if (InputSystem.isKeyDown(keys[i])) {
final Step side = sides[i]; Step side = sides[i];
if (player.canGo(side)) { if (pc.canGo(side)) {
player.go(side); pc.go(side);
return true; return true;
} else { } else {
return player.clickTile(side); return false;
} }
} }
} }
return false; return false;
@ -59,5 +68,6 @@ public class MIPKeyWalk implements MapInteractionPlugin {
@Override @Override
public void update(MapView mapView, PlayerControl pc, double delta) public void update(MapView mapView, PlayerControl pc, double delta)
{ {
walkByKey(pc);
} }
} }

@ -14,24 +14,31 @@ import mightypork.rogue.world.tile.Tile;
public class MIPMouseWalk implements MapInteractionPlugin { public class MIPMouseWalk implements MapInteractionPlugin {
@Override @Override
public void update(MapView world, PlayerControl player, double delta) public void update(MapView view, PlayerControl pc, double delta)
{ {
if (InputSystem.isMouseButtonDown(0)) { if (InputSystem.isMouseButtonDown(0)) {
// walk by holding btn // walk by holding btn
onClick(world, player, InputSystem.getMousePos(), 0, true); tryWalk(view, pc, InputSystem.getMousePos());
} }
} }
@Override @Override
public boolean onClick(MapView world, PlayerControl player, Vect mouse, int button, boolean down) public boolean onClick(MapView view, PlayerControl pc, Vect mouse, int button, boolean down)
{ {
if (!down || button != 0) return false; if (!down || button != 0) return false;
final Coord plpos = player.getCoord(); tryWalk(view, pc, mouse);
final Coord clicked = world.toWorldPos(mouse); return true;
}
private void tryWalk(MapView view, PlayerControl pc, Vect pos)
{
if (pc.getPlayerEntity().pos.isMoving()) return;
final Tile t = player.getLevel().getTile(clicked); final Coord plpos = pc.getCoord();
final Coord clicked = view.toWorldPos(pos);
final Polar p = Polar.fromCoord(clicked.x - plpos.x, clicked.y - plpos.y); final Polar p = Polar.fromCoord(clicked.x - plpos.x, clicked.y - plpos.y);
@ -39,22 +46,21 @@ public class MIPMouseWalk implements MapInteractionPlugin {
switch (dir) { switch (dir) {
case 0: case 0:
player.goEast(); pc.goEast();
break; break;
case 1: case 1:
player.goSouth(); pc.goSouth();
break; break;
case 2: case 2:
player.goWest(); pc.goWest();
break; break;
case 3: case 3:
player.goNorth(); pc.goNorth();
break; break;
} }
return true;
} }
@ -66,9 +72,12 @@ public class MIPMouseWalk implements MapInteractionPlugin {
@Override @Override
public boolean onStepEnd(MapView mapView, PlayerControl player) public boolean onStepEnd(MapView view, PlayerControl pc)
{ {
return false; if(!InputSystem.isMouseButtonDown(0)) return false;
tryWalk(view, pc, InputSystem.getMousePos());
return true;
} }
} }

@ -4,6 +4,7 @@ package mightypork.rogue.world.gui.interaction;
import mightypork.gamecore.util.math.algo.Coord; import mightypork.gamecore.util.math.algo.Coord;
import mightypork.gamecore.util.math.constraints.vect.Vect; import mightypork.gamecore.util.math.constraints.vect.Vect;
import mightypork.rogue.world.PlayerControl; import mightypork.rogue.world.PlayerControl;
import mightypork.rogue.world.WorldProvider;
import mightypork.rogue.world.gui.MapView; import mightypork.rogue.world.gui.MapView;
@ -19,9 +20,10 @@ public class MIPTileClick implements MapInteractionPlugin {
@Override @Override
public boolean onClick(MapView wv, PlayerControl player, Vect mouse, int button, boolean down) public boolean onClick(MapView wv, PlayerControl player, Vect mouse, int button, boolean down)
{ {
if (down && button == 1) { // right button if (!down && button == 0) {
final Coord pos = wv.toWorldPos(mouse); Coord pos = wv.toWorldPos(mouse);
player.clickTile(pos); player.clickTile(pos);
System.out.println("~");
return true; return true;
} }
@ -35,7 +37,6 @@ public class MIPTileClick implements MapInteractionPlugin {
return false; return false;
} }
@Override @Override
public void update(MapView mapView, PlayerControl pc, double delta) public void update(MapView mapView, PlayerControl pc, double delta)
{ {

@ -15,8 +15,8 @@ public interface MapInteractionPlugin {
boolean onKey(MapView mapView, PlayerControl player, int key, boolean down); boolean onKey(MapView mapView, PlayerControl player, int key, boolean down);
void update(MapView mapView, PlayerControl pc, double delta); void update(MapView mapView, PlayerControl pc, double delta);
} }

@ -1,6 +1,5 @@
package mightypork.rogue.world.tile; package mightypork.rogue.world.tile;
import mightypork.rogue.world.gen.TileProtectLevel; import mightypork.rogue.world.gen.TileProtectLevel;

@ -27,8 +27,7 @@ public final class Tiles {
public static final TileModel BRICK_WALL = new TileModel(11, WallTile.class, new BasicTileRenderer("tile.brick.wall")); public static final TileModel BRICK_WALL = new TileModel(11, WallTile.class, new BasicTileRenderer("tile.brick.wall"));
public static final TileModel BRICK_DOOR = new TileModel(12, DoorTile.class, new DoorRenderer("tile.brick.door.closed", "tile.brick.door.open")); public static final TileModel BRICK_DOOR = new TileModel(12, DoorTile.class, new DoorRenderer("tile.brick.door.closed", "tile.brick.door.open"));
public static final TileModel BRICK_PASSAGE = new TileModel(13, WallPassageTile.class, new BasicTileRenderer("tile.brick.passage")); public static final TileModel BRICK_PASSAGE = new TileModel(13, WallPassageTile.class, new BasicTileRenderer("tile.brick.passage"));
public static final TileModel BRICK_HIDDEN_DOOR = new TileModel(14, SecretDoorTile.class, new LockedDoorRenderer("tile.brick.door.secret", public static final TileModel BRICK_HIDDEN_DOOR = new TileModel(14, SecretDoorTile.class, new LockedDoorRenderer("tile.brick.door.secret", "tile.brick.door.closed", "tile.brick.door.open"));
"tile.brick.door.closed", "tile.brick.door.open"));
public static void register(int id, TileModel model) public static void register(int id, TileModel model)

@ -7,6 +7,7 @@ import mightypork.gamecore.util.math.constraints.rect.Rect;
import mightypork.rogue.Res; import mightypork.rogue.Res;
import mightypork.rogue.world.level.render.TileRenderContext; import mightypork.rogue.world.level.render.TileRenderContext;
import mightypork.rogue.world.tile.Tile; import mightypork.rogue.world.tile.Tile;
import mightypork.rogue.world.tile.TileRenderer;
public class LockedDoorRenderer extends DoorRenderer { public class LockedDoorRenderer extends DoorRenderer {

@ -1,7 +1,13 @@
package mightypork.rogue.world.tile.tiles; package mightypork.rogue.world.tile.tiles;
import java.io.IOException;
import mightypork.gamecore.util.ion.IonInput;
import mightypork.gamecore.util.ion.IonOutput;
import mightypork.gamecore.util.math.color.Color; import mightypork.gamecore.util.math.color.Color;
import mightypork.gamecore.util.math.timing.TimedTask;
import mightypork.rogue.world.level.Level;
import mightypork.rogue.world.tile.TileModel; import mightypork.rogue.world.tile.TileModel;
import mightypork.rogue.world.tile.TileRenderer; import mightypork.rogue.world.tile.TileRenderer;
import mightypork.rogue.world.tile.TileType; import mightypork.rogue.world.tile.TileType;
@ -9,6 +15,9 @@ import mightypork.rogue.world.tile.TileType;
public class SecretDoorTile extends LockedDoorTile { public class SecretDoorTile extends LockedDoorTile {
private int clicks = 2 + rand.nextInt(2);
public SecretDoorTile(TileModel model, TileRenderer renderer) public SecretDoorTile(TileModel model, TileRenderer renderer)
{ {
super(model, renderer); super(model, renderer);
@ -20,7 +29,9 @@ public class SecretDoorTile extends LockedDoorTile {
{ {
if (!locked) return false; if (!locked) return false;
locked = false; if (clicks > 0) clicks--;
if (clicks == 0) locked = false;
return true; return true;
} }
@ -32,4 +43,20 @@ public class SecretDoorTile extends LockedDoorTile {
if (locked) return TileType.WALL.getMapColor(); if (locked) return TileType.WALL.getMapColor();
return super.getMapColor(); return super.getMapColor();
} }
@Override
public void save(IonOutput out) throws IOException
{
super.save(out);
out.writeIntByte(clicks);
}
@Override
public void load(IonInput in) throws IOException
{
super.load(in);
clicks = in.readIntByte();
}
} }

Loading…
Cancel
Save