From ccf37b30ce63acfd96d5e4eb47cfe5b67bde0383 Mon Sep 17 00:00:00 2001 From: Starla Insigna Date: Mon, 4 Jun 2012 16:58:18 -0400 Subject: Allowed for multiple floors Also made the spider a bit weaker --- src/com/fourisland/frigidearth/Game.java | 18 +++ src/com/fourisland/frigidearth/Main.java | 1 + .../fourisland/frigidearth/MapViewGameState.java | 138 ++++++++++++--------- src/com/fourisland/frigidearth/mobs/Spider.java | 2 +- 4 files changed, 96 insertions(+), 63 deletions(-) create mode 100644 src/com/fourisland/frigidearth/Game.java (limited to 'src') diff --git a/src/com/fourisland/frigidearth/Game.java b/src/com/fourisland/frigidearth/Game.java new file mode 100644 index 0000000..5d669de --- /dev/null +++ b/src/com/fourisland/frigidearth/Game.java @@ -0,0 +1,18 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.fourisland.frigidearth; + +/** + * + * @author hatkirby + */ +public class Game +{ + public int health = 15; + public int maxHealth = 15; + public int defense = 0; + public int level = 1; + public int experience = 0; +} diff --git a/src/com/fourisland/frigidearth/Main.java b/src/com/fourisland/frigidearth/Main.java index ff81aad..09aa273 100644 --- a/src/com/fourisland/frigidearth/Main.java +++ b/src/com/fourisland/frigidearth/Main.java @@ -30,6 +30,7 @@ public class Main extends Canvas { public static final int CANVAS_WIDTH = 624; public static final int CANVAS_HEIGHT = 480; + public static Game currentGame = new Game(); private static JFrame mainWindow; private static Color[][] grid; diff --git a/src/com/fourisland/frigidearth/MapViewGameState.java b/src/com/fourisland/frigidearth/MapViewGameState.java index 62fc632..8419244 100644 --- a/src/com/fourisland/frigidearth/MapViewGameState.java +++ b/src/com/fourisland/frigidearth/MapViewGameState.java @@ -24,8 +24,6 @@ public class MapViewGameState implements GameState { private final int TILE_WIDTH = 12; private final int TILE_HEIGHT = 12; - private final int MAP_WIDTH = 100; - private final int MAP_HEIGHT = 100; private final int MESSAGE_HEIGHT = 6; private final int VIEWPORT_WIDTH = Main.CANVAS_WIDTH / TILE_WIDTH; private final int VIEWPORT_HEIGHT = Main.CANVAS_HEIGHT / TILE_HEIGHT - MESSAGE_HEIGHT; @@ -36,6 +34,8 @@ public class MapViewGameState implements GameState private final int MAX_CORRIDOR_LENGTH = 6; private final int MIN_CORRIDOR_LENGTH = 2; 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 int mapWidth = 60; + private int mapHeight = 60; private Tile[][] grid; private boolean[][] gridLighting; private String[] messages = new String[MESSAGE_HEIGHT]; @@ -45,9 +45,6 @@ public class MapViewGameState implements GameState private int playery = 4; private int viewportx = 0; private int viewporty = 0; - private int health = 15; - private int maxHealth = 15; - private int defense = 0; private int keyx; private int keyy; private boolean haveKey = false; @@ -55,21 +52,22 @@ public class MapViewGameState implements GameState private int heartbeat = 0; private int floor; private int spawnTimer = 0; - private int level = 1; - private int experience = 0; public MapViewGameState(int floor) { this.floor = floor; - grid = new Tile[MAP_WIDTH][MAP_HEIGHT]; - gridLighting = new boolean[MAP_WIDTH][MAP_HEIGHT]; + mapWidth += (50 * floor); + mapHeight += (50 * floor); - for (int x=0; x MAP_WIDTH)) + if ((x < 0) || (x > mapWidth)) { return false; } else { @@ -472,7 +470,7 @@ public class MapViewGameState implements GameState for (ytemp = y; ytemp > (y-length); ytemp--) { - if ((ytemp < 0) || (ytemp > MAP_HEIGHT)) + if ((ytemp < 0) || (ytemp > mapHeight)) { return false; } @@ -491,7 +489,7 @@ public class MapViewGameState implements GameState break; case East: - if ((y < 0) || (y > MAP_HEIGHT)) + if ((y < 0) || (y > mapHeight)) { return false; } else { @@ -500,7 +498,7 @@ public class MapViewGameState implements GameState for (xtemp = x; xtemp < (x+length); xtemp++) { - if ((xtemp < 0) || (xtemp > MAP_WIDTH)) + if ((xtemp < 0) || (xtemp > mapWidth)) { return false; } @@ -519,7 +517,7 @@ public class MapViewGameState implements GameState break; case South: - if ((x < 0) || (x > MAP_WIDTH)) + if ((x < 0) || (x > mapWidth)) { return false; } else { @@ -528,7 +526,7 @@ public class MapViewGameState implements GameState for (ytemp = y; ytemp < (y+length); ytemp++) { - if ((ytemp < 0) || (ytemp > MAP_HEIGHT)) + if ((ytemp < 0) || (ytemp > mapHeight)) { return false; } @@ -547,7 +545,7 @@ public class MapViewGameState implements GameState break; case West: - if ((y < 0) || (y > MAP_HEIGHT)) + if ((y < 0) || (y > mapHeight)) { return false; } else { @@ -556,7 +554,7 @@ public class MapViewGameState implements GameState for (xtemp = x; xtemp > (x-length); xtemp--) { - if ((xtemp < 0) || (xtemp > MAP_WIDTH)) + if ((xtemp < 0) || (xtemp > mapWidth)) { return false; } @@ -580,9 +578,9 @@ public class MapViewGameState implements GameState private void calculateFieldOfView() { - for (int x=0; x= 1000) + if (Main.currentGame.experience >= 1000) { - level++; - experience -= 1000; + Main.currentGame.level++; + Main.currentGame.experience -= 1000; int hpGain = Functions.rollDice(6, 2) + 3; - health += hpGain; - maxHealth += hpGain; + Main.currentGame.health += hpGain; + Main.currentGame.maxHealth += hpGain; - printMessage("You grow to level " + level + "!"); + printMessage("You grow to level " + Main.currentGame.level + "!"); } } @@ -833,9 +831,9 @@ public class MapViewGameState implements GameState printMessage("You get the key"); printMessage("All the windows in the room shatter!"); - for (int x=0; x path = findPath(mob.getPosition(), new Point(playerx, playery)); @@ -922,9 +936,9 @@ public class MapViewGameState implements GameState // Move snow if (snowGrow) { - for (int x=0; x (VIEWPORT_WIDTH/2)) { - if (playerx < (MAP_WIDTH - (VIEWPORT_WIDTH/2-1))) + if (playerx < (mapWidth - (VIEWPORT_WIDTH/2-1))) { viewportx = playerx - (VIEWPORT_WIDTH/2); } else { - viewportx = MAP_WIDTH - VIEWPORT_WIDTH; + viewportx = mapWidth - VIEWPORT_WIDTH; } } else { viewportx = 0; @@ -1043,11 +1057,11 @@ public class MapViewGameState implements GameState if (playery > (VIEWPORT_HEIGHT/2)) { - if (playery < (MAP_HEIGHT - (VIEWPORT_HEIGHT/2-1))) + if (playery < (mapHeight - (VIEWPORT_HEIGHT/2-1))) { viewporty = playery - (VIEWPORT_HEIGHT/2); } else { - viewporty = MAP_HEIGHT - VIEWPORT_HEIGHT; + viewporty = mapHeight - VIEWPORT_HEIGHT; } } else { viewporty = 0; @@ -1057,9 +1071,9 @@ public class MapViewGameState implements GameState private boolean isValidPosition(int x, int y) { if (x < 0) return false; - if (x > MAP_WIDTH) return false; + if (x > mapWidth) return false; if (y < 0) return false; - if (y > MAP_HEIGHT) return false; + if (y > mapHeight) return false; return true; } diff --git a/src/com/fourisland/frigidearth/mobs/Spider.java b/src/com/fourisland/frigidearth/mobs/Spider.java index 58a554b..7d3330e 100644 --- a/src/com/fourisland/frigidearth/mobs/Spider.java +++ b/src/com/fourisland/frigidearth/mobs/Spider.java @@ -44,7 +44,7 @@ public class Spider extends Mob public int getAttackPower() { - return 2; + return 1; } public int getBaseExperience() -- cgit 1.4.1