summary refs log tree commit diff stats
path: root/src/map.cpp
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2021-02-20 13:19:15 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2021-02-20 13:19:15 -0500
commitca4935cb65325edbd45d4a3aacc921ea9ed9483b (patch)
tree28376ffac0f817fc3f1f7290745e91d603fd59e8 /src/map.cpp
parent996076cf151a27a7a8d278aa4d15b28cfb196c46 (diff)
downloadtanetane-ca4935cb65325edbd45d4a3aacc921ea9ed9483b.tar.gz
tanetane-ca4935cb65325edbd45d4a3aacc921ea9ed9483b.tar.bz2
tanetane-ca4935cb65325edbd45d4a3aacc921ea9ed9483b.zip
Added enclosure zones
A sprite with an enclosure zone will collide with it if it attempts to leave the area defined by the zone. This is used to make sure that wandering sprites don't end up in weird places.
Diffstat (limited to 'src/map.cpp')
-rw-r--r--src/map.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/map.cpp b/src/map.cpp index 7bff071..5845009 100644 --- a/src/map.cpp +++ b/src/map.cpp
@@ -78,6 +78,8 @@ Map::Map(std::string_view name) : name_(name) {
78 p.shadow = property.getBoolValue(); 78 p.shadow = property.getBoolValue();
79 } else if (property.getName() == "wander") { 79 } else if (property.getName() == "wander") {
80 p.wander = property.getBoolValue(); 80 p.wander = property.getBoolValue();
81 } else if (property.getName() == "enclosureZone") {
82 p.enclosureZone = property.getStringValue();
81 } 83 }
82 } 84 }
83 85
@@ -118,6 +120,14 @@ Map::Map(std::string_view name) : name_(name) {
118 } 120 }
119 121
120 prototypes_.push_back(std::move(p)); 122 prototypes_.push_back(std::move(p));
123 } else if (object.getType() == "zone") {
124 Zone z;
125 z.ul.x() = object.getPosition().x;
126 z.ul.y() = object.getPosition().y;
127 z.dr.x() = z.ul.x() + object.getAABB().width;
128 z.dr.y() = z.ul.y() + object.getAABB().height;
129
130 zones_[object.getName()] = std::move(z);
121 } 131 }
122 } 132 }
123 } 133 }