diff options
| -rw-r--r-- | res/maps/map2.tmx | 10 | ||||
| -rw-r--r-- | res/scripts/map2.lua | 20 | ||||
| -rw-r--r-- | src/game.cpp | 4 | ||||
| -rw-r--r-- | 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 @@ | |||
| 1 | <?xml version="1.0" encoding="UTF-8"?> | 1 | <?xml version="1.0" encoding="UTF-8"?> |
| 2 | <map version="1.4" tiledversion="1.4.3" orientation="orthogonal" renderorder="right-down" width="64" height="64" tilewidth="16" tileheight="16" infinite="0" nextlayerid="3" nextobjectid="4"> | 2 | <map version="1.4" tiledversion="1.4.3" orientation="orthogonal" renderorder="right-down" width="64" height="64" tilewidth="16" tileheight="16" infinite="0" nextlayerid="3" nextobjectid="5"> |
| 3 | <tileset firstgid="1" name="fromRom" tilewidth="16" tileheight="16" tilecount="180" columns="10"> | 3 | <tileset firstgid="1" name="fromRom" tilewidth="16" tileheight="16" tilecount="180" columns="10"> |
| 4 | <image source="map2_tiles.png" width="160" height="288"/> | 4 | <image source="map2_tiles.png" width="160" height="288"/> |
| 5 | <tile id="61"> | 5 | <tile id="61"> |
| @@ -224,7 +224,7 @@ | |||
| 224 | </tile> | 224 | </tile> |
| 225 | <tile id="105"> | 225 | <tile id="105"> |
| 226 | <properties> | 226 | <properties> |
| 227 | <property name="solid" type="bool" value="true"/> | 227 | <property name="solid" type="bool" value="false"/> |
| 228 | </properties> | 228 | </properties> |
| 229 | </tile> | 229 | </tile> |
| 230 | <tile id="106"> | 230 | <tile id="106"> |
| @@ -645,6 +645,12 @@ | |||
| 645 | <property name="script" value="off_left"/> | 645 | <property name="script" value="off_left"/> |
| 646 | </properties> | 646 | </properties> |
| 647 | </object> | 647 | </object> |
| 648 | <object id="4" name="mailbox1" type="tileSprite" x="535" y="118.667"> | ||
| 649 | <properties> | ||
| 650 | <property name="interactionScript" value="mailbox1"/> | ||
| 651 | </properties> | ||
| 652 | <point/> | ||
| 653 | </object> | ||
| 648 | </objectgroup> | 654 | </objectgroup> |
| 649 | <layer id="1" name="Layer 0" width="64" height="64"> | 655 | <layer id="1" name="Layer 0" width="64" height="64"> |
| 650 | <data encoding="csv"> | 656 | <data encoding="csv"> |
| 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 = {} | |||
| 3 | function map2.off_left() | 3 | function map2.off_left() |
| 4 | ChangeMap("map1", "fromRight") | 4 | ChangeMap("map1", "fromRight") |
| 5 | end | 5 | end |
| 6 | |||
| 7 | function map2.mailbox1() | ||
| 8 | StartCutscene() | ||
| 9 | DisplayMessage("* The mailbox lid is open...\n* Peek inside?", "", SpeakerType.NONE) | ||
| 10 | ShowChoice("Yes", "No") | ||
| 11 | WaitForEndOfMessage() | ||
| 12 | |||
| 13 | if GetChoiceSelection() == 0 then | ||
| 14 | DisplayMessage("* There are lots of postcards inside.\n* Read them?", "", SpeakerType.NONE) | ||
| 15 | ShowChoice("Yes", "No") | ||
| 16 | WaitForEndOfMessage() | ||
| 17 | |||
| 18 | if GetChoiceSelection() == 0 then | ||
| 19 | 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) | ||
| 20 | WaitForEndOfMessage() | ||
| 21 | end | ||
| 22 | end | ||
| 23 | |||
| 24 | HideCutsceneBars() | ||
| 25 | 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) { | |||
| 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 | } |
