aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorJacob Janzen <jacob.a.s.janzen@gmail.com>2024-02-12 00:02:19 -0600
committerJacob Janzen <jacob.a.s.janzen@gmail.com>2024-02-12 00:02:19 -0600
commit8e873b2f45814508cbc6532ed2aac22729b53290 (patch)
tree06ada156b1622987f14193dc622a84f38680fb40 /main.c
parent53f018de3c6db90ed120e9993c656e23836874ae (diff)
guarantee valid starting location
Diffstat (limited to 'main.c')
-rw-r--r--main.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/main.c b/main.c
index d422b30..3dcc0d7 100644
--- a/main.c
+++ b/main.c
@@ -121,12 +121,17 @@ int main(void)
int num_open_tiles;
create_cave(&map, &open_tiles, &num_open_tiles);
+ int xpos = rand() % num_open_tiles;
+ int ypos = rand() % num_open_tiles;
+ startx = xpos = MAIN_PANEL_WIDTH / 2 + 1;
+ starty = ypos = MAIN_PANEL_HEIGHT / 2 + 1;
+
display_map(main_win, map, starty, startx);
int ch;
while ((ch = getch()) != KEY_F(1)) {
- int xpos = startx + MAIN_PANEL_WIDTH / 2 - 1;
- int ypos = starty + MAIN_PANEL_HEIGHT / 2 - 1;
+ xpos = startx + MAIN_PANEL_WIDTH / 2 - 1;
+ ypos = starty + MAIN_PANEL_HEIGHT / 2 - 1;
switch (ch) {
case 'k' :
if (ypos > 0) {