-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModuleReadFile.cpp
More file actions
63 lines (47 loc) · 1 KB
/
ModuleReadFile.cpp
File metadata and controls
63 lines (47 loc) · 1 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
#include "Globals.h"
#include "Application.h"
#include "ModuleReadFile.h"
#include <fstream>
#include <iostream>
ModuleReadFile::ModuleReadFile()
{
}
ModuleReadFile::~ModuleReadFile()
{
}
int* ModuleReadFile::readHeightMap(const std::string path)
{
std::ifstream file(path);
std::string value;
int* heightMap = new int[SCREEN_HEIGHT*SCREEN_WIDTH];
std::fill_n(heightMap, SCREEN_HEIGHT*SCREEN_WIDTH, 5);
unsigned long counter = 0;
while (!file.eof())
{
getline(file, value, ',');
if (value != "5")
{
heightMap[counter] = stoi(value);
}
++counter;
}
return heightMap;
}
int* ModuleReadFile::readTextureMap(const std::string path)
{
std::ifstream file(path);
std::string value;
int* textureMap = new int[SCREEN_HEIGHT*SCREEN_WIDTH];
memset(textureMap, 0, sizeof(int)*(SCREEN_HEIGHT*SCREEN_WIDTH));
unsigned long counter = 0;
while (!file.eof())
{
getline(file, value, ',');
if (value != "0")
{
textureMap[counter] = stoi(value);
}
++counter;
}
return textureMap;
}