Skip to content

Commit

Permalink
πŸ”€ Merge pull request #106 from 6im0n/104-add-random-wall-in-centipede
Browse files Browse the repository at this point in the history
✨ add random wall in centipede map
  • Loading branch information
Njord201 authored Apr 7, 2024
2 parents 723977d + 2305fbe commit 9443676
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/centipede/CentipedeGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ void generateLine(std::vector<std::shared_ptr<Arcade::IEntity>> &line, int y, in
line.push_back(wall2);
}

void generateRandomWall(std::vector<std::vector<std::shared_ptr<Arcade::IEntity>>> &map)
{
int nbWall = rand() % 7 + 8;
for (int i = 0; i < nbWall; i++) {
int x = rand() % AREA_GAME_WIDTH;
int y = rand() % AREA_GAME_HEIGHT;
map[y][x] = std::make_shared<Arcade::Wall>(GET_POSXY_AREA(x, y));
}
}

void generateMap(std::vector<std::vector<std::shared_ptr<Arcade::IEntity>>> &map)
{
for (int i = 0; i < AREA_GAME_HEIGHT; i++) {
Expand All @@ -48,6 +58,7 @@ void generateMap(std::vector<std::vector<std::shared_ptr<Arcade::IEntity>>> &map
generateLine(map[i], i, AREA_GAME_WIDTH);
}
generateWallLine(map[AREA_GAME_HEIGHT - 1], AREA_GAME_HEIGHT, AREA_GAME_WIDTH);
generateRandomWall(map);
}

Arcade::CentipedeGame::CentipedeGame()
Expand Down

0 comments on commit 9443676

Please sign in to comment.