Add setter for teleport coordinates

This commit is contained in:
NaiJi ✨ 2020-03-16 17:38:04 +03:00
parent 05826aeb3c
commit 7571b6a670
2 changed files with 12 additions and 4 deletions

View File

@ -111,8 +111,8 @@ bool ExitCell::onMovingTo(HeroPtr &hero, LevelPtr &level)
TeleportCell::TeleportCell(coordinate cell_row, coordinate cell_col, coordinate new_cell_row, coordinate new_cell_col, const sf::Color &color) : TeleportCell::TeleportCell(coordinate cell_row, coordinate cell_col, coordinate new_cell_row, coordinate new_cell_col, const sf::Color &color) :
Cell(cell_row, cell_col, color), Cell(cell_row, cell_col, color),
new_x(new_cell_row), new_row(new_cell_row),
new_y(new_cell_col) new_col(new_cell_col)
{} {}
TeleportCell::~TeleportCell() TeleportCell::~TeleportCell()
@ -123,10 +123,16 @@ bool TeleportCell::onMovingTo(HeroPtr &hero, LevelPtr &level)
UNUSED(level); UNUSED(level);
// Hero jumps into teleport! // Hero jumps into teleport!
hero->setPosition(new_x, new_y); hero->setPosition(new_row, new_col);
return true; return true;
} }
void TeleportCell::setDestination(coordinate new_cell_row, coordinate new_cell_col)
{
new_row = new_cell_row;
new_col = new_cell_col;
}
/////////////////////////////////////// ///////////////////////////////////////
TriggerCell::TriggerCell(/*std::vector<CellPtr> &&cells_to_change,*/ coordinate cell_row, coordinate cell_col, const sf::Color &color) : TriggerCell::TriggerCell(/*std::vector<CellPtr> &&cells_to_change,*/ coordinate cell_row, coordinate cell_col, const sf::Color &color) :

View File

@ -149,7 +149,7 @@ public:
class TeleportCell : public Cell class TeleportCell : public Cell
{ {
private: private:
coordinate new_x, new_y; coordinate new_row, new_col;
public: public:
TeleportCell(coordinate cell_row = 0, TeleportCell(coordinate cell_row = 0,
@ -159,6 +159,8 @@ public:
const sf::Color &color = palette::Purple); const sf::Color &color = palette::Purple);
virtual ~TeleportCell() override; virtual ~TeleportCell() override;
void setDestination(coordinate new_cell_row, coordinate new_cell_col);
virtual bool onMovingTo(HeroPtr &hero, LevelPtr &level) override; virtual bool onMovingTo(HeroPtr &hero, LevelPtr &level) override;
}; };