Make everything work

This commit is contained in:
NaiJi ✨ 2020-03-19 18:25:58 +03:00
parent 5d058f3e66
commit fefd6ddf49
3 changed files with 6 additions and 9 deletions

Binary file not shown.

View File

@ -20,12 +20,6 @@ Game::Game()
main_window.create(sf::VideoMode(window_side * 3, window_side * 3), "SFML-Test Application", sf::Style::Default);
main_window.setActive();
level->getCellAt(0, 0)->setHeightShift(15);
level->getCellAt(0, 1)->setHeightShift(10);
current_level = 1;
//loadLevel(current_level);
}
int Game::run()

View File

@ -3,6 +3,7 @@
#include <sstream>
#include <fstream>
#include <algorithm>
#include <iostream>
template<typename D, typename B> // [D]erived - [B]ase
std::unique_ptr<D> static_unique_pointer_cast(std::unique_ptr<B>&& old)
@ -28,6 +29,7 @@ void Level::Map::init(const std::string &map_file_name)
continue;
}
sstr.clear();
sstr.str(cur_line);
switch (cur_section)
{
@ -74,10 +76,11 @@ void Level::Map::readMapSize(std::istringstream &sstr)
void Level::Map::readMapRow(std::istringstream &sstr)
{
data.push_back(Row());
for (int cell_type; sstr >> cell_type;)
data.emplace_back(Row());
int cell_type;
while (sstr >> cell_type)
{
data.back().push_back(default_cells[cell_type]->clone());
data.back().emplace_back(default_cells[cell_type]->clone());
data.back().back()->setPosition(data.size()-1, data.back().size()-1);
}
}