diff options
author | drumsetmonkey <abelleisle@roadrunner.com> | 2016-04-06 07:38:59 -0400 |
---|---|---|
committer | drumsetmonkey <abelleisle@roadrunner.com> | 2016-04-06 07:38:59 -0400 |
commit | 3ca4cca09ed9a2b1028928dea98f19bd26ab3b2c (patch) | |
tree | f8444f987be86181786859c2aabdd2d7eb2a5539 | |
parent | b2ea70a36ba2249383c9b5cb3c2c784c28311938 (diff) |
First world and style
23 files changed, 54 insertions, 22 deletions
diff --git a/assets/style/farming/bg/bagels.jpg b/assets/style/farming/bg/bagels.jpg Binary files differnew file mode 100644 index 0000000..fb68d2e --- /dev/null +++ b/assets/style/farming/bg/bagels.jpg diff --git a/assets/style/farming/bg/bagels.png b/assets/style/farming/bg/bagels.png Binary files differnew file mode 100644 index 0000000..2ee843b --- /dev/null +++ b/assets/style/farming/bg/bagels.png diff --git a/assets/style/farming/bg/bg.png b/assets/style/farming/bg/bg.png Binary files differnew file mode 100644 index 0000000..2dbc3f9 --- /dev/null +++ b/assets/style/farming/bg/bg.png diff --git a/assets/style/farming/bg/bgFarMountain.png b/assets/style/farming/bg/bgFarMountain.png Binary files differnew file mode 100644 index 0000000..eb703bb --- /dev/null +++ b/assets/style/farming/bg/bgFarMountain.png diff --git a/assets/style/farming/bg/bgWoodTile.png b/assets/style/farming/bg/bgWoodTile.png Binary files differnew file mode 100644 index 0000000..95b0667 --- /dev/null +++ b/assets/style/farming/bg/bgWoodTile.png diff --git a/assets/style/farming/bg/bgb.png b/assets/style/farming/bg/bgb.png Binary files differnew file mode 100644 index 0000000..278e9b0 --- /dev/null +++ b/assets/style/farming/bg/bgb.png diff --git a/assets/style/farming/bg/bgfarMountains.png b/assets/style/farming/bg/bgfarMountains.png Binary files differnew file mode 100644 index 0000000..fa6b349 --- /dev/null +++ b/assets/style/farming/bg/bgfarMountains.png diff --git a/assets/style/farming/bg/bgn.png b/assets/style/farming/bg/bgn.png Binary files differnew file mode 100644 index 0000000..2aa3995 --- /dev/null +++ b/assets/style/farming/bg/bgn.png diff --git a/assets/style/farming/bg/dirt.png b/assets/style/farming/bg/dirt.png Binary files differnew file mode 100644 index 0000000..11252ac --- /dev/null +++ b/assets/style/farming/bg/dirt.png diff --git a/assets/style/farming/bg/forestTileBack.png b/assets/style/farming/bg/forestTileBack.png Binary files differnew file mode 100644 index 0000000..0ea6022 --- /dev/null +++ b/assets/style/farming/bg/forestTileBack.png diff --git a/assets/style/farming/bg/forestTileFar.png b/assets/style/farming/bg/forestTileFar.png Binary files differnew file mode 100644 index 0000000..241e479 --- /dev/null +++ b/assets/style/farming/bg/forestTileFar.png diff --git a/assets/style/farming/bg/forestTileFront.png b/assets/style/farming/bg/forestTileFront.png Binary files differnew file mode 100644 index 0000000..e54f631 --- /dev/null +++ b/assets/style/farming/bg/forestTileFront.png diff --git a/assets/style/farming/bg/forestTileMid.png b/assets/style/farming/bg/forestTileMid.png Binary files differnew file mode 100644 index 0000000..b23afd2 --- /dev/null +++ b/assets/style/farming/bg/forestTileMid.png diff --git a/assets/style/farming/bg/grass.png b/assets/style/farming/bg/grass.png Binary files differnew file mode 100644 index 0000000..e05fb9b --- /dev/null +++ b/assets/style/farming/bg/grass.png diff --git a/assets/style/farming/bg/moon.png b/assets/style/farming/bg/moon.png Binary files differnew file mode 100644 index 0000000..d9a5ab7 --- /dev/null +++ b/assets/style/farming/bg/moon.png diff --git a/assets/style/farming/farmHouse.png b/assets/style/farming/farmHouse.png Binary files differnew file mode 100644 index 0000000..a07d787 --- /dev/null +++ b/assets/style/farming/farmHouse.png @@ -1,4 +1,4 @@ -#version 120
+#version 130
uniform sampler2D sampler;
uniform int numLight;
diff --git a/include/entities.hpp b/include/entities.hpp index e7864d0..f53f8e6 100644 --- a/include/entities.hpp +++ b/include/entities.hpp @@ -102,11 +102,7 @@ public: } void draw(){ - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, colorIndex); - glUseProgram(shaderProgram); - glUniform1i(glGetUniformLocation(shaderProgram, "sampler"), 0); - glEnable(GL_TEXTURE_2D); + //glEnable(GL_TEXTURE_2D); glColor3ub(255,255,255); glBegin(GL_QUADS); glTexCoord2f(.25*index.x, .125*index.y); glVertex2i(loc.x, loc.y); @@ -114,8 +110,8 @@ public: glTexCoord2f(.25*index.x, .125*index.y); glVertex2i(loc.x + width, loc.y + height); glTexCoord2f(.25*index.x, .125*index.y); glVertex2i(loc.x, loc.y + width); glEnd(); - glDisable(GL_TEXTURE_2D); - glUseProgram(0); + //glDisable(GL_TEXTURE_2D); + //glUseProgram(0); } bool kill(float delta){ duration -= delta; @@ -221,6 +221,9 @@ int main(int argc, char *argv[]){ return -1; } + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1); + // Run SDL_Quit when main returns atexit(SDL_Quit); @@ -338,6 +341,8 @@ int main(int argc, char *argv[]){ SDL_ShowCursor(SDL_DISABLE); + //glEnable(GL_CULL_FACE); + Texture::initColorIndex(); initEntity(); diff --git a/src/world.cpp b/src/world.cpp index bcd4f7a..625a33b 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -434,20 +434,20 @@ void World::draw(Player *p){ safeSetColorA( 255, 255, 255, weather == WorldWeather::Snowy ? 150 : 255 - worldShade * 4); glBegin( GL_QUADS ); - glTexCoord2i( 0, 0 ); glVertex2i( offset.x - SCREEN_WIDTH/2-5, SCREEN_HEIGHT ); - glTexCoord2i( 1, 0 ); glVertex2i( offset.x + SCREEN_WIDTH/2+5, SCREEN_HEIGHT ); - glTexCoord2i( 1, 1 ); glVertex2i( offset.x + SCREEN_WIDTH/2+5, 0 ); - glTexCoord2i( 0, 1 ); glVertex2i( offset.x - SCREEN_WIDTH/2-5, 0 ); + glTexCoord2i( 0, 0 ); glVertex2i( offset.x - SCREEN_WIDTH/2-5, offset.y + SCREEN_HEIGHT/2 ); + glTexCoord2i( 1, 0 ); glVertex2i( offset.x + SCREEN_WIDTH/2+5, offset.y + SCREEN_HEIGHT/2 ); + glTexCoord2i( 1, 1 ); glVertex2i( offset.x + SCREEN_WIDTH/2+5, offset.y - SCREEN_HEIGHT/2 ); + glTexCoord2i( 0, 1 ); glVertex2i( offset.x - SCREEN_WIDTH/2-5, offset.y - SCREEN_HEIGHT/2 ); glEnd(); bgTex->bindNext(); safeSetColorA( 255, 255, 255, worldShade * 4); glBegin( GL_QUADS ); - glTexCoord2i( 0, 0 ); glVertex2i( worldStart, SCREEN_HEIGHT ); - glTexCoord2i( 1, 0 ); glVertex2i( -worldStart, SCREEN_HEIGHT ); - glTexCoord2i( 1, 1 ); glVertex2i( -worldStart, 0 ); - glTexCoord2i( 0, 1 ); glVertex2i( worldStart, 0 ); + glTexCoord2i( 0, 0 ); glVertex2i( offset.x - SCREEN_WIDTH/2-5, offset.y + SCREEN_HEIGHT/2 ); + glTexCoord2i( 1, 0 ); glVertex2i( offset.x + SCREEN_WIDTH/2+5, offset.y + SCREEN_HEIGHT/2 ); + glTexCoord2i( 1, 1 ); glVertex2i( offset.x + SCREEN_WIDTH/2+5, offset.y - SCREEN_HEIGHT/2 ); + glTexCoord2i( 0, 1 ); glVertex2i( offset.x - SCREEN_WIDTH/2-5, offset.y - SCREEN_HEIGHT/2 ); glEnd(); glDisable( GL_TEXTURE_2D ); @@ -524,7 +524,15 @@ void World::draw(Player *p){ // draw particles and buildings - std::for_each( particles.begin(), particles.end(), [](Particles part) { if ( part.behind ) part.draw(); }); + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, colorIndex); + + glUniform1i(glGetUniformLocation(shaderProgram, "sampler"), 0); + glUseProgram(shaderProgram); + + std::for_each( particles.begin(), particles.end(), [](Particles part) { if ( part.behind ) part.draw(); }); + + glUseProgram(0); for ( auto &b : build ) b->draw(); @@ -671,8 +679,17 @@ void World::draw(Player *p){ * Draw remaining entities. */ + + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, colorIndex); + + glUniform1i(glGetUniformLocation(shaderProgram, "sampler"), 0); + glUseProgram(shaderProgram); + std::for_each( particles.begin(), particles.end(), [](Particles part) { if ( !part.behind ) part.draw(); }); + glUseProgram(0); + for ( auto &n : npc ) n->draw(); @@ -1383,9 +1400,18 @@ draw( Player *p ) /* * Draw all entities. */ + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, colorIndex); - for ( auto &part : particles ) - part.draw(); + glUniform1i(glGetUniformLocation(shaderProgram, "sampler"), 0); + glUseProgram(shaderProgram); + + std::for_each( particles.begin(), particles.end(), [](Particles &part) { part.draw(); }); + + glUseProgram(0); + + /*for ( auto &part : particles ) + part.draw();*/ for ( auto &e : entity ) e->draw(); @@ -1542,7 +1568,7 @@ loadWorldFromXMLNoSave( std::string path ) { loadedRight = false; } } else - abort(); + abort(); } else if ( name == "style" ) { tmp->setStyle(wxml->StrAttribute("folder")); tmp->setBackground((WorldBGType)wxml->UnsignedAttribute("background")); diff --git a/storyXML/0000_SpawnHill.xml b/storyXML/0000_SpawnHill.xml index 0a41197..7edd3b8 100644 --- a/storyXML/0000_SpawnHill.xml +++ b/storyXML/0000_SpawnHill.xml @@ -1,10 +1,12 @@ <?xml version="1.0"?> <World> - <style background="0" bgm="assets/music/embark.wav" folder="assets/style/classic/" /> + <style background="0" bgm="assets/music/embark.wav" folder="assets/style/farming/" /> <generation type="Random" width="500" /> <time>12000</time> - <hill peakx="0" peaky="1000" width="50" /> + <hill peakx="0" peaky="1000" width="75" /> + + <structure type="0" x="-300" texture="assets/style/farming/farmHouse.png"/> </World> diff --git a/storyXML/0000_SpawnHill.xml.dat b/storyXML/0000_SpawnHill.xml.dat index 45a3a9f..6d4f7b2 100644 --- a/storyXML/0000_SpawnHill.xml.dat +++ b/storyXML/0000_SpawnHill.xml.dat @@ -1 +1,3 @@ +-300 +60 dOnE
\ No newline at end of file diff --git a/xml/playerSpawnHill1_Building1.xml b/xml/playerSpawnHill1_Building1.xml index 8478908..c4def6c 100644 --- a/xml/playerSpawnHill1_Building1.xml +++ b/xml/playerSpawnHill1_Building1.xml @@ -1,6 +1,7 @@ <?xml version="1.0"?> <IndoorWorld> <style background="1" bgm="assets/music/theme_jazz.wav" /> + <link outside="playerSpawnHill1.xml"/> <floor width="300"> <npc name="Bob" hasDialog="true" /> |