about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorStarla Insigna <hatkirby@fourisland.com>2012-06-03 20:05:19 -0400
committerStarla Insigna <hatkirby@fourisland.com>2012-06-03 20:05:19 -0400
commit039bb70673e3c5876aa24fb82592625be060d1bb (patch)
treeb28849af5cc5da1da5971563bea4a2ff7af983b7 /src
parenta74985844033dd9edff32b3cf4b7c49e96056410 (diff)
downloadfrigidearth-039bb70673e3c5876aa24fb82592625be060d1bb.tar.gz
frigidearth-039bb70673e3c5876aa24fb82592625be060d1bb.tar.bz2
frigidearth-039bb70673e3c5876aa24fb82592625be060d1bb.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/com/fourisland/frigidearth/Main.java2
-rw-r--r--src/com/fourisland/frigidearth/MapViewGameState.java7
2 files changed, 4 insertions, 5 deletions
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;
28 */ 28 */
29public class Main extends Canvas 29public class Main extends Canvas
30{ 30{
31 public static final int CANVAS_WIDTH = 636; 31 public static final int CANVAS_WIDTH = 624;
32 public static final int CANVAS_HEIGHT = 480; 32 public static final int CANVAS_HEIGHT = 480;
33 33
34 private static JFrame mainWindow; 34 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;
11import java.awt.Point; 11import java.awt.Point;
12import java.awt.event.KeyEvent; 12import java.awt.event.KeyEvent;
13import java.util.ArrayList; 13import java.util.ArrayList;
14import java.util.Arrays;
15import java.util.Collections; 14import java.util.Collections;
16import java.util.Deque;
17import java.util.List; 15import java.util.List;
18 16
19/** 17/**
@@ -26,7 +24,7 @@ public class MapViewGameState implements GameState
26 private final int TILE_HEIGHT = 12; 24 private final int TILE_HEIGHT = 12;
27 private final int MAP_WIDTH = 100; 25 private final int MAP_WIDTH = 100;
28 private final int MAP_HEIGHT = 100; 26 private final int MAP_HEIGHT = 100;
29 private final int MESSAGE_HEIGHT = 5; 27 private final int MESSAGE_HEIGHT = 6;
30 private final int VIEWPORT_WIDTH = Main.CANVAS_WIDTH / TILE_WIDTH; 28 private final int VIEWPORT_WIDTH = Main.CANVAS_WIDTH / TILE_WIDTH;
31 private final int VIEWPORT_HEIGHT = Main.CANVAS_HEIGHT / TILE_HEIGHT - MESSAGE_HEIGHT; 29 private final int VIEWPORT_HEIGHT = Main.CANVAS_HEIGHT / TILE_HEIGHT - MESSAGE_HEIGHT;
32 private final int MAX_ROOM_WIDTH = 13; 30 private final int MAX_ROOM_WIDTH = 13;
@@ -170,7 +168,8 @@ public class MapViewGameState implements GameState
170 for (Direction dir : Direction.values()) 168 for (Direction dir : Direction.values())
171 { 169 {
172 Point to = dir.to(new Point(newx, newy)); 170 Point to = dir.to(new Point(newx, newy));
173 if ((grid[to.x][to.y] == Tile.DirtFloor) || (grid[to.x][to.y] == Tile.Corridor)) 171
172 if ((isValidPosition(newx, newy)) && (grid[to.x][to.y] == Tile.DirtFloor) || (grid[to.x][to.y] == Tile.Corridor))
174 { 173 {
175 ways--; 174 ways--;
176 } 175 }