Skip to content

Commit

Permalink
Added ability to load a different map
Browse files Browse the repository at this point in the history
  • Loading branch information
CMDR-JohnAlex committed Jul 19, 2022
1 parent e578f11 commit 669113f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 12 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## [0.4.1]

### Added
* Added ability to load a different map

-------------------------------------------------------------------------------------------------------------

## [0.4.0]

### Added
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ I am learning OpenGL3.3 at [LearnOpenGL.com](https://learnopengl.com/) and after

This will be my first non-tutorial OpenGL project.

To load a different map than `map.txt`, open a terminal and type `./Windows95Maze.exe --map mapName.txt` but replace `mapName.txt` with the map file you want to load. On Windows you may need to change `./` to `.\`.

Please note, if you compile the program for yourself, make sure you move the executable to the root project directory.

Pre-compiled release versions should work without moving any files.
Expand Down
28 changes: 16 additions & 12 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,21 +179,18 @@ int main(int argc, char* argv[]) {
std::cout << "-c or --copyright Copyright Notice\n";
return 0;
}

if (strcmp(argv[1], "-m") == 0 || strcmp(argv[1], "--map") == 0)
else if (strcmp(argv[1], "-m") == 0 || strcmp(argv[1], "--map") == 0)
{
mapFilePath = argv[1];
return 0;
mapFilePath = "data/maps/" + std::string(argv[2]);
std::cout << "New map path: " << mapFilePath << '\n';
}

if (strcmp(argv[1], "-v") == 0 || strcmp(argv[1], "--version") == 0)
else if (strcmp(argv[1], "-v") == 0 || strcmp(argv[1], "--version") == 0)
{
std::cout << " Name: " << PROJECT_NAME << '\n';
std::cout << "Version: " << PROJECT_VER << '\n';
return 0;
}

if (strcmp(argv[1], "-c") == 0 || strcmp(argv[1], "--copyright") == 0)
else if (strcmp(argv[1], "-c") == 0 || strcmp(argv[1], "--copyright") == 0)
{
std::string licenseText;
std::ifstream licenseFile("LICENSE");
Expand All @@ -207,9 +204,12 @@ int main(int argc, char* argv[]) {
}
return 0;
}
std::cout << "Sorry, \"" << argv[1] << "\" is not a command!\n";
std::cout << "Please use '--help' for a list of commands\n";
return 1;
else
{
std::cout << "Sorry, \"" << argv[1] << "\" is not a command!\n";
std::cout << "Please use '--help' for a list of commands\n";
return 1;
}
}


Expand Down Expand Up @@ -479,9 +479,11 @@ int main(int argc, char* argv[]) {
std::string mapData;
std::ifstream mapFile;

mapFile.open("data/maps/map.txt", std::ios::in);
mapFile.open(mapFilePath, std::ios::in);
std::cout << "Map file: \"" << mapFilePath;

if (!mapFile) {
std::cout << "\" DOES NOT EXIST!\n";
std::cout << "ERROR::MAP::FILE_NOT_SUCCESFULLY_READ" << std::endl;

std::cout << "Assuming no map passed...\n" << "Using default map...\n" << "\n -- --------------------------------------------------- -- " << std::endl;
Expand All @@ -498,6 +500,8 @@ int main(int argc, char* argv[]) {
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
};
}
else
std::cout << "\"\n";
std::cout << "Map data: \n";
while (std::getline(mapFile, mapData)) {
std::vector<int> row;
Expand Down

0 comments on commit 669113f

Please sign in to comment.