From e68193a5bacb0f668f09d4a399fbc9c3418d2fa8 Mon Sep 17 00:00:00 2001 From: Starla Insigna Date: Sun, 3 Jun 2012 21:38:51 -0400 Subject: Added death condition Now, when you reach zero health, you are promted to quit the game. Also, Window, ShatteredWindow and Snow tiles were added in preparation for the key rooms. --- .../fourisland/frigidearth/MapViewGameState.java | 18 ++++++++- src/com/fourisland/frigidearth/Tile.java | 43 ++++++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/com/fourisland/frigidearth/MapViewGameState.java b/src/com/fourisland/frigidearth/MapViewGameState.java index 65bfbe7..e0cc8cb 100644 --- a/src/com/fourisland/frigidearth/MapViewGameState.java +++ b/src/com/fourisland/frigidearth/MapViewGameState.java @@ -191,7 +191,7 @@ public class MapViewGameState implements GameState if (ways == 0) { grid[newx][newy] = Tile.DownStairs; - playerx=newx+1; + playerx=newx; playery=newy; state = 10; break; @@ -673,6 +673,22 @@ public class MapViewGameState implements GameState adjustViewport(); calculateFieldOfView(); + + if (health <= 0) + { + printMessage("You have died! Press [ENTER] to quit."); + + Main.addInputable(new Inputable() { + @Override + public void processInput(KeyEvent e) + { + if (e.getKeyCode() == KeyEvent.VK_ENTER) + { + System.exit(0); + } + } + }); + } } private void adjustViewport() diff --git a/src/com/fourisland/frigidearth/Tile.java b/src/com/fourisland/frigidearth/Tile.java index be17d6c..5d758e2 100644 --- a/src/com/fourisland/frigidearth/Tile.java +++ b/src/com/fourisland/frigidearth/Tile.java @@ -109,6 +109,49 @@ public enum Tile { return new Color(162, 181, 205); } + }, + Window { + public boolean isBlocked() + { + return true; + } + + public char getDisplayCharacter() + { + return 'W'; + } + + public Color getBackgroundColor() + { + return new Color(0, 63, 135); + } + }, + ShatteredWindow { + public boolean isBlocked() + { + return false; + } + + public char getDisplayCharacter() + { + return 'W'; + } + + public Color getBackgroundColor() + { + return new Color(162, 181, 205); + } + }, + Snow { + public boolean isBlocked() + { + return false; + } + + public Color getBackgroundColor() + { + return new Color(255, 250, 250); + } }; public abstract boolean isBlocked(); -- cgit 1.4.1