From 7571b6a670c101f0ea6520220545b454c42550e9 Mon Sep 17 00:00:00 2001 From: NaiJi Date: Mon, 16 Mar 2020 17:38:04 +0300 Subject: [PATCH] Add setter for teleport coordinates --- src/cell.cpp | 12 +++++++++--- src/cell.h | 4 +++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/cell.cpp b/src/cell.cpp index c50376d..6e42301 100644 --- a/src/cell.cpp +++ b/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) : Cell(cell_row, cell_col, color), - new_x(new_cell_row), - new_y(new_cell_col) + new_row(new_cell_row), + new_col(new_cell_col) {} TeleportCell::~TeleportCell() @@ -123,10 +123,16 @@ bool TeleportCell::onMovingTo(HeroPtr &hero, LevelPtr &level) UNUSED(level); // Hero jumps into teleport! - hero->setPosition(new_x, new_y); + hero->setPosition(new_row, new_col); 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 &&cells_to_change,*/ coordinate cell_row, coordinate cell_col, const sf::Color &color) : diff --git a/src/cell.h b/src/cell.h index f2c0086..3c84279 100644 --- a/src/cell.h +++ b/src/cell.h @@ -149,7 +149,7 @@ public: class TeleportCell : public Cell { private: - coordinate new_x, new_y; + coordinate new_row, new_col; public: TeleportCell(coordinate cell_row = 0, @@ -159,6 +159,8 @@ public: const sf::Color &color = palette::Purple); virtual ~TeleportCell() override; + + void setDestination(coordinate new_cell_row, coordinate new_cell_col); virtual bool onMovingTo(HeroPtr &hero, LevelPtr &level) override; };