From de4a0dc1802a91cd8601f9327ea2a39fadc6a5fb Mon Sep 17 00:00:00 2001 From: Starla Insigna Date: Mon, 4 Jun 2012 08:45:33 -0400 Subject: Added key and heartbeat When you pick up the key, the windows in the room shatter and snow grows into unblocked spaces (except for up stairs) every other turn. When you're standing on snow, you lose 1HP every other turn. When you're not, you randomly gain 1HP back every few turns. --- .../fourisland/frigidearth/MapViewGameState.java | 104 +++++++++++++++++++++ src/com/fourisland/frigidearth/Tile.java | 6 ++ 2 files changed, 110 insertions(+) (limited to 'src/com/fourisland') diff --git a/src/com/fourisland/frigidearth/MapViewGameState.java b/src/com/fourisland/frigidearth/MapViewGameState.java index bcac17d..5a13e7e 100644 --- a/src/com/fourisland/frigidearth/MapViewGameState.java +++ b/src/com/fourisland/frigidearth/MapViewGameState.java @@ -47,6 +47,11 @@ public class MapViewGameState implements GameState private int health = 15; private int maxHealth = 15; private int defense = 0; + private int keyx; + private int keyy; + private boolean haveKey = false; + private boolean snowGrow = false; + private int heartbeat = 0; public MapViewGameState() { @@ -311,24 +316,34 @@ public class MapViewGameState implements GameState case North: grid[room.getX()+room.getWidth()/2][room.getY()+room.getHeight()] = Tile.Door; grid[room.getX()+room.getWidth()/2][room.getY()+room.getHeight()-1] = Tile.DirtFloor; + keyx = room.getX()+3; + keyy = room.getY()+3; break; case East: grid[room.getX()-1][room.getY()+room.getHeight()/2] = Tile.Door; grid[room.getX()][room.getY()+room.getHeight()/2] = Tile.DirtFloor; + keyx = room.getX()+10; + keyy = room.getY()+3; break; case South: grid[room.getX()+room.getWidth()/2][room.getY()-1] = Tile.Door; grid[room.getX()+room.getWidth()/2][room.getY()] = Tile.DirtFloor; + keyx = room.getX()+3; + keyy = room.getY()+10; break; case West: grid[room.getX()+room.getWidth()][room.getY()+room.getHeight()/2] = Tile.Door; grid[room.getX()+room.getWidth()-1][room.getY()+room.getHeight()/2] = Tile.DirtFloor; + keyx = room.getX()+3; + keyy = room.getY()+3; break; } + rooms.add(room); + adjustViewport(); calculateFieldOfView(); } @@ -673,6 +688,12 @@ public class MapViewGameState implements GameState } } + // Render key + if ((!haveKey) && (gridLighting[keyx][keyy])) + { + g.drawImage(SystemFont.getCharacter('k', Color.YELLOW), (keyx-viewportx)*TILE_WIDTH, (keyy-viewporty)*TILE_HEIGHT, TILE_WIDTH, TILE_HEIGHT, null); + } + // Render player g.drawImage(SystemFont.getCharacter('@', Color.WHITE), (playerx-viewportx)*TILE_WIDTH, (playery-viewporty)*TILE_HEIGHT, TILE_WIDTH, TILE_HEIGHT, null); @@ -767,6 +788,27 @@ public class MapViewGameState implements GameState break; + case KeyEvent.VK_G: + if ((playerx == keyx) && (playery == keyy) && (!haveKey)) + { + haveKey = true; + printMessage("You get the key"); + printMessage("All the windows in the room shatter!"); + + for (int x=0; x