From 039bb70673e3c5876aa24fb82592625be060d1bb Mon Sep 17 00:00:00 2001 From: Starla Insigna Date: Sun, 3 Jun 2012 20:05:19 -0400 Subject: Fixed a couple of out of bounds map bugs One bug had to do with the fact that if the game attempted to place a staircase at the edge of the map, it would check if every surrounding space was blocked regardless of whether or not they were valid positions (i.e. if they were off the edge off the map). The other bug had to do with rounding errors when calculating the viewport because the viewport width and height were both an odd number of tiles. By decreasing the canvas width and increasing the size of the message window, the viewport was changed so as to have an even width and height, thus avoiding the rounding errors. --- src/com/fourisland/frigidearth/Main.java | 2 +- src/com/fourisland/frigidearth/MapViewGameState.java | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/com/fourisland/frigidearth/Main.java b/src/com/fourisland/frigidearth/Main.java index bd617b3..09c0b28 100644 --- a/src/com/fourisland/frigidearth/Main.java +++ b/src/com/fourisland/frigidearth/Main.java @@ -28,7 +28,7 @@ import javax.swing.JFrame; */ public class Main extends Canvas { - public static final int CANVAS_WIDTH = 636; + public static final int CANVAS_WIDTH = 624; public static final int CANVAS_HEIGHT = 480; private static JFrame mainWindow; diff --git a/src/com/fourisland/frigidearth/MapViewGameState.java b/src/com/fourisland/frigidearth/MapViewGameState.java index 67da9ae..dd20eac 100644 --- a/src/com/fourisland/frigidearth/MapViewGameState.java +++ b/src/com/fourisland/frigidearth/MapViewGameState.java @@ -11,9 +11,7 @@ import java.awt.Graphics2D; import java.awt.Point; import java.awt.event.KeyEvent; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; -import java.util.Deque; import java.util.List; /** @@ -26,7 +24,7 @@ public class MapViewGameState implements GameState private final int TILE_HEIGHT = 12; private final int MAP_WIDTH = 100; private final int MAP_HEIGHT = 100; - private final int MESSAGE_HEIGHT = 5; + private final int MESSAGE_HEIGHT = 6; private final int VIEWPORT_WIDTH = Main.CANVAS_WIDTH / TILE_WIDTH; private final int VIEWPORT_HEIGHT = Main.CANVAS_HEIGHT / TILE_HEIGHT - MESSAGE_HEIGHT; private final int MAX_ROOM_WIDTH = 13; @@ -170,7 +168,8 @@ public class MapViewGameState implements GameState for (Direction dir : Direction.values()) { Point to = dir.to(new Point(newx, newy)); - if ((grid[to.x][to.y] == Tile.DirtFloor) || (grid[to.x][to.y] == Tile.Corridor)) + + if ((isValidPosition(newx, newy)) && (grid[to.x][to.y] == Tile.DirtFloor) || (grid[to.x][to.y] == Tile.Corridor)) { ways--; } -- cgit 1.4.1