summary refs log tree commit diff stats
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
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).
-rw-r--r--res/maps/map2.tmx10
-rw-r--r--res/scripts/map2.lua20
-rw-r--r--src/game.cpp4
-rw-r--r--src/map.cpp15
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 = {}
3function map2.off_left() 3function map2.off_left()
4 ChangeMap("map1", "fromRight") 4 ChangeMap("map1", "fromRight")
5end 5end
6
7function 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()
25end
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 }