diff options
-rw-r--r-- | assets/style/classic/bg/bgFarMountain.png | bin | 33711 -> 74188 bytes | |||
-rw-r--r-- | assets/style/classic/bg/grass.png | bin | 128 -> 158 bytes | |||
-rw-r--r-- | assets/style/classic/house1.png | bin | 598 -> 2033 bytes | |||
-rw-r--r-- | brice.dat | 8 | ||||
-rw-r--r-- | main.cpp | 2 | ||||
-rw-r--r-- | src/world.cpp | 142 | ||||
-rw-r--r-- | xcf/goodmtns.xcf | bin | 0 -> 362046 bytes | |||
-rw-r--r-- | xcf/grass.xcf | bin | 0 -> 647 bytes | |||
-rw-r--r-- | xcf/house1.xcf | bin | 0 -> 8452 bytes | |||
-rw-r--r-- | xml/bobshouse.xml | 8 | ||||
-rw-r--r-- | xml/playerSpawnHill1.xml | 6 | ||||
-rw-r--r-- | xml/playerSpawnHill1_Building1.xml | 6 | ||||
-rw-r--r-- | xml/town.xml | 4 |
13 files changed, 53 insertions, 123 deletions
diff --git a/assets/style/classic/bg/bgFarMountain.png b/assets/style/classic/bg/bgFarMountain.png Binary files differindex dc4d682..382f8d6 100644 --- a/assets/style/classic/bg/bgFarMountain.png +++ b/assets/style/classic/bg/bgFarMountain.png diff --git a/assets/style/classic/bg/grass.png b/assets/style/classic/bg/grass.png Binary files differindex e05fb9b..fc49f0b 100644 --- a/assets/style/classic/bg/grass.png +++ b/assets/style/classic/bg/grass.png diff --git a/assets/style/classic/house1.png b/assets/style/classic/house1.png Binary files differindex f5acc24..73cbf74 100644 --- a/assets/style/classic/house1.png +++ b/assets/style/classic/house1.png @@ -1,7 +1,7 @@ 3 -canSprint -1 -canJump -0 Slow 0 +canJump +0 +canSprint +1 @@ -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); diff --git a/src/world.cpp b/src/world.cpp index 2f1a8a6..08c788b 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -19,6 +19,28 @@ #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 Binary files differnew file mode 100644 index 0000000..c6492d5 --- /dev/null +++ b/xcf/goodmtns.xcf diff --git a/xcf/grass.xcf b/xcf/grass.xcf Binary files differnew file mode 100644 index 0000000..95d8d89 --- /dev/null +++ b/xcf/grass.xcf diff --git a/xcf/house1.xcf b/xcf/house1.xcf Binary files differnew file mode 100644 index 0000000..4c40d29 --- /dev/null +++ b/xcf/house1.xcf diff --git a/xml/bobshouse.xml b/xml/bobshouse.xml index 243063d..ebf020b 100644 --- a/xml/bobshouse.xml +++ b/xml/bobshouse.xml @@ -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> diff --git a/xml/playerSpawnHill1.xml b/xml/playerSpawnHill1.xml index e197f2e..3f0e2ce 100644 --- a/xml/playerSpawnHill1.xml +++ b/xml/playerSpawnHill1.xml @@ -16,11 +16,11 @@ <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> diff --git a/xml/playerSpawnHill1_Building1.xml b/xml/playerSpawnHill1_Building1.xml index 5c5dfdc..61b8e16 100644 --- a/xml/playerSpawnHill1_Building1.xml +++ b/xml/playerSpawnHill1_Building1.xml @@ -10,17 +10,17 @@ <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> diff --git a/xml/town.xml b/xml/town.xml index 8d0a0a4..fc5fcd5 100644 --- a/xml/town.xml +++ b/xml/town.xml @@ -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> |