Skip to content

Commit

Permalink
standing corner
Browse files Browse the repository at this point in the history
  • Loading branch information
jonylu7 committed May 30, 2024
1 parent 2e6f9ab commit e6826bc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
12 changes: 9 additions & 3 deletions include/Avatar/Moving.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class Moving {
float m_MovementSpeed = 1.F;
glm::vec2 m_PrevCell;

int m_Corner = 0;

public:
enum class AvatarStandingCorner {
CENTER,
Expand Down Expand Up @@ -55,14 +57,15 @@ class Moving {
if (!m_MovePath.empty()) {
setCurrentDir(m_MovePath.front());
} else {
finishedmovingUpdate();
finishedmovingUpdate(AvatarStandingCorner(m_Corner));
}
}
moveToNextCell();
}

void finishedmovingUpdate() {
moveToCellCorner(AvatarStandingCorner::CENTER);
void finishedmovingUpdate(
AvatarStandingCorner corner = AvatarStandingCorner::CENTER) {
moveToCellCorner(corner);
setCurrentDir(MoveDirection::IDLE);
}

Expand Down Expand Up @@ -90,5 +93,8 @@ class Moving {
}

void setMovementSpeed(float speed) { m_MovementSpeed = speed; }

int getStandingCorner() { return m_Corner; }
void setStandingCorner(int value) { m_Corner = value; }
};
#endif // PRACTICALTOOLSFORSIMPLEDESIGN_MOVING_HPP
1 change: 1 addition & 0 deletions include/Map/Tile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class TileClass {
m_Structure = structure;
}
void pushAvatars(std::shared_ptr<Avatar> avatar) {
avatar->getMoving()->setStandingCorner(m_Avatars.size());
m_Avatars.push_back(avatar);
if (m_Avatars.size() == 4) {
setWalkable(false);
Expand Down
3 changes: 0 additions & 3 deletions src/Map/Tile.cpp

This file was deleted.

0 comments on commit e6826bc

Please sign in to comment.