void gd_drawcave_game(const GdCave *cave,
int **element_buffer, int **last_element_buffer,
int **drawing_buffer, int **last_drawing_buffer, int **gfx_buffer,
+ int **covered_buffer,
boolean bonus_life_flash, int animcycle, boolean hate_invisible_outbox)
{
static int player_blinking = 0;
GdElement actual = cave->map[y][x];
// if covered, real element is not important
- if (actual & COVERED)
+ if (covered_buffer[y][x])
map = O_COVERED;
else
map = elemmapping[actual];
// if covered, real element is not important
- if (actual & COVERED)
+ if (covered_buffer[y][x])
draw = gd_element_properties[O_COVERED].image_game;
else
draw = elemdrawing[actual];
gd_cave_map_free(game->dir_buffer_to);
if (game->gfx_buffer)
gd_cave_map_free(game->gfx_buffer);
+ if (game->covered_buffer)
+ gd_cave_map_free(game->covered_buffer);
game->player_lives = 0;
gd_cave_map_free(game->gfx_buffer);
game->gfx_buffer = NULL;
+ // delete covered buffer
+ if (game->covered_buffer)
+ gd_cave_map_free(game->covered_buffer);
+ game->covered_buffer = NULL;
+
// load the cave
game->cave_score = 0;
for (y = 0; y < game->cave->h; y++)
for (x = 0; x < game->cave->w; x++)
game->gfx_buffer[y][x] = -1; // fill with "invalid"
+
+ // create new covered buffer
+ game->covered_buffer = gd_cave_map_new(game->cave, int);
+
+ for (y = 0; y < game->cave->h; y++)
+ for (x = 0; x < game->cave->w; x++)
+ game->covered_buffer[y][x] = FALSE;
}
GdCave *gd_create_snapshot(GdGame *game)
// cover all cells of cave
for (y = 0; y < game->cave->h; y++)
for (x = 0; x < game->cave->w; x++)
- game->cave->map[y][x] |= COVERED;
+ game->covered_buffer[y][x] = TRUE;
counter_next = game->state_counter + 1;
y = gd_random_int_range(0, game->cave->h);
x = gd_random_int_range(0, game->cave->w);
- game->cave->map[y][x] &= ~COVERED;
+ game->covered_buffer[y][x] = FALSE;
}
counter_next++; // as we did something, advance the counter.
// time to uncover the whole cave.
for (y = 0; y < game->cave->h; y++)
for (x = 0; x < game->cave->w; x++)
- game->cave->map[y][x] &= ~COVERED;
+ game->covered_buffer[y][x] = FALSE;
// to stop uncover sound.
gd_cave_clear_sounds(game->cave);
// covering eight times faster than uncovering.
for (j = 0; j < game->cave->w * game->cave->h * 8 / 40; j++)
- game->cave->map[gd_random_int_range(0, game->cave->h)][gd_random_int_range (0, game->cave->w)] |= COVERED;
+ game->covered_buffer[gd_random_int_range(0, game->cave->h)][gd_random_int_range(0, game->cave->w)] = TRUE;
}
return_state = GD_GAME_NOTHING;
// cover all
for (y = 0; y < game->cave->h; y++)
for (x = 0; x < game->cave->w; x++)
- game->cave->map[y][x] |= COVERED;
+ game->covered_buffer[y][x] = TRUE;
counter_next = game->state_counter + 1;
return_state = GD_GAME_NOTHING;
if (game->element_buffer && game->drawing_buffer && game->gfx_buffer)
gd_drawcave_game(game->cave, game->element_buffer, game->last_element_buffer,
game->drawing_buffer, game->last_drawing_buffer, game->gfx_buffer,
+ game->covered_buffer,
game->bonus_life_flash != 0, game->animcycle, setup.bd_show_invisible_outbox);
game->state_counter = counter_next;
engine_snapshot_bd.dir_buffer_from[x][y] = game->dir_buffer_from[y][x];
engine_snapshot_bd.dir_buffer_to[x][y] = game->dir_buffer_to[y][x];
engine_snapshot_bd.gfx_buffer[x][y] = game->gfx_buffer[y][x];
+ engine_snapshot_bd.covered_buffer[x][y] = game->covered_buffer[y][x];
}
}
engine_snapshot_bd.game.dir_buffer_from = game->dir_buffer_from;
engine_snapshot_bd.game.dir_buffer_to = game->dir_buffer_to;
engine_snapshot_bd.game.gfx_buffer = game->gfx_buffer;
+ engine_snapshot_bd.game.covered_buffer = game->covered_buffer;
*game = engine_snapshot_bd.game;
game->dir_buffer_from[y][x] = engine_snapshot_bd.dir_buffer_from[x][y];
game->dir_buffer_to[y][x] = engine_snapshot_bd.dir_buffer_to[x][y];
game->gfx_buffer[y][x] = engine_snapshot_bd.gfx_buffer[x][y];
+ game->covered_buffer[y][x] = engine_snapshot_bd.covered_buffer[x][y];
}
}