-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmap.h
67 lines (59 loc) · 2.04 KB
/
map.h
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
#pragma once
#include <SFML\Graphics.hpp>
#include "settings.h"
const int HEIGHT_MAP = 28;
const int WIDTH_MAP = 43;
using namespace sf;
String TileMap[HEIGHT_MAP] = {
"1111111111111111111111111111111111111111111",
"1 1 1 1 1 1",
"1 1 1 1 1 1",
"1 1 11111 11111 1 1",
"1 1 1 1",
"11111 111 111 11111",
"1 111 2222 111 1",
"1 2222 1",
"11111 2222 1111 11111",
"1 2222 1111 1",
"1 2222 1111 1",
"1 2222 1111 1",
"1 1",
"1 2222 1",
"1111111 2222 11111111",
"1 1111 2222 1",
"1 1111 2222 1",
"1 1111 2222 1",
"1 1111 2222 1",
"1 1",
"11111 2222 11111",
"1 222 2222 22 1",
"1 222 22 1",
"1 1 1 1",
"1 1 11111 11111 1 1",
"1 1 1 1 1 1",
"1 1 1 1 1 1",
"1111111111111111111111111111111111111111111",
};
void RenderMap(RenderWindow& window)
{
Image map_image;
map_image.loadFromFile("images/map.png");
Texture map;
map.loadFromImage(map_image);
Sprite s_map;
s_map.setTexture(map);
for (int i = 0; i < HEIGHT_MAP; i++)
for (int j = 0; j < WIDTH_MAP; j++)
{
if (TileMap[i][j] != ' ')
{
s_map.setTextureRect(IntRect(0, 0, 32, 32));
}
else
{
s_map.setTextureRect(IntRect(193, 0, 32, 32));
}
s_map.setPosition(j * TILE, i * TILE);
window.draw(s_map);
}
}