diff options
| author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2021-02-09 20:34:59 -0500 |
|---|---|---|
| committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2021-02-09 20:34:59 -0500 |
| commit | 315ca2fb388f790791c9ce372cf44e00d51e0e7f (patch) | |
| tree | 99fd0a66ce191959c73fe5058e538a4dcd07100e /src/character_system.cpp | |
| parent | 0c2cd251fa0427b19f7c995bc7da7319d2ac80a5 (diff) | |
| download | tanetane-315ca2fb388f790791c9ce372cf44e00d51e0e7f.tar.gz tanetane-315ca2fb388f790791c9ce372cf44e00d51e0e7f.tar.bz2 tanetane-315ca2fb388f790791c9ce372cf44e00d51e0e7f.zip | |
Added trigger zones to the map
Walking into a trigger zone runs a script.
Diffstat (limited to 'src/character_system.cpp')
| -rw-r--r-- | src/character_system.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
| diff --git a/src/character_system.cpp b/src/character_system.cpp index fcd69dd..d4765bf 100644 --- a/src/character_system.cpp +++ b/src/character_system.cpp | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | #include "game.h" | 5 | #include "game.h" |
| 6 | #include "transform_system.h" | 6 | #include "transform_system.h" |
| 7 | #include "animation_system.h" | 7 | #include "animation_system.h" |
| 8 | #include "script_system.h" | ||
| 8 | 9 | ||
| 9 | void CharacterSystem::initSprite(int spriteId) { | 10 | void CharacterSystem::initSprite(int spriteId) { |
| 10 | Sprite& sprite = game_.getSprite(spriteId); | 11 | Sprite& sprite = game_.getSprite(spriteId); |
| @@ -83,10 +84,22 @@ void CharacterSystem::tick(double dt) { | |||
| 83 | 84 | ||
| 84 | if (collision.horiz.blocked) { | 85 | if (collision.horiz.blocked) { |
| 85 | pLoc.x() = sprite.loc.x();//(newColPosDR * map.getTileSize() - (collisionBox / 2)).x() - 1; | 86 | pLoc.x() = sprite.loc.x();//(newColPosDR * map.getTileSize() - (collisionBox / 2)).x() - 1; |
| 87 | } else if (collision.horiz.colliderSprite != -1) { | ||
| 88 | Sprite& collider = game_.getSprite(collision.horiz.colliderSprite); | ||
| 89 | |||
| 90 | if (collider.walkthroughScript != "") { | ||
| 91 | game_.getSystem<ScriptSystem>().runScript(collider.walkthroughScript); | ||
| 92 | } | ||
| 86 | } | 93 | } |
| 87 | 94 | ||
| 88 | if (collision.vert.blocked) { | 95 | if (collision.vert.blocked) { |
| 89 | pLoc.y() = sprite.loc.y();//(newColPosDR * map.getTileSize() - (collisionBox / 2)).x() - 1; | 96 | pLoc.y() = sprite.loc.y();//(newColPosDR * map.getTileSize() - (collisionBox / 2)).x() - 1; |
| 97 | } else if (collision.vert.colliderSprite != -1) { | ||
| 98 | Sprite& collider = game_.getSprite(collision.vert.colliderSprite); | ||
| 99 | |||
| 100 | if (collider.walkthroughScript != "") { | ||
| 101 | game_.getSystem<ScriptSystem>().runScript(collider.walkthroughScript); | ||
| 102 | } | ||
| 90 | } | 103 | } |
| 91 | 104 | ||
| 92 | if (blocked && sprite.characterState == CharacterState::Running) { | 105 | if (blocked && sprite.characterState == CharacterState::Running) { |
