about summary refs log tree commit diff stats
path: root/src/com/fourisland
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/fourisland')
-rw-r--r--src/com/fourisland/frigidearth/MapViewGameState.java41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/com/fourisland/frigidearth/MapViewGameState.java b/src/com/fourisland/frigidearth/MapViewGameState.java index c6f82d0..d85608a 100644 --- a/src/com/fourisland/frigidearth/MapViewGameState.java +++ b/src/com/fourisland/frigidearth/MapViewGameState.java
@@ -150,6 +150,47 @@ public class MapViewGameState implements GameState
150 } 150 }
151 } 151 }
152 } 152 }
153
154 int newx = 0;
155 int newy = 0;
156 int ways = 0;
157 int state = 0;
158 while (state != 10)
159 {
160 for (int testing = 0; testing < 1000; testing++)
161 {
162 newx = Functions.random(1, GAME_WIDTH-1);
163 newy = Functions.random(1, GAME_HEIGHT-2);
164 ways = 4;
165
166 for (Direction dir : Direction.values())
167 {
168 Point to = dir.to(new Point(newx, newy));
169 if ((grid[to.x][to.y] == Tile.DirtFloor) || (grid[to.x][to.y] == Tile.Corridor))
170 {
171 ways--;
172 }
173 }
174
175 if (state == 0)
176 {
177 if (ways == 0)
178 {
179 grid[newx][newy] = Tile.UpStairs;
180 state = 1;
181 break;
182 }
183 } else if (state == 1)
184 {
185 if (ways == 0)
186 {
187 grid[newx][newy] = Tile.DownStairs;
188 state = 10;
189 break;
190 }
191 }
192 }
193 }
153 } 194 }
154 195
155 private boolean makeRoom(int x, int y, Direction direction) 196 private boolean makeRoom(int x, int y, Direction direction)