From a87eb8f0548206c0c9a7ff180774d48b97447418 Mon Sep 17 00:00:00 2001 From: Starla Insigna Date: Sun, 3 Jun 2012 15:24:13 -0400 Subject: Added message window --- .../fourisland/frigidearth/MapViewGameState.java | 55 +++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) (limited to 'src/com/fourisland') diff --git a/src/com/fourisland/frigidearth/MapViewGameState.java b/src/com/fourisland/frigidearth/MapViewGameState.java index e038d41..3b2cce2 100644 --- a/src/com/fourisland/frigidearth/MapViewGameState.java +++ b/src/com/fourisland/frigidearth/MapViewGameState.java @@ -22,8 +22,9 @@ public class MapViewGameState implements GameState private final int TILE_HEIGHT = 16; private final int GAME_WIDTH = 100; private final int GAME_HEIGHT = 100; + private final int MESSAGE_HEIGHT = 5; private final int VIEWPORT_WIDTH = Main.GAME_WIDTH / TILE_WIDTH; - private final int VIEWPORT_HEIGHT = Main.GAME_HEIGHT / TILE_HEIGHT; + private final int VIEWPORT_HEIGHT = Main.GAME_HEIGHT / TILE_HEIGHT - MESSAGE_HEIGHT; private final int MAX_ROOM_WIDTH = 13; private final int MIN_ROOM_WIDTH = 7; private final int MAX_ROOM_HEIGHT = 13; @@ -33,6 +34,7 @@ public class MapViewGameState implements GameState private final int[][] OCTET_MULTIPLIERS = new int[][] {new int[] {1,0,0,-1,-1,0,0,1}, new int[] {0,1,-1,0,0,-1,1,0}, new int[] {0,1,1,0,0,-1,-1,0}, new int[] {1,0,0,1,-1,0,0,-1}}; private Tile[][] grid; private boolean[][] gridLighting; + private String[] messages = new String[MESSAGE_HEIGHT]; private List rooms = new ArrayList(); private List mobs = new ArrayList(); private int playerx = 4; @@ -525,6 +527,21 @@ public class MapViewGameState implements GameState // Render player g.drawImage(SystemFont.getCharacter('@'), (playerx-viewportx)*TILE_WIDTH, (playery-viewporty)*TILE_HEIGHT, TILE_WIDTH, TILE_HEIGHT, null); + + // Render messages + g.setColor(new Color(53, 63, 62)); + g.fillRect(0, VIEWPORT_HEIGHT*TILE_HEIGHT, Main.GAME_WIDTH, TILE_HEIGHT*MESSAGE_HEIGHT); + + for (int i=0; i VIEWPORT_WIDTH) + { + String shortm = temp.substring(0, VIEWPORT_WIDTH); + + if ((temp.charAt(VIEWPORT_WIDTH) == ' ') || (shortm.endsWith(" "))) + { + pushUpMessages(shortm); + temp = temp.substring(VIEWPORT_WIDTH); + } else { + int lastSpace = shortm.lastIndexOf(" "); + pushUpMessages(shortm.substring(0, lastSpace)); + temp = temp.substring(lastSpace); + } + } + + pushUpMessages(temp); + } + + private void pushUpMessages(String message) + { + for (int i=1; i