about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorStarla Insigna <hatkirby@fourisland.com>2012-06-04 08:45:33 -0400
committerStarla Insigna <hatkirby@fourisland.com>2012-06-04 08:45:33 -0400
commitde4a0dc1802a91cd8601f9327ea2a39fadc6a5fb (patch)
tree32c9e410aeffe8099fff7b132c952244c658be13
parent48525fb8610a197f7cd479848b6a6abb72bfcf82 (diff)
downloadfrigidearth-de4a0dc1802a91cd8601f9327ea2a39fadc6a5fb.tar.gz
frigidearth-de4a0dc1802a91cd8601f9327ea2a39fadc6a5fb.tar.bz2
frigidearth-de4a0dc1802a91cd8601f9327ea2a39fadc6a5fb.zip
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.
-rw-r--r--src/com/fourisland/frigidearth/MapViewGameState.java104
-rw-r--r--src/com/fourisland/frigidearth/Tile.java6
2 files changed, 110 insertions, 0 deletions
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
47 private int health = 15; 47 private int health = 15;
48 private int maxHealth = 15; 48 private int maxHealth = 15;
49 private int defense = 0; 49 private int defense = 0;
50 private int keyx;
51 private int keyy;
52 private boolean haveKey = false;
53 private boolean snowGrow = false;
54 private int heartbeat = 0;
50 55
51 public MapViewGameState() 56 public MapViewGameState()
52 { 57 {
@@ -311,24 +316,34 @@ public class MapViewGameState implements GameState
311 case North: 316 case North:
312 grid[room.getX()+room.getWidth()/2][room.getY()+room.getHeight()] = Tile.Door; 317 grid[room.getX()+room.getWidth()/2][room.getY()+room.getHeight()] = Tile.Door;
313 grid[room.getX()+room.getWidth()/2][room.getY()+room.getHeight()-1] = Tile.DirtFloor; 318 grid[room.getX()+room.getWidth()/2][room.getY()+room.getHeight()-1] = Tile.DirtFloor;
319 keyx = room.getX()+3;
320 keyy = room.getY()+3;
314 break; 321 break;
315 322
316 case East: 323 case East:
317 grid[room.getX()-1][room.getY()+room.getHeight()/2] = Tile.Door; 324 grid[room.getX()-1][room.getY()+room.getHeight()/2] = Tile.Door;
318 grid[room.getX()][room.getY()+room.getHeight()/2] = Tile.DirtFloor; 325 grid[room.getX()][room.getY()+room.getHeight()/2] = Tile.DirtFloor;
326 keyx = room.getX()+10;
327 keyy = room.getY()+3;
319 break; 328 break;
320 329
321 case South: 330 case South:
322 grid[room.getX()+room.getWidth()/2][room.getY()-1] = Tile.Door; 331 grid[room.getX()+room.getWidth()/2][room.getY()-1] = Tile.Door;
323 grid[room.getX()+room.getWidth()/2][room.getY()] = Tile.DirtFloor; 332 grid[room.getX()+room.getWidth()/2][room.getY()] = Tile.DirtFloor;
333 keyx = room.getX()+3;
334 keyy = room.getY()+10;
324 break; 335 break;
325 336
326 case West: 337 case West:
327 grid[room.getX()+room.getWidth()][room.getY()+room.getHeight()/2] = Tile.Door; 338 grid[room.getX()+room.getWidth()][room.getY()+room.getHeight()/2] = Tile.Door;
328 grid[room.getX()+room.getWidth()-1][room.getY()+room.getHeight()/2] = Tile.DirtFloor; 339 grid[room.getX()+room.getWidth()-1][room.getY()+room.getHeight()/2] = Tile.DirtFloor;
340 keyx = room.getX()+3;
341 keyy = room.getY()+3;
329 break; 342 break;
330 } 343 }
331 344
345 rooms.add(room);
346
332 adjustViewport(); 347 adjustViewport();
333 calculateFieldOfView(); 348 calculateFieldOfView();
334 } 349 }
@@ -673,6 +688,12 @@ public class MapViewGameState implements GameState
673 } 688 }
674 } 689 }
675 690
691 // Render key
692 if ((!haveKey) && (gridLighting[keyx][keyy]))
693 {
694 g.drawImage(SystemFont.getCharacter('k', Color.YELLOW), (keyx-viewportx)*TILE_WIDTH, (keyy-viewporty)*TILE_HEIGHT, TILE_WIDTH, TILE_HEIGHT, null);
695 }
696
676 // Render player 697 // Render player
677 g.drawImage(SystemFont.getCharacter('@', Color.WHITE), (playerx-viewportx)*TILE_WIDTH, (playery-viewporty)*TILE_HEIGHT, TILE_WIDTH, TILE_HEIGHT, null); 698 g.drawImage(SystemFont.getCharacter('@', Color.WHITE), (playerx-viewportx)*TILE_WIDTH, (playery-viewporty)*TILE_HEIGHT, TILE_WIDTH, TILE_HEIGHT, null);
678 699
@@ -767,6 +788,27 @@ public class MapViewGameState implements GameState
767 788
768 break; 789 break;
769 790
791 case KeyEvent.VK_G:
792 if ((playerx == keyx) && (playery == keyy) && (!haveKey))
793 {
794 haveKey = true;
795 printMessage("You get the key");
796 printMessage("All the windows in the room shatter!");
797
798 for (int x=0; x<MAP_WIDTH; x++)
799 {
800 for (int y=0; y<MAP_HEIGHT; y++)
801 {
802 if (grid[x][y] == Tile.Window)
803 {
804 grid[x][y] = Tile.ShatteredWindow;
805 }
806 }
807 }
808 }
809
810 break;
811
770 default: 812 default:
771 return; 813 return;
772 } 814 }
@@ -808,6 +850,68 @@ public class MapViewGameState implements GameState
808 } 850 }
809 } 851 }
810 852
853 // Move snow
854 if (snowGrow)
855 {
856 for (int x=0; x<MAP_WIDTH; x++)
857 {
858 for (int y=0; y<MAP_HEIGHT; y++)
859 {
860 if (grid[x][y] == Tile.Snow)
861 {
862 for (Direction d : Direction.values())
863 {
864 Point to = d.to(new Point(x, y));
865 if ((!grid[to.x][to.y].isBlocked()) && (grid[to.x][to.y] != Tile.Snow) && (grid[to.x][to.y] != Tile.UpStairs))
866 {
867 grid[to.x][to.y] = Tile.SnowTemp;
868 }
869 }
870 }
871 }
872 }
873
874 for (int x=0; x<MAP_WIDTH; x++)
875 {
876 for (int y=0; y<MAP_HEIGHT; y++)
877 {
878 if (grid[x][y] == Tile.ShatteredWindow)
879 {
880 for (Direction d : Direction.values())
881 {
882 Point to = d.to(new Point(x, y));
883 if ((!grid[to.x][to.y].isBlocked()) && (grid[to.x][to.y] != Tile.Snow))
884 {
885 grid[to.x][to.y] = Tile.Snow;
886 }
887 }
888 } else if (grid[x][y] == Tile.SnowTemp)
889 {
890 grid[x][y] = Tile.Snow;
891 }
892 }
893 }
894 }
895
896 snowGrow = !snowGrow;
897
898 // Heartbeat
899 if (heartbeat % 2 == 0)
900 {
901 if (grid[playerx][playery] == Tile.Snow)
902 {
903 health--;
904 } else if (heartbeat == Functions.random(0, 3)) {
905 if (health < maxHealth)
906 {
907 health++;
908 }
909 }
910 }
911
912 heartbeat++;
913 if (heartbeat == 4) heartbeat = 0;
914
811 adjustViewport(); 915 adjustViewport();
812 calculateFieldOfView(); 916 calculateFieldOfView();
813 917
diff --git a/src/com/fourisland/frigidearth/Tile.java b/src/com/fourisland/frigidearth/Tile.java index 5d758e2..8b11e50 100644 --- a/src/com/fourisland/frigidearth/Tile.java +++ b/src/com/fourisland/frigidearth/Tile.java
@@ -152,6 +152,12 @@ public enum Tile
152 { 152 {
153 return new Color(255, 250, 250); 153 return new Color(255, 250, 250);
154 } 154 }
155 },
156 SnowTemp {
157 public boolean isBlocked()
158 {
159 return false;
160 }
155 }; 161 };
156 162
157 public abstract boolean isBlocked(); 163 public abstract boolean isBlocked();