]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
better textures, fixing indoors
authorClyne Sullivan <tullivan99@gmail.com>
Mon, 27 Jun 2016 18:47:01 +0000 (14:47 -0400)
committerClyne Sullivan <tullivan99@gmail.com>
Mon, 27 Jun 2016 18:47:01 +0000 (14:47 -0400)
13 files changed:
assets/style/classic/bg/bgFarMountain.png
assets/style/classic/bg/grass.png
assets/style/classic/house1.png
brice.dat
main.cpp
src/world.cpp
xcf/goodmtns.xcf [new file with mode: 0644]
xcf/grass.xcf [new file with mode: 0644]
xcf/house1.xcf [new file with mode: 0644]
xml/bobshouse.xml
xml/playerSpawnHill1.xml
xml/playerSpawnHill1_Building1.xml
xml/town.xml

index dc4d6825952d41400f52d025025a0ff0b4ccdd35..382f8d606790955e390d7feded9e5dfd53a52e48 100644 (file)
Binary files a/assets/style/classic/bg/bgFarMountain.png and b/assets/style/classic/bg/bgFarMountain.png differ
index e05fb9b15e87e90e7a14af4a4d428cdc44de21ef..fc49f0bfe4d9faf65184744e624cdd487f51fc1b 100644 (file)
Binary files a/assets/style/classic/bg/grass.png and b/assets/style/classic/bg/grass.png differ
index f5acc2448a9c4b4a63f8413eaf2882841f257dba..73cbf74dec8b9eb87ff1cf1a340e317b6aecf83e 100644 (file)
Binary files a/assets/style/classic/house1.png and b/assets/style/classic/house1.png differ
index 2033bae64b8c312af83dfe1243c6508df9c542aa..4dad7115c21edf220ed1e407b1d7f9f20b430ea0 100644 (file)
--- a/brice.dat
+++ b/brice.dat
@@ -1,7 +1,7 @@
 3
-canSprint
-1
-canJump
-0
 Slow
 0
+canJump
+0
+canSprint
+1
index 72987a3e862b024f57f2ab2d8709a2c8fbbb92d0..fd8ed4d3a498d5044e44c9f083883bcf2dddca72 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -138,7 +138,7 @@ int main(int argc, char *argv[])
        }
 
        // attempt to initialize SDL
-       if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) != 0)
+       if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK) != 0)
                UserError(std::string("SDL was not able to initialize! Error: ") + SDL_GetError());
        atexit(SDL_Quit);
 
index 2f1a8a68c3734ccb7ce6b1ee5120b69940965335..08c788bf880096b2fc4e231073c692a042e72c83 100644 (file)
 #include <tinyxml2.h>
 using namespace tinyxml2;
 
+void makeWorldDrawingSimplerEvenThoughAndyDoesntThinkWeCanMakeItIntoFunctions(
+               unsigned size, void *coordAddr, void *texAddr, unsigned triCount
+       )
+{
+       glVertexAttribPointer(worldShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, size, coordAddr);
+       glVertexAttribPointer(worldShader_attribute_tex  , 2, GL_FLOAT, GL_FALSE, size, texAddr  );
+       glDrawArrays(GL_TRIANGLES, 0, triCount);
+}
+
+void makeWorldDrawingSimplerEvenThoughAndyDoesntThinkWeCanMakeItIntoFunctions_JustDrawThis(
+               unsigned size, void *coordAddr, void *texAddr, unsigned triCount
+       )
+{
+       glEnableVertexAttribArray(worldShader_attribute_coord);
+       glEnableVertexAttribArray(worldShader_attribute_tex);
+
+       makeWorldDrawingSimplerEvenThoughAndyDoesntThinkWeCanMakeItIntoFunctions(size, coordAddr, texAddr, triCount);
+
+       glDisableVertexAttribArray(worldShader_attribute_tex);
+       glDisableVertexAttribArray(worldShader_attribute_coord);
+}
+
 /* ----------------------------------------------------------------------------
 ** Variables section
 ** --------------------------------------------------------------------------*/
@@ -335,16 +357,14 @@ void World::drawBackgrounds(void)
 
     bgTex(0);
        glUniform4f(worldShader_uniform_color, 1.0, 1.0, 1.0, 1.0);
-       glVertexAttribPointer(worldShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, 0, back_tex_coord);
-    glVertexAttribPointer(worldShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, 0, scrolling_tex_coord);
-    glDrawArrays(GL_TRIANGLES, 0 , 6);
+
+
+       makeWorldDrawingSimplerEvenThoughAndyDoesntThinkWeCanMakeItIntoFunctions(0, back_tex_coord, scrolling_tex_coord, 6);
 
        bgTex++;
        glUniform4f(worldShader_uniform_color, 1.0, 1.0, 1.0, 1.3 - static_cast<float>(alpha)/255.0f);
 
-       glVertexAttribPointer(worldShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, 0, fron_tex_coord);
-    glVertexAttribPointer(worldShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, 0, tex_coord);
-    glDrawArrays(GL_TRIANGLES, 0 , 6);
+       makeWorldDrawingSimplerEvenThoughAndyDoesntThinkWeCanMakeItIntoFunctions(0, fron_tex_coord, tex_coord, 6);
 
        // TODO make stars dynamic
        //static GLuint starTex = Texture::genColor(Color(255, 255, 255));
@@ -404,10 +424,7 @@ void World::drawBackgrounds(void)
                //glUniform4f(worldShader_uniform_color, 1.0, 1.0, 1.0, (255.0f - (randGet() % 200 - 100)) / 255.0f);
                glUniform4f(worldShader_uniform_color, 1.0, 1.0, 1.0, 1.3 - static_cast<float>(alpha)/255.0f);
 
-               glVertexAttribPointer(worldShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), &star_coord[0]);
-               glVertexAttribPointer(worldShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), &star_coord[3]);
-               glDrawArrays(GL_TRIANGLES, 0, star.size() * 6);
-
+               makeWorldDrawingSimplerEvenThoughAndyDoesntThinkWeCanMakeItIntoFunctions(5 * sizeof(GLfloat), &star_coord[0], &star_coord[3], star.size() * 6);
        }
 
        glDisableVertexAttribArray(worldShader_attribute_coord);
@@ -452,15 +469,7 @@ void World::drawBackgrounds(void)
     glUseProgram(worldShader);
        glUniform1f(worldShader_uniform_light_impact, 0.01);
 
-    glEnableVertexAttribArray(worldShader_attribute_coord);
-    glEnableVertexAttribArray(worldShader_attribute_tex);
-
-    glVertexAttribPointer(worldShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, 0, &bg_i[0]);
-    glVertexAttribPointer(worldShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, 0, &bg_tx[0]);
-    glDrawArrays(GL_TRIANGLES, 0 , bg_items.size());
-
-    glDisableVertexAttribArray(worldShader_attribute_tex);
-       glDisableVertexAttribArray(worldShader_attribute_coord);
+       makeWorldDrawingSimplerEvenThoughAndyDoesntThinkWeCanMakeItIntoFunctions_JustDrawThis(0, &bg_i[0], &bg_tx[0], bg_items.size());
 
     glUseProgram(0);
 
@@ -499,15 +508,7 @@ void World::drawBackgrounds(void)
         glUseProgram(worldShader);
                glUniform1f(worldShader_uniform_light_impact, 0.075f + (0.2f*i));
 
-        glEnableVertexAttribArray(worldShader_attribute_coord);
-        glEnableVertexAttribArray(worldShader_attribute_tex);
-
-        glVertexAttribPointer(worldShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, 0, &bg_i[0]);
-        glVertexAttribPointer(worldShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, 0, &bg_tx[0]);
-        glDrawArrays(GL_TRIANGLES, 0 , c.size());
-
-        glDisableVertexAttribArray(worldShader_attribute_tex);
-       glDisableVertexAttribArray(worldShader_attribute_coord);
+               makeWorldDrawingSimplerEvenThoughAndyDoesntThinkWeCanMakeItIntoFunctions_JustDrawThis(0, &bg_i[0], &bg_tx[0], c.size());
 
         glUseProgram(0);
        }
@@ -620,15 +621,7 @@ void World::draw(Player *p)
     glUseProgram(worldShader);
        glUniform1f(worldShader_uniform_light_impact, 0.45f);
 
-    glEnableVertexAttribArray(worldShader_attribute_coord);
-    glEnableVertexAttribArray(worldShader_attribute_tex);
-
-    glVertexAttribPointer(worldShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, 0, &dirtc[0]);
-    glVertexAttribPointer(worldShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, 0, &dirtt[0]);
-    glDrawArrays(GL_TRIANGLES, 0 , c.size());
-
-    glDisableVertexAttribArray(worldShader_attribute_tex);
-       glDisableVertexAttribArray(worldShader_attribute_coord);
+       makeWorldDrawingSimplerEvenThoughAndyDoesntThinkWeCanMakeItIntoFunctions_JustDrawThis(0, &dirtc[0], &dirtt[0], c.size());
 
     glUseProgram(0);
 
@@ -705,56 +698,17 @@ void World::draw(Player *p)
     glUseProgram(worldShader);
        glUniform1f(worldShader_uniform_light_impact, 1.0f);
 
-    glEnableVertexAttribArray(worldShader_attribute_coord);
-    glEnableVertexAttribArray(worldShader_attribute_tex);
-
-    glVertexAttribPointer(worldShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, 0, &grassc[0]);
-    glVertexAttribPointer(worldShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, 0, &grasst[0]);
-    glDrawArrays(GL_TRIANGLES, 0 , c.size());
-
-    glDisableVertexAttribArray(worldShader_attribute_tex);
-    glDisableVertexAttribArray(worldShader_attribute_coord);
-
-    glUseProgram(0);
-
-
-       //glUseProgram(0);
-       //glDisable(GL_TEXTURE_2D);
-
-       // draw particles
-
-    glBindTexture(GL_TEXTURE_2D, colorIndex);
-    glUniform1i(worldShader_uniform_texture, 0);
-    glUseProgram(worldShader);
-
-    glEnableVertexAttribArray(worldShader_attribute_coord);
-    glEnableVertexAttribArray(worldShader_attribute_tex);
-
-       /*GLfloat *pIndexT = &partVec[0];
-
-    for (auto &p : particles) {
-        if (!p.behind)
-            p.draw(pIndexT);
-    }
-
-    glVertexAttribPointer(worldShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), &partVec[0]);
-    glVertexAttribPointer(worldShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), &partVec[3]);
-    glDrawArrays(GL_TRIANGLES, 0, ps * 6);
-*/
-    glDisableVertexAttribArray(worldShader_attribute_tex);
-    glDisableVertexAttribArray(worldShader_attribute_coord);
+       makeWorldDrawingSimplerEvenThoughAndyDoesntThinkWeCanMakeItIntoFunctions_JustDrawThis(0, &grassc[0], &grasst[0], c.size());
 
     glUseProgram(0);
 
        // draw the buildings
-       for (auto &b : build) {
+       for (auto &b : build)
         b->draw();
-    }
 
     // draw remaining entities
-       for (auto &n : npc) {
+       for (auto &n : npc)
         n->draw();
-    }
 
        for (auto &m : mob)
                m->draw();
@@ -783,9 +737,6 @@ void World::draw(Player *p)
 
        glUniform4f(worldShader_uniform_color, 1.0, 1.0, 1.0, .8);
 
-    glEnableVertexAttribArray(worldShader_attribute_coord);
-    glEnableVertexAttribArray(worldShader_attribute_tex);
-
        partMutex.lock();
        uint ps = particles.size();
     uint pss = ps * 6 * 5;
@@ -804,12 +755,7 @@ void World::draw(Player *p)
     }
        partMutex.unlock();
 
-    glVertexAttribPointer(worldShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), &partVec[0]);
-    glVertexAttribPointer(worldShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), &partVec[3]);
-    glDrawArrays(GL_TRIANGLES, 0, ps * 6);
-
-    glDisableVertexAttribArray(worldShader_attribute_tex);
-    glDisableVertexAttribArray(worldShader_attribute_coord);
+       makeWorldDrawingSimplerEvenThoughAndyDoesntThinkWeCanMakeItIntoFunctions_JustDrawThis(5 * sizeof(GLfloat), &partVec[0], &partVec[3], ps * 6);
 
        glUniform4f(worldShader_uniform_color, 1.0, 1.0, 1.0, 1.0);
 
@@ -1702,15 +1648,7 @@ draw(Player *p)
                                                          0, 0,
                                                          0, 1};
 
-       glEnableVertexAttribArray(worldShader_attribute_coord);
-       glEnableVertexAttribArray(worldShader_attribute_tex);
-
-       glVertexAttribPointer(worldShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, 0, backTile);
-       glVertexAttribPointer(worldShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, 0, backTile_tex);
-       glDrawArrays(GL_TRIANGLES, 0, 6);
-
-       glDisableVertexAttribArray(worldShader_attribute_coord);
-       glDisableVertexAttribArray(worldShader_attribute_tex);
+       makeWorldDrawingSimplerEvenThoughAndyDoesntThinkWeCanMakeItIntoFunctions_JustDrawThis(0, backTile, backTile_tex, 6);
 
        glUseProgram(0);
 
@@ -1770,15 +1708,7 @@ draw(Player *p)
        }
     }
 
-       glEnableVertexAttribArray(worldShader_attribute_coord);
-       glEnableVertexAttribArray(worldShader_attribute_tex);
-
-       glVertexAttribPointer(worldShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), &f[0]);
-       glVertexAttribPointer(worldShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), &f[3]);
-       glDrawArrays(GL_TRIANGLES, 0, floor.size() * 6);
-
-       glDisableVertexAttribArray(worldShader_attribute_coord);
-       glDisableVertexAttribArray(worldShader_attribute_tex);
+       makeWorldDrawingSimplerEvenThoughAndyDoesntThinkWeCanMakeItIntoFunctions_JustDrawThis(5 * sizeof(GLfloat), &f[0], &f[3], floor.size() * 6);
 
        glUseProgram(0);
 
diff --git a/xcf/goodmtns.xcf b/xcf/goodmtns.xcf
new file mode 100644 (file)
index 0000000..c6492d5
Binary files /dev/null and b/xcf/goodmtns.xcf differ
diff --git a/xcf/grass.xcf b/xcf/grass.xcf
new file mode 100644 (file)
index 0000000..95d8d89
Binary files /dev/null and b/xcf/grass.xcf differ
diff --git a/xcf/house1.xcf b/xcf/house1.xcf
new file mode 100644 (file)
index 0000000..4c40d29
Binary files /dev/null and b/xcf/house1.xcf differ
index 243063dae5a4949d109b74d23b50d0e9dcd1ee68..ebf020bdad917a8d81fef9ab9fe12b3f8052c09d 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0"?>
 <IndoorWorld>
-       <style background="1" bgm="assets/music/embark.wav" folder="assets/style/classic/"/>
-       <floor width="1600"/>
-       <link outside="town.xml"/>
-       <npc name="Bob" hasDialog="false" spawnx="30"/>
+    <style background="1" bgm="assets/music/embark.wav" folder="assets/style/classic/"/>
+    <floor width="1600"/>
+    <link outside="town.xml"/>
+    <npc name="Bob" hasDialog="false" spawnx="30"/>
 </IndoorWorld>
index e197f2e4d4ff6b0973bdb619043f57ffcd06f222..3f0e2ce31c22c4937493e0728f6d2b1ae29591d4 100644 (file)
 <Dialog name="Guy">
     <text id="0" nextid="1">
                Hello there! My name is Ralph.
-                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       <gotox>300</gotox>
+                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               <gotox>300</gotox>
     </text>
     <text id="1">
                ...
-                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       <gotox>1000</gotox>
+                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               <gotox>1000</gotox>
         <set id="Slow" value="0"/>
         <set id="canSprint" value="1"/>
     </text>
@@ -33,5 +33,5 @@
     <text id="0" stop="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 5c5dfdc986796590e6f67c2f4945ad88faaa7183..61b8e163c8324a86a4daa887bf94289446f46f9f 100644 (file)
 <Dialog name="Bob">
     <text id="0" nextid="1" pause="true">
        Hey. Have a Dank MayMay :)
-                                                                                                                                                                                                                                                                                                                                                       <give id="Dank MayMay" count="1"/></text>
+                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       <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">
                K.
-                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   <give id="Dank MayMay" count="1"/></text>
+                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   <give id="Dank MayMay" count="1"/></text>
     <text id="3" nextid="4">
                Well... I'm out of Dank MayMays.
        </text>
     <text id="4">
                Have a sword though.
-                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               <give id="Wood Sword" count="1"/></text>
+                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               <give id="Wood Sword" count="1"/></text>
 </Dialog>
index 8d0a0a400f6218b51afe8bc416da8e7416b42df7..fc5fcd558517d11262f3468745e28156e319706b 100644 (file)
@@ -4,8 +4,8 @@
     <generation type="Random" width="1600"/>
     <time>6000</time>
     <spawnx>-300</spawnx>
-    <npc name="Sanc" hasDialog="true" health="1" x="-316.38254" y="62.999008" dindex="9999"/>
-    <npc name="Bob" hasDialog="true" spawnx="30" health="1" x="262.3949" y="66.698959" dindex="0"/>
+    <npc name="Sanc" hasDialog="true" health="1" x="-215.47046" y="59.999001" dindex="0"/>
+    <npc name="Bob" hasDialog="true" spawnx="30" health="1" x="44.280304" y="60.998985" dindex="0"/>
     <structure type="1" spawnx="300" alive="1"/>
     <structure inside="bobshouse.xml" type="1" spawnx="10" alive="1"/>
 </World>