-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathLevel.cpp
61 lines (50 loc) · 874 Bytes
/
Level.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
#include "Level.h"
#include <iostream>
#include <fstream>
#include <Windows.h>
using namespace std;
Level::Level()
{
}
//loadFromFile(filename)
Level::Level(string filename)
{
loadFromFile(filename);
}
Level::~Level()
{
}
//loadfromfile to loadLevel[x][y] - isWall & type
void Level::loadFromFile(string filename)
{
fstream file;
file.open(filename, ios::in);
string str = "Not found level: " + filename;
LPSTR error = const_cast<char *>(str.c_str());
if (!file.is_open())
{
MessageBox(NULL, error, "ERROR", NULL);
return;
}
else
{
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
int tmp;
file >> tmp;
loadLevel[y][x].type = FieldType(tmp);
if (tmp == 0)
{
loadLevel[y][x].isWall = false;
}
else
{
loadLevel[y][x].isWall = true;
}
}//forx
}//fory
}
file.close();
}