]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
proper game resetting
authorClyne Sullivan <tullivan99@gmail.com>
Thu, 9 Jun 2016 12:29:18 +0000 (08:29 -0400)
committerClyne Sullivan <tullivan99@gmail.com>
Thu, 9 Jun 2016 12:29:18 +0000 (08:29 -0400)
brice.dat
include/brice.hpp
include/coolarray.hpp
main.cpp
src/brice.cpp
src/mob.cpp
xml/playerSpawnHill1.xml
xml/playerSpawnHill1_Building1.xml
xml/playerSpawnHill2.xml

index 4bfeac60c203b4b22f8a89cba605f469d3bf47d2..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
--- a/brice.dat
+++ b/brice.dat
@@ -1,5 +0,0 @@
-2
-canJump
-1
-canSprint
-1
index 5f82fece6906637a44ac717e093210bb067da48a..dc3ea96c795e4b6850f1cd9c70a40b9d2947f9e7 100644 (file)
@@ -11,6 +11,7 @@ namespace game {
        
        bool setValue(const std::string& id, const std::string& value);
 
+       void briceClear(void);
        void briceSave(void);
        void briceLoad(void);
 
index 3e167b78391182dafc1275749f681caba0121cb1..5388aab04a64d53db704a081a470d49916f48a46 100644 (file)
@@ -16,7 +16,7 @@ public:
                _capacity = 0;
        }
 
-       CoolArray(size_t n, const T& value) {
+       CoolArray(size_t n, const T& value=0) {
                buffer = new T[n];
                _size = n;
                _capacity = n;
index fdecea9685344417f7411408cdbbfea87ffcb650..4dac3b8e362cebe27f797624fcaf130421e9c12a 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -260,18 +260,19 @@ int main(int argc, char *argv[])
                for (const auto &xf : xmlFiles) {
                        if (xf[0] != '.') {
                                XMLDocument xmld;
-                               xmld.LoadFile(xf.c_str());
+                               auto file = xmlFolder + xf;
+                               xmld.LoadFile(file.c_str());
 
                                auto xmle = xmld.FirstChildElement("World");
 
-                               if (xmle == nullptr)
+                               if (xmle == nullptr) {
                                        xmle = xmld.FirstChildElement("IndoorWorld");
 
-                               if (xmle == nullptr)
-                                       continue;
+                                       if (xmle == nullptr)
+                                               continue;
+                               }
 
                                xmle = xmle->FirstChildElement();
-                                       std::cout << xmle->Name() << '\n';
                                while (xmle) {
                                        xmle->DeleteAttribute("x");
                                        xmle->DeleteAttribute("y");
@@ -280,9 +281,11 @@ int main(int argc, char *argv[])
                                        xmle->DeleteAttribute("dindex");
                                        xmle = xmle->NextSiblingElement();
                                }
-                               xmld.SaveFile(xf.c_str(), false);
+                               xmld.SaveFile(file.c_str(), false);
                        }
                }
+
+               game::briceClear();
        }
 
        if (currentWorld == nullptr) {
index 07cd05dc8deac330a330daeba05ebcac280350e8..d5ac46dc31a008569db4abeb282b1562b033f3de 100644 (file)
@@ -33,6 +33,12 @@ namespace game {
                }
        }
 
+       void briceClear(void) {
+               std::ofstream out ("brice.dat", std::ios::out);
+               out.close();
+               brice.clear();
+       }
+
        void briceSave(void) {
                std::ofstream out ("brice.dat", std::ios::out | std::ios::binary);
                std::string data = std::to_string(brice.size()) + '\n';
index ed9fbf47b13f15c014d6c4973d8c8cb8c66fe535..7701086c84009723aea75092adbc2417485fa42a 100644 (file)
@@ -350,11 +350,20 @@ void Trigger::act(void)
             xml.LoadFile(currentXML.c_str());
             exml = xml.FirstChildElement("Trigger");
 
-            while(exml->StrAttribute("id") != id)
+            while(exml && exml->StrAttribute("id") != id)
                 exml = exml->NextSiblingElement();
 
             player->vel.x = 0;
 
+                       if (exml == nullptr) {
+                               auto id = xmle->StrAttribute("cid");
+                               if (!id.empty()) {
+                                       game::setValue(id, xmle->StrAttribute("cvalue"));
+                                       game::briceUpdate();
+                               }
+                               return;
+                       }
+
             ui::toggleBlackFast();
             ui::waitForCover();
 
index c5d88d68e584b90bbf87d53b8b4e31d1a975ee10..d7889fc5859afdb114a0fc2ac7f047d3d198e793 100644 (file)
@@ -5,13 +5,13 @@
     <link right="playerSpawnHill2.xml"/>
     <time>12000</time>
     <hill peakx="0" peaky="1000" width="50"/>
-    <rabbit spawnx="300" aggressive="false" maxHealth="100" health="32"/>
-    <bird spawny="500" x="808.80286" y="295.4079" health="1"/>
-    <cat x="0" y="64.496956" alive="1"/>
+    <rabbit spawnx="300" aggressive="false" maxHealth="100"/>
+    <bird spawny="500"/>
+    <cat/>
     <!--<trigger x="-300" id="Test"/>-->
-    <npc name="Ralph" hasDialog="true" spawnx="300" health="1" x="-10.007523" y="65.396942" dindex="2"/>
-    <npc name="Johnny" hasDialog="false" spawnx="300" health="1" x="824.5191" y="71.996918" dindex="0"/>
-    <npc name="Big Dave" hasDialog="true" spawnx="300" health="1" x="377.85727" y="62.197029" dindex="9999"/>
+    <npc name="Ralph" hasDialog="true" spawnx="300"/>
+    <npc name="Johnny" hasDialog="false" spawnx="300"/>
+    <npc name="Big Dave" hasDialog="true" spawnx="300"/>
     <page spawnx="-200" id="assets/pages/gootaGoFast.png" cid="canSprint" cvalue="1"/>
     <page spawnx="-500" id="assets/pages/gootaJump.png" cid="canJump" cvalue="1"/>
     <village name="Big Dave&apos;s bagel emporium! The greatest place on earth!">
@@ -38,14 +38,14 @@ And it wasn't stormy.
 <Dialog name="Ralph">
     <text id="0" nextid="1">
                Hello there! My name is Ralph.
-                                                                                                                                                               <gotox>300</gotox>
+                                                                                                                                                                                                                                                                                                               <gotox>300</gotox>
     </text>
     <text id="1" nextid="2" call="Johnny" callid="0" pause="true">
                You should go talk to my friend Johnny. He's a pretty chill dude.
        </text>
     <text id="2">
                Niice.
-                                                                                                                                                               <quest check="Your First Quest" fail="3"/></text>
+                                                                                                                                                                                                                                                                                                               <quest check="Your First Quest" fail="3"/></text>
     <text id="3">
                Go check out Johnny. He's cool.
        </text>
@@ -54,7 +54,7 @@ And it wasn't stormy.
 <Dialog name="Johnny">
     <text id="0" nextid="1" pause="true">
                Sup bro! Have a quest. To complete it, just go talk to Ralph again.
-                                                                                                                                                               <quest assign="Your First Quest">
+                                                                                                                                                                                                                                                                                                               <quest assign="Your First Quest">
                Dank MayMay,2
                Wood Sword,1
                </quest>
@@ -68,5 +68,5 @@ And it wasn't stormy.
     <text id="0" pause="true">
                Hey friend! It's dangerous out there, here take these!
                Wait, promise you'll stop by my stand in the local market!
-                               <give id="Wood Sword" count="1"/>        <give id="Hunters Bow" count="1"/>        <give id="Crude Arrow" count="110"/>        <give id="Fried Chicken" count="1"/>        <give id="Mossy Torch" count="1"/></text>
+                                                                                                                                                                               <give id="Wood Sword" count="1"/>        <give id="Hunters Bow" count="1"/>        <give id="Crude Arrow" count="110"/>        <give id="Fried Chicken" count="1"/>        <give id="Mossy Torch" count="1"/></text>
 </Dialog>
index 0cf04c1859deffe54628b6f2a5aaec041e46c5fb..800f0077d65373fb8243955dd828a773d125952d 100644 (file)
@@ -1,37 +1,26 @@
 <?xml version="1.0"?>
 <IndoorWorld>
-       <style background="1" bgm="assets/music/theme_jazz.wav" />
-       <link outside="playerSpawnHill1.xml"/>
-
-       <floor width="300" />
-       <floor width="200" start="100" />
-
-       <npc name="Bob" hasDialog="true" floor="2" />
-
+    <style background="1" bgm="assets/music/theme_jazz.wav"/>
+    <link outside="playerSpawnHill1.xml"/>
+    <floor width="300"/>
+    <floor width="200" start="100"/>
+    <npc name="Bob" hasDialog="true" floor="2"/>
 </IndoorWorld>
 
 <Dialog name="Bob">
-       <text id="0" nextid="1" pause="true">
+    <text id="0" nextid="1" pause="true">
                Hey. Have a Dank MayMay :)
-               <give id="Dank MayMay" count="1" />
-       </text>
-
-       <text id="1" nextid="2">
+                                               <give id="Dank MayMay" count="1"/></text>
+    <text id="1" nextid="2">
                What? You want another Dank MayMay?
        </text>
-
-       <text id="2" nextid="3" pause="true">
+    <text id="2" nextid="3" pause="true">
                K.
-               <give id="Dank MayMay" count="1" />
-       </text>
-
-       <text id="3" nextid="4">
+                                               <give id="Dank MayMay" count="1"/></text>
+    <text id="3" nextid="4">
                Well... I'm out of Dank MayMays.
        </text>
-
-       <text id="4">
+    <text id="4">
                Have a sword though.
-               <give id="Wood Sword"  count="1"/>
-       </text>
-
+                                               <give id="Wood Sword" count="1"/></text>
 </Dialog>
index 482908702e0c90c15405e79f79ca638b3ec081bf..c0ef54158918547a1674174f0a0b782210743944 100644 (file)
@@ -1,11 +1,8 @@
 <?xml version="1.0"?>
 <World>
-       <style background="0" bgm="assets/music/embark.wav" folder="assets/style/rustic/"/>
-       <generation type="Random" width="1000" />
-       <structure type="5" inside="playerSpawnHill1_Building1.xml"/>
-
-       <npc name="Swag" x="0" />
-
-       <link left="playerSpawnHill1.xml" />
-
+    <style background="0" bgm="assets/music/embark.wav" folder="assets/style/rustic/"/>
+    <generation type="Random" width="1000"/>
+    <structure type="5" inside="playerSpawnHill1_Building1.xml"/>
+    <npc name="Swag"/>
+    <link left="playerSpawnHill1.xml"/>
 </World>