-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
69 lines (59 loc) · 1.41 KB
/
main.cpp
File metadata and controls
69 lines (59 loc) · 1.41 KB
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
68
69
#include <iostream>
#include "SDL2/SDL.h"
#include "rsdl.hpp"
#include "mgolf.hpp"
#include "ball.hpp"
#include "wall.hpp"
#include "area.hpp"
#include "distance.hpp"
#include "pointholder.hpp"
#include "hole.hpp"
#include "utils.hpp"
#include <math.h>
#include <vector>
#include <string>
#include <fstream>
#include <sstream>
#include <stdlib.h>
using namespace std;
const vector<string> commands = {"window_size", "normal_area",
"sand_area", "water_area", "ball", "hole", "sharp_wall", "wall"};
int whatIsTheCommand(string cmd) {
int position{0};
for(string c : commands){
if(c == cmd){
break;
}
position++;
}
return position;
}
vector<string> split(string str){
stringstream line(str);
vector<string> result;
string tempStr;
while (getline(line, tempStr, ' ')) {
result.push_back(tempStr);
}
return result;
}
void getTheCommand(string map,MiniGolf* mini){
fstream inputFile(map);
vector<string> readFile;
string lineHolder;
while(getline(inputFile, lineHolder)){
vector<string> cmdArgs = split(lineHolder);
int command = whatIsTheCommand(cmdArgs[0]);
mini->runTheCommand(command, cmdArgs);
}
}
int main(int argc, char* argv[]){
string map = argv[1];
MiniGolf mini;
getTheCommand(map, &mini);
while(true){
mini.update();
mini.draw();
delay(50);
}
}