summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2021-02-12 00:45:43 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2021-02-12 00:45:43 -0500
commit0a3ec1862fd479295639a38ab4799e4d36e12c13 (patch)
tree8651ccafcae9d53fb63234e089158a7cb29c278c /src
parent5ecd0f428dd8292a17c5013c525a4f5d3967acb8 (diff)
downloadtanetane-0a3ec1862fd479295639a38ab4799e4d36e12c13.tar.gz
tanetane-0a3ec1862fd479295639a38ab4799e4d36e12c13.tar.bz2
tanetane-0a3ec1862fd479295639a38ab4799e4d36e12c13.zip
Added tile-sized invisible sprites
These are used when you want a solid, interactable object that is part of the map instead of sprite animated (e.g. the mailboxes).
Diffstat (limited to 'src')
-rw-r--r--src/game.cpp4
-rw-r--r--src/map.cpp15
2 files changed, 18 insertions, 1 deletions
diff --git a/src/game.cpp b/src/game.cpp index 8b6ef8f..fcd5f44 100644 --- a/src/game.cpp +++ b/src/game.cpp
@@ -59,7 +59,9 @@ void Game::loadMap(std::string filename, std::string warpPoint, Direction dir) {
59 int spriteId = emplaceSprite(p.name); 59 int spriteId = emplaceSprite(p.name);
60 getSystem<TransformSystem>().initSprite(spriteId, p.pos); 60 getSystem<TransformSystem>().initSprite(spriteId, p.pos);
61 getSystem<TransformSystem>().setUpCollision(spriteId, p.collisionOffset, p.collisionSize, true); 61 getSystem<TransformSystem>().setUpCollision(spriteId, p.collisionOffset, p.collisionSize, true);
62 getSystem<AnimationSystem>().initSprite(spriteId, p.animationFilename); 62 if (!p.animationFilename.empty()) {
63 getSystem<AnimationSystem>().initSprite(spriteId, p.animationFilename);
64 }
63 getSprite(spriteId).interactionScript = p.interactionScript; 65 getSprite(spriteId).interactionScript = p.interactionScript;
64 } 66 }
65 67
diff --git a/src/map.cpp b/src/map.cpp index 8d4aa2d..da382fd 100644 --- a/src/map.cpp +++ b/src/map.cpp
@@ -99,6 +99,21 @@ Map::Map(std::string_view name) : name_(name) {
99 } 99 }
100 100
101 triggers_.push_back(std::move(t)); 101 triggers_.push_back(std::move(t));
102 } else if (object.getType() == "tileSprite") {
103 Prototype p;
104 p.name = object.getName();
105 p.pos.x() = std::floor(object.getPosition().x / 16) * 16;
106 p.pos.y() = std::floor(object.getPosition().y / 16) * 16;
107 p.collisionOffset = { 0, 0 };
108 p.collisionSize = { 16, 16 };
109
110 for (const tmx::Property& property : object.getProperties()) {
111 if (property.getName() == "interactionScript") {
112 p.interactionScript = property.getStringValue();
113 }
114 }
115
116 prototypes_.push_back(std::move(p));
102 } 117 }
103 } 118 }
104 } 119 }