-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTileManager.cpp
More file actions
34 lines (28 loc) · 1.21 KB
/
Copy pathTileManager.cpp
File metadata and controls
34 lines (28 loc) · 1.21 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
//
// Created by luniminex on 10/7/23.
//
#include "TileManager.h"
void TileManager::LoadTiles(const std::string &folderPath) {
textures_ = FileHandler::LoadTextures(folderPath);
std::map<int, std::map<int, std::vector<int>>> rules = FileHandler::LoadRules(folderPath);
CreateTiles(rules);
}
void TileManager::CreateTiles(std::map<int, std::map<int, std::vector<int>>>& rules) {
for(const auto& textureIdx : rules){
for(const auto& rotationIdx : textureIdx.second){
TextureTile tx = {textureIdx.first, rotationIdx.first, rotationIdx.second};
uniqueTextureTiles_.emplace_back(tx);
}
}
}
std::vector<TextureTile> &TileManager::GetTextureTiles() {
return uniqueTextureTiles_;
}
void TileManager::DrawTile(SDL_Renderer* renderer, int textureIdx, int rotation, SDL_Point pos, int size) {
textures_.at(textureIdx)->RenderTextureAt(pos.x, pos.y,
size, size,
renderer, nullptr,
static_cast<double>(rotation) * 90.f,
nullptr,
SDL_FLIP_NONE);
}