-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
stairs are now working, we can go lower inside the dungeon!
- Loading branch information
Showing
9 changed files
with
165 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#ifndef PATARO_ACTIONS_FOLLOWSTAIRS_HPP | ||
#define PATARO_ACTIONS_FOLLOWSTAIRS_HPP | ||
|
||
#include <Pataro/Action.hpp> | ||
|
||
namespace pat | ||
{ | ||
class Engine; | ||
class Entity; | ||
|
||
class FollowStairsAction : public Action | ||
{ | ||
public: | ||
enum class Direction | ||
{ | ||
Up, | ||
Down | ||
}; | ||
|
||
/** | ||
* @brief Construct a new Follow Stairs Action object | ||
* | ||
* @param source can only be the player | ||
* @param direction | ||
*/ | ||
FollowStairsAction(Entity* source, Direction direction); | ||
|
||
ActionResult perform(Engine* engine) override; | ||
|
||
private: | ||
Entity* m_source; | ||
Direction m_direction; | ||
}; | ||
} | ||
|
||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#include <Pataro/Actions/FollowStairs.hpp> | ||
|
||
#include <Pataro/Engine.hpp> | ||
#include <Pataro/Entity.hpp> | ||
#include <Pataro/Colors.hpp> | ||
#include <Pataro/Constants.hpp> | ||
|
||
using namespace pat; | ||
|
||
FollowStairsAction::FollowStairsAction(Entity* source, FollowStairsAction::Direction direction) : | ||
m_source(source), m_direction(direction) | ||
{} | ||
|
||
ActionResult FollowStairsAction::perform(Engine* engine) | ||
{ | ||
if (m_source != engine->get_player()) | ||
return ActionResult::Fail; | ||
|
||
Map* map = engine->get_map(); | ||
|
||
switch (m_direction) | ||
{ | ||
case Direction::Up: | ||
if (map->move_upstairs(m_source)) | ||
{ | ||
engine->get_gui()->message(colors::lightBlue, "You moved upstairs"); | ||
if (map->floor() == 0) | ||
engine->get_gui()->message(colors::lightAmber, "You are on the ground floor"); | ||
|
||
int x = m_source->get_x(); | ||
int y = m_source->get_y(); | ||
engine->get_map()->compute_fov(x, y, details::player_fov); | ||
return ActionResult::Success; | ||
} | ||
break; | ||
|
||
case Direction::Down: | ||
if (map->move_downstairs(m_source)) | ||
{ | ||
if (map->is_bottom_floor()) | ||
engine->get_gui()->message(colors::lightAmber, "You have reached the depths of the dungeon"); | ||
else | ||
engine->get_gui()->message(colors::lightBlue, "You moved downstairs"); | ||
|
||
int x = m_source->get_x(); | ||
int y = m_source->get_y(); | ||
engine->get_map()->compute_fov(x, y, details::player_fov); | ||
return ActionResult::Success; | ||
} | ||
break; | ||
} | ||
|
||
return ActionResult::Fail; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters