-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMap(deprecated).cpp
More file actions
56 lines (51 loc) · 1.18 KB
/
Copy pathMap(deprecated).cpp
File metadata and controls
56 lines (51 loc) · 1.18 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
#include "Map.hpp"
#include "Game.hpp"
#include <fstream>
#include "TextureManager.hpp"
Map::Map()
{
}
Map::~Map()
{
}
void Map::LoadMap(std::string path, int sizeX, int sizeY)
{
// SDL_Texture *tileset = TextureManager::loadTexture("assets/tile.png");
// for (int y = 0; y < sizeY; y++)
// {
// for (int x = 0; x < sizeX; x++)
// {
// SDL_Rect src, dest;
// src.w = src.h = dest.w = dest.h = 10;
// src.y = 1;
// if (y < 50)
// {
// src.x = 1;
// }
// else
// {
// src.x = 10;
// }
// dest.x = x;
// dest.y = y;
// TextureManager::Draw(tileset, src, dest);
// }
// }
//fdghgfh
char tile;
std::fstream mapFile;
mapFile.open(path);
for (int y = 0; y < sizeY; y++)
{
for (int x = 0; x < sizeX; x++)
{
mapFile.get(tile);
tile -= '0';
if (tile < 0 or tile > 2)
tile = 0;
Game::AddTile(tile, x * 64, y * 64, 64, 64);
mapFile.ignore();
}
}
mapFile.close();
}