diff options
Diffstat (limited to 'src/components/map_render.cpp')
-rw-r--r-- | src/components/map_render.cpp | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/src/components/map_render.cpp b/src/components/map_render.cpp deleted file mode 100644 index 45766e1..0000000 --- a/src/components/map_render.cpp +++ /dev/null | |||
@@ -1,40 +0,0 @@ | |||
1 | #include "map_render.h" | ||
2 | #include "map.h" | ||
3 | #include "game.h" | ||
4 | #include "consts.h" | ||
5 | |||
6 | MapRenderComponent::MapRenderComponent(const Map& map) : screen(GAME_WIDTH, GAME_HEIGHT) | ||
7 | { | ||
8 | screen.fill(screen.entirety(), 0, 0, 0); | ||
9 | |||
10 | Texture tiles("res/tiles.png"); | ||
11 | |||
12 | for (int i=0; i<MAP_WIDTH*MAP_HEIGHT; i++) | ||
13 | { | ||
14 | int tile = map.getMapdata()[i]; | ||
15 | int x = i % MAP_WIDTH; | ||
16 | int y = i / MAP_WIDTH; | ||
17 | Rectangle dst {x*TILE_WIDTH, y*TILE_HEIGHT, TILE_WIDTH, TILE_HEIGHT}; | ||
18 | Rectangle src {tile%8*TILE_WIDTH, tile/8*TILE_HEIGHT, TILE_WIDTH, TILE_HEIGHT}; | ||
19 | |||
20 | if (tile > 0) | ||
21 | { | ||
22 | screen.blit(tiles, src, dst); | ||
23 | } | ||
24 | } | ||
25 | |||
26 | Texture font("res/font.bmp"); | ||
27 | std::string map_name = map.getTitle(); | ||
28 | int start_x = (40/2) - (map_name.length()/2); | ||
29 | for (size_t i=0; i<map_name.length(); i++) | ||
30 | { | ||
31 | Rectangle srcRect {map_name[i] % 16 * 8, map_name[i] / 16 * 8, 8, 8}; | ||
32 | Rectangle dstRect {(start_x + (int)i)*8, 24*8, 8, 8}; | ||
33 | screen.blit(font, srcRect, dstRect); | ||
34 | } | ||
35 | } | ||
36 | |||
37 | void MapRenderComponent::render(Game&, Entity&, Texture& buffer) | ||
38 | { | ||
39 | buffer.blit(screen, screen.entirety(), buffer.entirety()); | ||
40 | } | ||