]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
inside world work
authorClyne Sullivan <tullivan99@gmail.com>
Tue, 18 Oct 2016 14:49:02 +0000 (10:49 -0400)
committerClyne Sullivan <tullivan99@gmail.com>
Tue, 18 Oct 2016 14:49:02 +0000 (10:49 -0400)
.gitignore
assets/style/classic/bg/bgWoodTile.png
assets/style/classic/bg/insideWoodHouse.png [new file with mode: 0644]
include/common.hpp
include/world.hpp
src/world.cpp
xcf/insideWoodHouse.xcf [new file with mode: 0644]
xml/!town.xml
xml/bobshouse.xml

index a0d00072c61ce79bd6fee1175ed469e2b16b9a5f..43989929c9390e89781d7d1bffcbc0a4625bddd3 100644 (file)
@@ -2,3 +2,6 @@ main
 doc/**\r
 storyXML/*.dat\r
 xml/*.dat\r
+brice.dat\r
+config/settings.xml\r
+setup.mk\r
index 95b0667f6372d08c232bd6800ce0431be4f7bcfd..e10dd1f24b67a702a45bf5b68384b4bd4cbc5d3e 100644 (file)
Binary files a/assets/style/classic/bg/bgWoodTile.png and b/assets/style/classic/bg/bgWoodTile.png differ
diff --git a/assets/style/classic/bg/insideWoodHouse.png b/assets/style/classic/bg/insideWoodHouse.png
new file mode 100644 (file)
index 0000000..47d3918
Binary files /dev/null and b/assets/style/classic/bg/insideWoodHouse.png differ
index 69e6a11f81678d7f020d4161164cee02e71ea5a9..31c8d62b22442602894ff778a45a93e9bb3bc316 100644 (file)
@@ -55,6 +55,8 @@ typedef unsigned int uint;
  */
 #define DEBUG_printf(message, ...) DEBUG_prints(__FILE__, __LINE__, message, __VA_ARGS__)
 
+#define BREAKPOINT __asm__("int $3")
+
 /**
  * Creates a coordinate of integers.
  */
index 4b25e854263ea39e0e1c6ed81b8537f4c0ed3fa0..7dccf1b34c27e262924a8898ddef966cfde45ffe 100644 (file)
@@ -198,6 +198,8 @@ private:
 
 public:
 
+       float HouseWidth;
+
        inline bool isIndoor(void) const
        { return m_Indoor; }
 
index 11132703f109eee6d81baaeb3abde89074fe259a..816b280e5b2b146bf754f30e21a9d0bef50cd031 100644 (file)
@@ -77,25 +77,16 @@ std::string currentXML;
 static std::vector<WorldSwitchInfo> arenaNest;
 
 // pathnames of images for world themes
-constexpr const unsigned int BG_PATHS_ENTRY_SIZE = 9;
-static const std::string bgPaths[][BG_PATHS_ENTRY_SIZE] = {
-    {"bg.png",                                 // Daytime background
-     "bgn.png",                                        // Nighttime background
-     "bgFarMountain.png",              // Furthest layer
-     "forestTileFar.png",              // Furthest away Tree Layer
-     "forestTileBack.png",             // Closer layer
-     "forestTileMid.png",              // Near layer
-     "forestTileFront.png",            // Closest layer
-     "dirt.png",                               // Dirt
-     "grass.png"},                             // Grass
-    {"bgWoodTile.png",
-     "bgWoodTile.png",
-     "bgWoodTile.png",
-     "bgWoodTile.png",
-     "bgWoodTile.png",
-     "bgWoodTile.png",
-     "bgWoodTile.png",
-     "bgWoodTile.png"}
+static const std::string bgPaths[] = {
+    "bg.png",                                  // Daytime background
+    "bgn.png",                                 // Nighttime background
+    "bgFarMountain.png",               // Furthest layer
+    "forestTileFar.png",               // Furthest away Tree Layer
+    "forestTileBack.png",              // Closer layer
+    "forestTileMid.png",               // Near layer
+    "forestTileFront.png",             // Closest layer
+    "dirt.png",                                        // Dirt
+    "grass.png",                               // Grass
 };
 
 // pathnames of structure textures
@@ -195,9 +186,9 @@ generate(int width)
     auto wditer = std::begin(worldData) + GROUND_HILLINESS;
 
        if (m_Indoor) {
-               for(; wditer < std::end(worldData); wditer++) {
+               for(wditer = std::begin(worldData); wditer < std::end(worldData); wditer++) {
                        auto w = &*(wditer);
-                       w->groundHeight = 100;
+                       w->groundHeight = GROUND_HEIGHT_MINIMUM + 5;
                        w->groundColor = 4;
                }
        } else {
@@ -961,19 +952,14 @@ loadWorldFromXMLNoSave(std::string path) {
 
         // world generation (for outdoor areas)
         else if (name == "generation") {
-            // random gen.
-                       if (!Indoor && wxml->StrAttribute("type") == "Random")
-                               tmp->generate(wxml->UnsignedAttribute("width") / game::HLINE);
-            else {
-                if (Indoor)
-                    UserError("XML Error: <generation> tags can't be in <IndoorWorld> tags, use <floor> instead (in " + _currentXML + ")!");
-                else
-                    UserError("XML Error: Invalid <generation> tag in " + _currentXML + "!");
-            }
+                       tmp->generate(wxml->UnsignedAttribute("width") / game::HLINE);
                }
 
-               else if (name == "floor" && tmp->isIndoor()) {
-                       tmp->generate(wxml->UnsignedAttribute("width") / game::HLINE);
+               else if (name == "house") {
+                       if (Indoor)
+                               tmp->HouseWidth = wxml->FloatAttribute("width");
+                       else
+                               UserError("<house> can only be used with indoor worlds");
                }
 
                // weather tags
@@ -1423,30 +1409,47 @@ void WorldSystem::render(void)
        // draw the remaining layers
        for (unsigned int i = 0; i < 4; i++) {
                bgTex++;
-        dim2 dim = bgTex.getTextureDim();
+               auto dim = bgTex.getTextureDim();
                auto xcoord = offset.x * bgDraw[i][2];
 
                bg_items.clear();
                bg_tex.clear();
 
-               for (int j = worldStart; j <= -worldStart; j += dim.x) {
-            bg_items.emplace_back(j         + xcoord, GROUND_HEIGHT_MINIMUM,           7-(i*.1));
-            bg_items.emplace_back(j + dim.x + xcoord, GROUND_HEIGHT_MINIMUM,           7-(i*.1));
-            bg_items.emplace_back(j + dim.x + xcoord, GROUND_HEIGHT_MINIMUM + dim.y, 7-(i*.1));
-
-            bg_items.emplace_back(j + dim.x + xcoord, GROUND_HEIGHT_MINIMUM + dim.y, 7-(i*.1));
-            bg_items.emplace_back(j         + xcoord, GROUND_HEIGHT_MINIMUM + dim.y, 7-(i*.1));
-            bg_items.emplace_back(j         + xcoord, GROUND_HEIGHT_MINIMUM,           7-(i*.1));
+               if (world->isIndoor() && i == 3) {
+                       static const GLuint tex = Texture::loadTexture(world->styleFolder + "insideWoodHouse.png");
+                       static const auto dimm = Texture::imageDim(world->styleFolder + "insideWoodHouse.png");
+                       glBindTexture(GL_TEXTURE_2D, tex);
+
+                       bg_items.emplace_back(worldStart, GROUND_HEIGHT_MINIMUM, 7-(i*.1));
+               bg_items.emplace_back(worldStart + world->HouseWidth, GROUND_HEIGHT_MINIMUM,    7-(i*.1));
+               bg_items.emplace_back(worldStart + world->HouseWidth, GROUND_HEIGHT_MINIMUM + dimm.y, 7-(i*.1));
+
+               bg_items.emplace_back(worldStart + world->HouseWidth, GROUND_HEIGHT_MINIMUM + dimm.y, 7-(i*.1));
+               bg_items.emplace_back(worldStart, GROUND_HEIGHT_MINIMUM + dimm.y, 7-(i*.1));
+               bg_items.emplace_back(worldStart, GROUND_HEIGHT_MINIMUM,        7-(i*.1));
+               } else {
+                       for (int j = worldStart; j <= -worldStart; j += dim.x) {
+                   bg_items.emplace_back(j         + xcoord, GROUND_HEIGHT_MINIMUM,            7-(i*.1));
+                   bg_items.emplace_back(j + dim.x + xcoord, GROUND_HEIGHT_MINIMUM,            7-(i*.1));
+                   bg_items.emplace_back(j + dim.x + xcoord, GROUND_HEIGHT_MINIMUM + dim.y, 7-(i*.1));
+
+                   bg_items.emplace_back(j + dim.x + xcoord, GROUND_HEIGHT_MINIMUM + dim.y, 7-(i*.1));
+                   bg_items.emplace_back(j         + xcoord, GROUND_HEIGHT_MINIMUM + dim.y, 7-(i*.1));
+                   bg_items.emplace_back(j         + xcoord, GROUND_HEIGHT_MINIMUM,            7-(i*.1));
+                       }
                }
 
-        for (uint i = 0; i < bg_items.size()/6; i++) {
-            for (auto &v : bg_tex_coord)
-                bg_tex.push_back(v);
-        }
+           for (uint i = 0; i < bg_items.size()/6; i++) {
+                       for (auto &v : bg_tex_coord)
+                               bg_tex.push_back(v);
+               }
 
         Render::worldShader.use();
                glUniform1f(Render::worldShader.uniform[WU_light_impact], 0.075f + (0.2f*i));
 
+           glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+           glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+
                makeWorldDrawingSimplerEvenThoughAndyDoesntThinkWeCanMakeItIntoFunctions_JustDrawThis(0, bg_items.data(), &bg_tex[0], bg_items.size());
 
         Render::worldShader.unuse();
@@ -1572,6 +1575,14 @@ void WorldSystem::render(void)
 
        Render::worldShader.disable();
                Render::worldShader.unuse();
+       } else {
+               Render::useShader(&Render::worldShader);
+               Render::worldShader.use();
+               static const GLuint rug = Texture::genColor(Color {255, 0, 0});
+               glBindTexture(GL_TEXTURE_2D, rug);
+               vec2 ll = vec2 {worldStart, GROUND_HEIGHT_MINIMUM};
+               Render::drawRect(ll, vec2 {ll.x + world->HouseWidth, ll.y + 4}, -3);
+               Render::worldShader.unuse();
        }
 
        player->draw();
@@ -1582,8 +1593,11 @@ void WorldSystem::setWorld(World *w)
        world = w;
 
        bgFiles.clear();
-       for (const auto &s : bgPaths[(int)w->bgType])
-               bgFiles.push_back(w->styleFolder + s);
+
+       for (int i = 0; i < 9; i++) { 
+               int idx = /*((int)w->bgType * 9) +*/ i;
+               bgFiles.push_back(w->styleFolder + bgPaths[idx]);
+       }
 
        bgTex = TextureIterator(bgFiles);
 }
diff --git a/xcf/insideWoodHouse.xcf b/xcf/insideWoodHouse.xcf
new file mode 100644 (file)
index 0000000..f08dff8
Binary files /dev/null and b/xcf/insideWoodHouse.xcf differ
index 12cc438aa10ed32bb3d788d5db76c5905abc2a44..9d0838b80187e7ba68db32143fcaaadc37d8d973 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0"?>
 <World>
     <style background="0" bgm="assets/music/embark.wav" folder="assets/style/classic/"/>
-    <generation type="Random" width="1600"/>
+    <generation width="1600"/>
     <time>6000</time>
     <spawnx>-300</spawnx>
     <npc name="Sanc" hasDialog="true" health="1" x="23.971899" y="59.998001" dindex="9999"/>
index 87ad9b6fdbaefbec24087fb7b1f5a478e16ae407..43644ca3b8875602d135e0a37c6620e0c09ee3a4 100644 (file)
@@ -1,7 +1,8 @@
 <?xml version="1.0"?>
 <IndoorWorld>
     <style background="1" bgm="assets/music/theme_jazz.wav" folder="assets/style/classic/"/>
-    <floor width="1600"/>
+       <house width="800" />
+       <generation width="1600" />     
     <link outside="town.xml"/>
     <npc name="Bob" hasDialog="false" spawnx="30"/>
 </IndoorWorld>