/* reset all runtime variables to their initial values */
+ game_init_cave_buffers();
+
lev.left = CAVE_BUFFER_XOFFSET;
lev.top = CAVE_BUFFER_YOFFSET;
lev.right = lev.left + lev.width;
lev.bottom = lev.top + lev.height;
- for (y = 0; y < CAVE_HEIGHT; y++)
- for (x = 0; x < CAVE_WIDTH; x++)
+ for (x = 0; x < lev.width; x++)
+ for (y = 0; y < lev.height; y++)
lev.cave[lev.left + x][lev.top + y] = native_em_level.cave[x][y];
- for (y = 0; y < CAVE_BUFFER_HEIGHT; y++)
- for (x = 0; x < CAVE_BUFFER_WIDTH; x++)
- lev.next[x][y] = lev.cave[x][y];
-
- for (y = 0; y < CAVE_BUFFER_HEIGHT; y++)
- for (x = 0; x < CAVE_BUFFER_WIDTH; x++)
- lev.draw[x][y] = lev.cave[x][y];
+ for (x = lev.left; x < lev.right; x++)
+ for (y = lev.top; y < lev.bottom; y++)
+ lev.next[x][y] = lev.draw[x][y] = lev.cave[x][y];
lev.time_initial = lev.time_seconds;
lev.time = lev.time_initial;
seed = RandomEM;
score = 0;
- for (y = 1; y < CAVE_BUFFER_HEIGHT - 1; y++)
- for (x = 0; x < CAVE_BUFFER_WIDTH; x++)
+ for (y = lev.top; y < lev.bottom; y++)
+ for (x = lev.left; x < lev.right; x++)
handle_tile(x, y);
if (ply[0].alive || ply[1].alive || ply[2].alive || ply[3].alive)
/* handle explosions */
- for (y = 1; y < CAVE_BUFFER_HEIGHT - 1; y++)
- for (x = 1; x < CAVE_BUFFER_WIDTH - 1; x++)
+ for (y = lev.top; y < lev.bottom; y++)
+ for (x = lev.left; x < lev.right; x++)
Lexplode(x, y);
/* triple buffering */
- for (y = 0; y < CAVE_BUFFER_HEIGHT; y++)
- for (x = 0; x < CAVE_BUFFER_WIDTH; x++)
+ for (y = lev.top; y < lev.bottom; y++)
+ for (x = lev.left; x < lev.right; x++)
next[x][y] = cave[x][y];
}