-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMazeAlgorithmText.cpp
More file actions
46 lines (43 loc) · 1.07 KB
/
Copy pathMazeAlgorithmText.cpp
File metadata and controls
46 lines (43 loc) · 1.07 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
#include "MazeAlgorithmText.h"
#include <iostream>
#include <fstream>
#include "Wall.h"
using namespace std;
MazeAlgorithmText::MazeAlgorithmText(string mazeFile)
{
fileForMaze = mazeFile;
}
void MazeAlgorithmText::genMaze(CollideableContainer * cc)
{
int count = 0;
//cout << "Generating maze with filepath: " << fileForMaze << endl;
string line;
ifstream mazeFile(fileForMaze.c_str());
if(mazeFile.is_open())
{
while(getline(mazeFile,line))
{
//cout << line << endl;
//cout << cc->collideableFieldPtr->size() << endl;
if(cc->collideableFieldPtr->size() <= count)
{
cc->collideableFieldPtr->push_back(new vector<Collideable *>);
}
vector<Collideable *> * currentRow = cc->collideableFieldPtr->at(count);
for(int i = 0; i < line.length(); ++i)
{
if(currentRow->size() <= i)
{
currentRow->push_back(0);
}
if(line[i] == '#')
{
//This is the symbol indicating a wall, so we will create a wall in our vector
currentRow->at(i) = new Wall();
}
}
cc->collideableFieldPtr->at(count) = currentRow;
count++;
}
}
}