-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
42 lines (39 loc) · 1.42 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
Copyright (C) 2016 Meritxell Jordana
Copyright (C) 2016 Marc Sanchez
*/
#include "map.h"
#include "mapgenerator.h"
#include "graphic.h"
#include <iostream>
#include <stdlib.h>
#include <string.h>
using namespace std;
int main(int argc, char **argv) {
if (argc < 3) {
cout << "Use: " << argv[0] << " <nRows> <nCols> [--training]" << endl;
return 1;
}
int graphicWidth = atoi(argv[2]) * Graphic::cellWidth;
int graphicHeight = atoi(argv[1]) * Graphic::cellHeight;
Graphic& g = Graphic::getInstance();
if (argc >= 4 && strcmp(argv[3], "--training") == 0) {
g.setTraining(true);
}
g.glutInitialize(&argc, argv);
if (graphicWidth > g.getScreenWidth() || graphicHeight > g.getScreenHeight()
|| atoi(argv[1]) < Map::minRows || atoi(argv[2]) < Map::minCols) {
cout << "ERROR: Incorrect map dimmensions!" << endl;
cout << "Use: " << argv[0] << " <nRows> <nCols>" << endl;
cout << " <nRows> must be between [" << Map::minRows << ", "
<< g.getScreenHeight() / Graphic::cellHeight << "]" << endl;
cout << " <nCols> must be between [" << Map::minCols << ", "
<< g.getScreenWidth() / Graphic::cellWidth << "]" << endl;
exit(1);
}
g.setGlutDimensions(graphicWidth, graphicHeight);
Map map = MapGenerator(atoi(argv[1]), atoi(argv[2])).getMap();
g.setMap(map);
g.glutRun();
return 0;
}