Mario editor: use visitors
This commit is contained in:
+6
-9
@@ -38,7 +38,7 @@ void loadMap(std::shared_ptr<SDLPP::Scene> &scene, std::shared_ptr<SDLPP::Rectan
|
||||
collision = true;
|
||||
}
|
||||
// TODO add modifiers to createTerrainBlock
|
||||
auto obj = createTerrainBlock(id, static_cast<BlockType>(type), renderer, i * BLOCK_SIZE, 1 - (16-j) * BLOCK_SIZE, collision);
|
||||
auto obj = createTerrainBlock(id, static_cast<BlockType>(type), renderer, i, j, collision);
|
||||
if(obj != nullptr)
|
||||
scene->addObject(obj);
|
||||
if(character) {
|
||||
@@ -51,6 +51,7 @@ void loadMap(std::shared_ptr<SDLPP::Scene> &scene, std::shared_ptr<SDLPP::Rectan
|
||||
scene->moveZTop(mario);
|
||||
}
|
||||
|
||||
// editor loader
|
||||
void loadMap(std::shared_ptr<SDLPP::Scene> &scene, const std::string &file, std::shared_ptr<SDLPP::Renderer> &renderer, std::vector<std::array<std::tuple<uint8_t, uint16_t, uint8_t, uint8_t, uint8_t, uint8_t>,16>> &objects) {
|
||||
std::ifstream map_file;
|
||||
map_file.open(file, std::ios::in | std::ios::binary);
|
||||
@@ -81,17 +82,13 @@ void loadMap(std::shared_ptr<SDLPP::Scene> &scene, const std::string &file, std:
|
||||
}
|
||||
}
|
||||
col[j] = {type, id, character_type, character, modifier_type, modifier_data};
|
||||
bool collision = false;
|
||||
if(id == FLOOR_ID) {
|
||||
collision = true;
|
||||
}
|
||||
// TODO add modifiers to createTerrainBlock
|
||||
auto obj = createTerrainBlock(id, static_cast<BlockType>(type), renderer, i * BLOCK_SIZE, 1 - (16-j) * BLOCK_SIZE, collision);
|
||||
if(obj != nullptr)
|
||||
scene->addObject(obj);
|
||||
auto obj = createTerrainBlock(id, static_cast<BlockType>(type), renderer, i, j, true);
|
||||
obj->getCollisions()[0]->setId(EDITOR_TERRAIN_ID);
|
||||
scene->addObject(obj);
|
||||
if(character) {
|
||||
if(character == MARIO_ID) {
|
||||
scene->addObject(createMario(static_cast<BlockType>(character_type), renderer, i * BLOCK_SIZE, 1 - (16-j) * BLOCK_SIZE));
|
||||
scene->addObject(createMario(static_cast<BlockType>(character_type), renderer, i, j));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user