Skip to content

Commit

Permalink
Key non-collidable after collection
Browse files Browse the repository at this point in the history
  • Loading branch information
justin-ys committed Dec 27, 2023
1 parent b890707 commit 7c9767f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
5 changes: 3 additions & 2 deletions game/entities/misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ void LevelTransition::on_collide(std::shared_ptr<TileEntity> collider) {
void Key::on_collide(std::shared_ptr<TileEntity> collider) {
std::shared_ptr<Player> player = std::dynamic_pointer_cast<Player>(collider);
if (player) {
isCollidable = false;
Event ev("GAME_KeyCollect");
eventManager->emit(ev);
collectedTimer.reset();
state = KeyState::Collected;
}
collectedTimer.reset();
state = KeyState::Collected;
}

void Key::on_update() {
Expand Down
3 changes: 1 addition & 2 deletions include/levelmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ class TileEntity : public Object, public std::enable_shared_from_this<TileEntity
protected:
std::shared_ptr<LevelMap> world;
public:
// getter/setter
const bool isCollidable;
bool isCollidable;
const Tile* tile = nullptr;
void setTile(Tile* tileObj);
void setParent(std::shared_ptr<TileEntity> ent);
Expand Down

0 comments on commit 7c9767f

Please sign in to comment.