private int distanceBetweenPoints(Point a, Point b){ //on the same side if (a.y == b.y || a.x == b.x){ return Math.max(spaceBetween(a.x, b.x), spaceBetween(a.y, b.y)); } //otherwise... //subtract 1 at the end to account for overlap return Math.min(spaceBetween(left, a.x) + spaceBetween(left, b.x), spaceBetween(right, a.x) + spaceBetween(right, b.x)) + Math.min(spaceBetween(top, a.y) + spaceBetween(top, b.y), spaceBetween(bottom, a.y) + spaceBetween(bottom, b.y)) - 1; }
@Override public int minWidth() { return Math.max(5, super.minWidth()); }
@Override public int minHeight() { return Math.max(5, super.minHeight()); }
@Override public void paint(Level level) { if (Math.min(width(), height()) > 3) { Painter.fill(level, this, 1, Terrain.CHASM); } super.paint(level); for (Room r : neigbours){ if (r instanceof BridgeRoom || r instanceof RingBridgeRoom || r instanceof WalkwayRoom){ Rect i = intersect(r); if (i.width() != 0){ i.left++; i.right--; } else { i.top++; i.bottom--; } Painter.fill(level, i.left, i.top, i.width()+1, i.height()+1, Terrain.CHASM); } } } }
@Override public void paint(Level level) { if (Math.min(width(), height()) > 3) { Painter.fill(level, this, 1, Terrain.CHASM); } super.paint(level); for (Room r : neigbours){ if (r instanceof BridgeRoom || r instanceof RingBridgeRoom || r instanceof WalkwayRoom){ Rect i = intersect(r); if (i.width() != 0){ i.left++; i.right--; } else { i.top++; i.bottom--; } Painter.fill(level, i.left, i.top, i.width()+1, i.height()+1, Terrain.CHASM); } } } }
@Override public void paint(Level level) { super.paint(level); int floor = level.tunnelTile(); Rect ring = getConnectionSpace(); Painter.fill( level, ring.left, ring.top, 3, 3, floor); Painter.fill( level, ring.left+1, ring.top+1, 1, 1, Terrain.WALL); }
@Override public void paint(Level level) { Painter.fill(level, this, 1, Terrain.CHASM); super.paint(level); for (Room r : neigbours){ if (r instanceof BridgeRoom || r instanceof RingBridgeRoom || r instanceof WalkwayRoom){ Rect i = intersect(r); if (i.width() != 0){ i.left++; i.right--; } else { i.top++; i.bottom--; } Painter.fill(level, i.left, i.top, i.width()+1, i.height()+1, Terrain.CHASM); } } } }
protected Rect getConnectionSpace(){ Point c = getDoorCenter(); return new Rect(c.x, c.y, c.x, c.y); }
@Override protected Rect getConnectionSpace() { if (connSpace == null) { Point c = getDoorCenter(); c.x = (int) GameMath.gate(left + 2, c.x, right - 2); c.y = (int) GameMath.gate(top + 2, c.y, bottom - 2); connSpace = new Rect(c.x-1, c.y-1, c.x+1, c.y+1); } return connSpace; } }
@Override public void paint(Level level) { super.paint(level); Painter.fill(level, this, 1, Terrain.EMPTY); //true = space, false = wall boolean[][] maze = Maze.generate(this); Painter.fill(level, this, 1, Terrain.EMPTY); for (int x = 0; x < maze.length; x++) for (int y = 0; y < maze[0].length; y++) { if (maze[x][y] == Maze.FILLED) { Painter.fill(level, x + left, y + top, 1, 1, Terrain.WALL); } } for (Door door : connected.values()) { door.set( Door.Type.HIDDEN ); } }
@Override public void paint(Level level) { if (Math.min(width(), height()) > 3) { Painter.fill(level, this, 1, Terrain.CHASM); } super.paint(level); for (Room r : neigbours){ if (r instanceof BridgeRoom || r instanceof RingBridgeRoom || r instanceof WalkwayRoom){ Rect i = intersect(r); if (i.width() != 0){ i.left++; i.right--; } else { i.top++; i.bottom--; } Painter.fill(level, i.left, i.top, i.width()+1, i.height()+1, Terrain.CHASM); } } } }
@Override public void paint(Level level) { if (Math.min(width(), height()) > 3) { Painter.fill(level, this, 1, Terrain.CHASM); } super.paint(level); for (Room r : neigbours){ if (r instanceof BridgeRoom || r instanceof RingBridgeRoom || r instanceof WalkwayRoom){ Rect i = intersect(r); if (i.width() != 0){ i.left++; i.right--; } else { i.top++; i.bottom--; } Painter.fill(level, i.left, i.top, i.width()+1, i.height()+1, Terrain.CHASM); } } } }
@Override public void paint(Level level) { super.paint(level); int floor = level.tunnelTile(); Rect ring = getConnectionSpace(); Painter.fill( level, ring.left, ring.top, 3, 3, floor); Painter.fill( level, ring.left+1, ring.top+1, 1, 1, Terrain.WALL); }
@Override public void paint(Level level) { Painter.fill(level, this, 1, Terrain.CHASM); super.paint(level); for (Room r : neigbours){ if (r instanceof BridgeRoom || r instanceof RingBridgeRoom || r instanceof WalkwayRoom){ Rect i = intersect(r); if (i.width() != 0){ i.left++; i.right--; } else { i.top++; i.bottom--; } Painter.fill(level, i.left, i.top, i.width()+1, i.height()+1, Terrain.CHASM); } } } }
@Override public int minWidth() { return Math.max(5, super.minWidth()); }
@Override public int minHeight() { return Math.max(5, super.minHeight()); }
protected Rect getConnectionSpace(){ Point c = getDoorCenter(); return new Rect(c.x, c.y, c.x, c.y); }
@Override protected Rect getConnectionSpace() { if (connSpace == null) { Point c = getDoorCenter(); c.x = (int) GameMath.gate(left + 2, c.x, right - 2); c.y = (int) GameMath.gate(top + 2, c.y, bottom - 2); connSpace = new Rect(c.x-1, c.y-1, c.x+1, c.y+1); } return connSpace; } }
private int distanceBetweenPoints(Point a, Point b){ //on the same side if (a.y == b.y || a.x == b.x){ return Math.max(spaceBetween(a.x, b.x), spaceBetween(a.y, b.y)); } //otherwise... //subtract 1 at the end to account for overlap return Math.min(spaceBetween(left, a.x) + spaceBetween(left, b.x), spaceBetween(right, a.x) + spaceBetween(right, b.x)) + Math.min(spaceBetween(top, a.y) + spaceBetween(top, b.y), spaceBetween(bottom, a.y) + spaceBetween(bottom, b.y)) - 1; }
@Override public void paint(Level level) { super.paint(level); Painter.fill(level, this, 1, Terrain.EMPTY); //true = space, false = wall boolean[][] maze = Maze.generate(this); Painter.fill(level, this, 1, Terrain.EMPTY); for (int x = 0; x < maze.length; x++) for (int y = 0; y < maze[0].length; y++) { if (maze[x][y] == Maze.FILLED) { Painter.fill(level, x + left, y + top, 1, 1, Terrain.WALL); } } for (Door door : connected.values()) { door.set( Door.Type.HIDDEN ); } }