Add setter for teleport coordinates
This commit is contained in:
parent
05826aeb3c
commit
7571b6a670
12
src/cell.cpp
12
src/cell.cpp
|
@ -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) :
|
||||||
|
|
|
@ -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;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue