From ca4935cb65325edbd45d4a3aacc921ea9ed9483b Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sat, 20 Feb 2021 13:19:15 -0500 Subject: 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. --- src/map.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/map.cpp') 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) { p.shadow = property.getBoolValue(); } else if (property.getName() == "wander") { p.wander = property.getBoolValue(); + } else if (property.getName() == "enclosureZone") { + p.enclosureZone = property.getStringValue(); } } @@ -118,6 +120,14 @@ Map::Map(std::string_view name) : name_(name) { } prototypes_.push_back(std::move(p)); + } else if (object.getType() == "zone") { + Zone z; + z.ul.x() = object.getPosition().x; + z.ul.y() = object.getPosition().y; + z.dr.x() = z.ul.x() + object.getAABB().width; + z.dr.y() = z.ul.y() + object.getAABB().height; + + zones_[object.getName()] = std::move(z); } } } -- cgit 1.4.1