The cave playfield size (or just cave size) is the size of the visible
playfield (potentially containing an additional steelwall border, if
the level was converted from R'n'D format and does not contain a
steelwall border).
The cave buffer size is the size of the internal cave buffer (which
also contains surrounding internal game engine elements) that is used
by the EM game engine logic.
Currently the native cave structure has the same size as the internal
cave buffer; this should be changed.
struct PLAYER **ply = level_em->ply;
int i, j, x, y;
struct PLAYER **ply = level_em->ply;
int i, j, x, y;
- lev->width = MIN(level->fieldx, EM_MAX_CAVE_WIDTH);
- lev->height = MIN(level->fieldy, EM_MAX_CAVE_HEIGHT);
+ lev->width = MIN(level->fieldx, EM_MAX_CAVE_BUFFER_WIDTH);
+ lev->height = MIN(level->fieldy, EM_MAX_CAVE_BUFFER_HEIGHT);
lev->time_seconds = level->time;
lev->required_initial = level->gems_needed;
lev->time_seconds = level->time;
lev->required_initial = level->gems_needed;
map_android_clone_elements_RND_to_EM(level);
// first fill the complete playfield with the default border element
map_android_clone_elements_RND_to_EM(level);
// first fill the complete playfield with the default border element
- for (y = 0; y < EM_MAX_CAVE_HEIGHT; y++)
- for (x = 0; x < EM_MAX_CAVE_WIDTH; x++)
+ for (y = 0; y < EM_MAX_CAVE_BUFFER_HEIGHT; y++)
+ for (x = 0; x < EM_MAX_CAVE_BUFFER_WIDTH; x++)
level_em->cave[x][y] = Zborder;
if (BorderElement == EL_STEELWALL)
level_em->cave[x][y] = Zborder;
if (BorderElement == EL_STEELWALL)
}
/* first fill the complete playfield with the default border element */
}
/* first fill the complete playfield with the default border element */
- for (y = 0; y < CAVE_HEIGHT; y++)
- for (x = 0; x < CAVE_WIDTH; x++)
+ for (y = 0; y < CAVE_BUFFER_HEIGHT; y++)
+ for (x = 0; x < CAVE_BUFFER_WIDTH; x++)
native_em_level.cave[x][y] = Zborder;
/* then copy the real level contents from level file into the playfield */
native_em_level.cave[x][y] = Zborder;
/* then copy the real level contents from level file into the playfield */
/* reset all runtime variables to their initial values */
/* reset all runtime variables to their initial values */
- for (y = 0; y < CAVE_HEIGHT; y++)
- for (x = 0; x < CAVE_WIDTH; x++)
+ for (y = 0; y < CAVE_BUFFER_HEIGHT; y++)
+ for (x = 0; x < CAVE_BUFFER_WIDTH; x++)
lev.cave[x][y] = native_em_level.cave[x][y];
lev.cave[x][y] = native_em_level.cave[x][y];
- for (y = 0; y < CAVE_HEIGHT; y++)
- for (x = 0; x < CAVE_WIDTH; x++)
+ for (y = 0; y < CAVE_BUFFER_HEIGHT; y++)
+ for (x = 0; x < CAVE_BUFFER_WIDTH; x++)
lev.next[x][y] = lev.cave[x][y];
lev.next[x][y] = lev.cave[x][y];
- for (y = 0; y < CAVE_HEIGHT; y++)
- for (x = 0; x < CAVE_WIDTH; x++)
+ for (y = 0; y < CAVE_BUFFER_HEIGHT; y++)
+ for (x = 0; x < CAVE_BUFFER_WIDTH; x++)
lev.draw[x][y] = lev.cave[x][y];
lev.time_initial = lev.time_seconds;
lev.draw[x][y] = lev.cave[x][y];
lev.time_initial = lev.time_seconds;
/* define these to use additional elements */
#define EM_ENGINE_USE_ADDITIONAL_ELEMENTS
/* define these to use additional elements */
#define EM_ENGINE_USE_ADDITIONAL_ELEMENTS
-/* one border for Zborder elements, one border for steelwall, if needed */
-#define CAVE_WIDTH (MAX_PLAYFIELD_WIDTH + 2 + 2)
-#define CAVE_HEIGHT (MAX_PLAYFIELD_HEIGHT + 2 + 2)
+/* with border for steelwall, if needed (when converted from R'n'D level) */
+#define CAVE_WIDTH (MAX_PLAYFIELD_WIDTH + 2)
+#define CAVE_HEIGHT (MAX_PLAYFIELD_HEIGHT + 2)
+
+/* with border for Zborder elements (surrounding the visible playfield) */
+#define CAVE_BUFFER_XOFFSET 1
+#define CAVE_BUFFER_YOFFSET 1
+#define CAVE_BUFFER_WIDTH (CAVE_WIDTH + 2 * CAVE_BUFFER_XOFFSET)
+#define CAVE_BUFFER_HEIGHT (CAVE_HEIGHT + 2 * CAVE_BUFFER_YOFFSET)
/*
-----------------------------------------------------------------------------
/*
-----------------------------------------------------------------------------
int exit_x, exit_y; /* kludge for playing player exit sound */
int exit_x, exit_y; /* kludge for playing player exit sound */
- short cavebuf[CAVE_WIDTH][CAVE_HEIGHT];
- short nextbuf[CAVE_WIDTH][CAVE_HEIGHT];
- short drawbuf[CAVE_WIDTH][CAVE_HEIGHT];
- short boombuf[CAVE_WIDTH][CAVE_HEIGHT];
+ short cavebuf[CAVE_BUFFER_WIDTH][CAVE_BUFFER_HEIGHT];
+ short nextbuf[CAVE_BUFFER_WIDTH][CAVE_BUFFER_HEIGHT];
+ short drawbuf[CAVE_BUFFER_WIDTH][CAVE_BUFFER_HEIGHT];
+ short boombuf[CAVE_BUFFER_WIDTH][CAVE_BUFFER_HEIGHT];
- short *cavecol[CAVE_WIDTH];
- short *nextcol[CAVE_WIDTH];
- short *drawcol[CAVE_WIDTH];
- short *boomcol[CAVE_WIDTH];
+ short *cavecol[CAVE_BUFFER_WIDTH];
+ short *nextcol[CAVE_BUFFER_WIDTH];
+ short *drawcol[CAVE_BUFFER_WIDTH];
+ short *boomcol[CAVE_BUFFER_WIDTH];
short **cave;
short **next;
short **cave;
short **next;
// constant definitions
// ----------------------------------------------------------------------------
// constant definitions
// ----------------------------------------------------------------------------
-#define EM_MAX_CAVE_WIDTH CAVE_WIDTH
-#define EM_MAX_CAVE_HEIGHT CAVE_HEIGHT
+#define EM_MAX_CAVE_BUFFER_WIDTH CAVE_BUFFER_WIDTH
+#define EM_MAX_CAVE_BUFFER_HEIGHT CAVE_BUFFER_HEIGHT
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
- short cave[CAVE_WIDTH][CAVE_HEIGHT];
+ short cave[CAVE_BUFFER_WIDTH][CAVE_BUFFER_HEIGHT];
struct LEVEL *lev;
struct PLAYER *ply[MAX_PLAYERS];
struct LEVEL *lev;
struct PLAYER *ply[MAX_PLAYERS];
};
if (!game.use_native_emc_graphics_engine)
};
if (!game.use_native_emc_graphics_engine)
- for (y = 2; y < CAVE_HEIGHT - 2; y++)
- for (x = 2; x < CAVE_WIDTH - 2; x++)
+ for (y = 2; y < CAVE_BUFFER_HEIGHT - 2; y++)
+ for (x = 2; x < CAVE_BUFFER_WIDTH - 2; x++)
SetGfxAnimation_EM(&graphic_info_em_object[lev.draw[x][y]][frame],
lev.draw[x][y], 7 - frame, x - 2, y - 2);
SetGfxAnimation_EM(&graphic_info_em_object[lev.draw[x][y]][frame],
lev.draw[x][y], 7 - frame, x - 2, y - 2);
int yy = y + xy[i][1];
int tile_next;
int yy = y + xy[i][1];
int tile_next;
- if (xx < 0 || xx >= CAVE_WIDTH ||
- yy < 0 || yy >= CAVE_HEIGHT)
+ if (xx < 0 || xx >= CAVE_BUFFER_WIDTH ||
+ yy < 0 || yy >= CAVE_BUFFER_HEIGHT)
continue;
tile_next = lev.draw[xx][yy];
continue;
tile_next = lev.draw[xx][yy];
- for (y = 0; y < CAVE_HEIGHT; y++)
- for (x = 0; x < CAVE_WIDTH; x++)
+ for (y = 0; y < CAVE_BUFFER_HEIGHT; y++)
+ for (x = 0; x < CAVE_BUFFER_WIDTH; x++)
lev.cavebuf[x][y] = Zborder;
lev.cavebuf[x][y] = Zborder;
- for (y = 0; y < CAVE_HEIGHT; y++)
- for (x = 0; x < CAVE_WIDTH; x++)
+ for (y = 0; y < CAVE_BUFFER_HEIGHT; y++)
+ for (x = 0; x < CAVE_BUFFER_WIDTH; x++)
lev.nextbuf[x][y] = Zborder;
lev.nextbuf[x][y] = Zborder;
- for (y = 0; y < CAVE_HEIGHT; y++)
- for (x = 0; x < CAVE_WIDTH; x++)
+ for (y = 0; y < CAVE_BUFFER_HEIGHT; y++)
+ for (x = 0; x < CAVE_BUFFER_WIDTH; x++)
lev.drawbuf[x][y] = Zborder;
lev.drawbuf[x][y] = Zborder;
- for (y = 0; y < CAVE_HEIGHT; y++)
- for (x = 0; x < CAVE_WIDTH; x++)
+ for (y = 0; y < CAVE_BUFFER_HEIGHT; y++)
+ for (x = 0; x < CAVE_BUFFER_WIDTH; x++)
lev.boombuf[x][y] = Xblank;
lev.boombuf[x][y] = Xblank;
- for (x = 0; x < CAVE_WIDTH; x++)
+ for (x = 0; x < CAVE_BUFFER_WIDTH; x++)
lev.cavecol[x] = lev.cavebuf[x];
lev.cavecol[x] = lev.cavebuf[x];
- for (x = 0; x < CAVE_WIDTH; x++)
+ for (x = 0; x < CAVE_BUFFER_WIDTH; x++)
lev.nextcol[x] = lev.nextbuf[x];
lev.nextcol[x] = lev.nextbuf[x];
- for (x = 0; x < CAVE_WIDTH; x++)
+ for (x = 0; x < CAVE_BUFFER_WIDTH; x++)
lev.drawcol[x] = lev.drawbuf[x];
lev.drawcol[x] = lev.drawbuf[x];
- for (x = 0; x < CAVE_WIDTH; x++)
+ for (x = 0; x < CAVE_BUFFER_WIDTH; x++)
lev.boomcol[x] = lev.boombuf[x];
lev.cave = lev.cavecol;
lev.boomcol[x] = lev.boombuf[x];
lev.cave = lev.cavecol;
seed = RandomEM;
score = 0;
seed = RandomEM;
score = 0;
- for (y = 1; y < CAVE_HEIGHT - 1; y++)
- for (x = 0; x < CAVE_WIDTH; x++)
+ for (y = 1; y < CAVE_BUFFER_HEIGHT - 1; y++)
+ for (x = 0; x < CAVE_BUFFER_WIDTH; x++)
handle_tile(x, y);
if (ply[0].alive || ply[1].alive || ply[2].alive || ply[3].alive)
handle_tile(x, y);
if (ply[0].alive || ply[1].alive || ply[2].alive || ply[3].alive)
for (count = lev.amoeba_time; count--;)
{
for (count = lev.amoeba_time; count--;)
{
- x = (random >> 10) % (CAVE_WIDTH - 2);
- y = (random >> 20) % (CAVE_HEIGHT - 2);
+ x = (random >> 10) % (CAVE_BUFFER_WIDTH - 2);
+ y = (random >> 20) % (CAVE_BUFFER_HEIGHT - 2);
- for (y = 1; y < CAVE_HEIGHT - 1; y++)
- for (x = 1; x < CAVE_WIDTH - 1; x++)
+ for (y = 1; y < CAVE_BUFFER_HEIGHT - 1; y++)
+ for (x = 1; x < CAVE_BUFFER_WIDTH - 1; x++)
Lexplode(x, y);
/* triple buffering */
Lexplode(x, y);
/* triple buffering */
- for (y = 0; y < CAVE_HEIGHT; y++)
- for (x = 0; x < CAVE_WIDTH; x++)
+ for (y = 0; y < CAVE_BUFFER_HEIGHT; y++)
+ for (x = 0; x < CAVE_BUFFER_WIDTH; x++)
next[x][y] = cave[x][y];
}
next[x][y] = cave[x][y];
}