diff options
| author | Emil Williams | 2026-02-15 02:44:29 +0000 |
|---|---|---|
| committer | Emil Williams | 2026-02-15 02:44:29 +0000 |
| commit | 97ddf26c3d83a9ae2a99a3d6d2884a3ebecd3e03 (patch) | |
| tree | a012960ad45eba54f512da2337440a448f72a2f0 /source/gamemode.c | |
| parent | dc655ac2079e0eea55c56b6712bf6a2167b57845 (diff) | |
| download | Monobomberman-97ddf26c3d83a9ae2a99a3d6d2884a3ebecd3e03.tar.xz Monobomberman-97ddf26c3d83a9ae2a99a3d6d2884a3ebecd3e03.tar.zst | |
config_t 2, bomb minus bugs
Diffstat (limited to 'source/gamemode.c')
| -rw-r--r-- | source/gamemode.c | 71 |
1 files changed, 13 insertions, 58 deletions
diff --git a/source/gamemode.c b/source/gamemode.c index cf5d06a..9c1055a 100644 --- a/source/gamemode.c +++ b/source/gamemode.c @@ -1,8 +1,16 @@ #include "all.h" -void MultiPlayer(game_t * game, u16 width, u16 height, u8 player_count) { +void MultiPlayer(game_t * game) { + u8 width = game->config.map_x; + u8 height = game->config.map_y; int i, j; + for (i = 0; i < PLAYER_LIMIT; ++i) { + for (j = 0; j < BOMB_LIMIT; ++j) { + game->bombs.timer[i][j] = 0; + } + } + for (i = 0; i < width; ++i) { for (j = 0; j < height; ++j) { game->tiles.state[i][j]._ = rand() % 10 ? IMPASSIBLE_BREAKABLE_WALL : PASSIBLE_NOTHING; @@ -17,8 +25,8 @@ void MultiPlayer(game_t * game, u16 width, u16 height, u8 player_count) { bzero(game->players.state, sizeof(*game->players.state) * PLAYER_LIMIT); - for (i = 0; i < MIN(PLAYER_LIMIT, player_count); ++i) { - game->players.state[i].bomb_limit = 1; + for (i = 0; i < MIN(PLAYER_LIMIT, game->config.player_count); ++i) { + game->players.state[i].bomb_limit = 15; game->players.state[i].power = 2; game->players.state[i].speed = 2; game->players.state[i].alive = 1; @@ -37,7 +45,7 @@ void MultiPlayer(game_t * game, u16 width, u16 height, u8 player_count) { GAME_BLUE | GAME_OPAQUE, }; - for (i = 0; i < MIN(player_count, PLAYER_LIMIT); ++i) { + for (i = 0; i < MIN(game->config.player_count, PLAYER_LIMIT); ++i) { game->players.x[i] = player_x[i % 4]; game->players.y[i] = player_y[i % 4]; game->players.color[i] = color[i % 4]; @@ -49,7 +57,7 @@ void MultiPlayer(game_t * game, u16 width, u16 height, u8 player_count) { u8 offset_y[12] = {0, 0, 1, height-1, height-1, height-2, 0, 0, 1, height-1, height-1, height-2}; - for (i = 0; i < MIN((player_count * 3), 12); ++i) { + for (i = 0; i < MIN((game->config.player_count * 3), 12); ++i) { game->tiles.state[offset_x[i]][offset_y[i]]._ = PASSIBLE_NOTHING; } @@ -60,56 +68,3 @@ void MultiPlayer(game_t * game, u16 width, u16 height, u8 player_count) { printf("\n"); } } - -/* missing proper player / bomb / enemy initialization */ -void SinglePlayer(game_t * game, u16 width, u16 height) { - u16 i, j; - - for (i = 0; i < width; ++i) { - for (j = 0; j < height; ++j) { - game->tiles.state[i][j]._ = rand() % 10 ? IMPASSIBLE_BREAKABLE_WALL : PASSIBLE_NOTHING; - } - } - - u16 x, y; - int distance, direction; - for (i = 0; i < ENEMY_LIMIT; ++i) { - distance = rand() % MIN(width, height); - direction = rand() % MOVEMENT_LAST; - x = rand() % width; - y = rand() % height; - game->enemies.x[i] = x; - game->enemies.y[i] = y; - game->enemies.movement[i] = direction; - game->tiles.state[x][y]._ = PASSIBLE_NOTHING; - for (j = -(distance/2); j+(distance/2) < distance; ++j) { - game->tiles.state - [x + (j * (direction == MOVEMENT_HORIZONTAL) * (x + j < width ))] - [y + (j * (direction == MOVEMENT_VERTICAL ) * (y + j < height))]._ = PASSIBLE_NOTHING; - } - } - - for (i = 1; i < width; i += 2) { - for (j = 1; j < height; j += 2) { - game->tiles.state[i][j]._ = IMPASSIBLE_WALL; - } - } - - game->tiles.state[0][0]._ = PASSIBLE_NOTHING; - game->tiles.state[1][0]._ = PASSIBLE_NOTHING; - game->tiles.state[0][1]._ = PASSIBLE_NOTHING; - - game->players.x[0] = 0; - game->players.y[0] = 0; - game->players.state[0].bomb_limit = 1; - game->players.state[0].power = 2; - game->players.state[0].speed = 3; - game->players.state[0].alive = 1; - - for (i = 0; i < width; ++i) { - for (j = 0; j < height; ++j) { - printf("%3d ", game->tiles.state[i][j]._); - } - printf("\n"); - } -} |
