From 0a3ec1862fd479295639a38ab4799e4d36e12c13 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Fri, 12 Feb 2021 00:45:43 -0500 Subject: 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). --- res/maps/map2.tmx | 10 ++++++++-- res/scripts/map2.lua | 20 ++++++++++++++++++++ src/game.cpp | 4 +++- src/map.cpp | 15 +++++++++++++++ 4 files changed, 46 insertions(+), 3 deletions(-) diff --git a/res/maps/map2.tmx b/res/maps/map2.tmx index 43fa850..ee9931c 100644 --- a/res/maps/map2.tmx +++ b/res/maps/map2.tmx @@ -1,5 +1,5 @@ - + @@ -224,7 +224,7 @@ - + @@ -645,6 +645,12 @@ + + + + + + diff --git a/res/scripts/map2.lua b/res/scripts/map2.lua index 1f14b31..1b55072 100644 --- a/res/scripts/map2.lua +++ b/res/scripts/map2.lua @@ -3,3 +3,23 @@ map2 = {} function map2.off_left() ChangeMap("map1", "fromRight") end + +function map2.mailbox1() + StartCutscene() + DisplayMessage("* The mailbox lid is open...\n* Peek inside?", "", SpeakerType.NONE) + ShowChoice("Yes", "No") + WaitForEndOfMessage() + + if GetChoiceSelection() == 0 then + DisplayMessage("* There are lots of postcards inside.\n* Read them?", "", SpeakerType.NONE) + ShowChoice("Yes", "No") + WaitForEndOfMessage() + + if GetChoiceSelection() == 0 then + DisplayMessage("* The boy named Lucas is crying at a grave.\n\f* The boy named Lucas and his dog are loitering in the forest.\n\f* The boy named Lucas is getting into trouble in the mountains.\n\f* The boy named Lucas stole Beanoff from our garden.\n\f* The boy named Lucas is bullying animals.\n\f* The boy named Lucas learned some bad magic.\n\f* The boy named Lucas ......\n\f* The boy named Lucas ......\n\f* The boy named Lucas ......\n\f* The boy named Lucas .........\n\f* The mailbox let out a tremendous scream.", "", SpeakerType.NONE) + WaitForEndOfMessage() + end + end + + HideCutsceneBars() +end 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) { int spriteId = emplaceSprite(p.name); getSystem().initSprite(spriteId, p.pos); getSystem().setUpCollision(spriteId, p.collisionOffset, p.collisionSize, true); - getSystem().initSprite(spriteId, p.animationFilename); + if (!p.animationFilename.empty()) { + getSystem().initSprite(spriteId, p.animationFilename); + } getSprite(spriteId).interactionScript = p.interactionScript; } 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) { } triggers_.push_back(std::move(t)); + } else if (object.getType() == "tileSprite") { + Prototype p; + p.name = object.getName(); + p.pos.x() = std::floor(object.getPosition().x / 16) * 16; + p.pos.y() = std::floor(object.getPosition().y / 16) * 16; + p.collisionOffset = { 0, 0 }; + p.collisionSize = { 16, 16 }; + + for (const tmx::Property& property : object.getProperties()) { + if (property.getName() == "interactionScript") { + p.interactionScript = property.getStringValue(); + } + } + + prototypes_.push_back(std::move(p)); } } } -- cgit 1.4.1