-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
67 lines (58 loc) · 1.34 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <iostream>
#include <utility>
#include "World.h"
using namespace std;
int main(int argc, char** argv)
{
int numRobots = 1;
int numLights = 1;
bool attract = true;
if (argc > 1)
{
for (int i = 1; i < argc; i++)
{
if (string(argv[i]) == "-r")
{
numRobots = atoi(argv[i + 1]);
}
if (string(argv[i]) == "-l")
{
numLights = atoi(argv[i + 1]);
}
if (string(argv[i]) == "--attract")
{
attract = true;
}
if (string(argv[i]) == "--avoid")
{
attract = false;
}
}
}
srand(time(NULL));
vector<pair<int, int>> lightPositions;
for (int i = 0; i < numLights; i++)
{
pair<int, int> light(rand() % 800, rand() % 600);
lightPositions.push_back(light);
}
World world(lightPositions, attract);
for (int i = 0 ; i < numRobots; i++)
{
world.addRobot(rand() % 800, rand() % 600, 20, 20);
}
//initialize SDL
if (SDL_Init(SDL_INIT_VIDEO) < 0)
{
cout << "SDL init error: " << SDL_GetError() << endl;
}
else
{
world.initVideo();
}
for (;;)
{
world.updateWorld();
world.renderLightMap();
}
}