about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--README.md10
-rw-r--r--src/com/fourisland/frigidearth/MapViewGameState.java41
2 files changed, 49 insertions, 2 deletions
diff --git a/README.md b/README.md index ca63a11..fe9e1cd 100644 --- a/README.md +++ b/README.md
@@ -1,4 +1,10 @@
1frigidearth 1Frigid Earth
2=========== 2===========
3 3
42012 seven day rougelike entry \ No newline at end of file 4A seven day roguelike about being the last person left on an Earth that has become too cold to sustain life.
5
6This project is still being worked on! I'm posting daily updates about my progress on my blog:
7
8# [Day 1](http://www.fourisland.com/2012/06/frigid-earth-day-1/)
9
10© 2012 Starla Insigna
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)