]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
First world and style
authordrumsetmonkey <abelleisle@roadrunner.com>
Wed, 6 Apr 2016 11:38:59 +0000 (07:38 -0400)
committerdrumsetmonkey <abelleisle@roadrunner.com>
Wed, 6 Apr 2016 11:38:59 +0000 (07:38 -0400)
23 files changed:
assets/style/farming/bg/bagels.jpg [new file with mode: 0644]
assets/style/farming/bg/bagels.png [new file with mode: 0644]
assets/style/farming/bg/bg.png [new file with mode: 0644]
assets/style/farming/bg/bgFarMountain.png [new file with mode: 0644]
assets/style/farming/bg/bgWoodTile.png [new file with mode: 0644]
assets/style/farming/bg/bgb.png [new file with mode: 0644]
assets/style/farming/bg/bgfarMountains.png [new file with mode: 0644]
assets/style/farming/bg/bgn.png [new file with mode: 0644]
assets/style/farming/bg/dirt.png [new file with mode: 0644]
assets/style/farming/bg/forestTileBack.png [new file with mode: 0644]
assets/style/farming/bg/forestTileFar.png [new file with mode: 0644]
assets/style/farming/bg/forestTileFront.png [new file with mode: 0644]
assets/style/farming/bg/forestTileMid.png [new file with mode: 0644]
assets/style/farming/bg/grass.png [new file with mode: 0644]
assets/style/farming/bg/moon.png [new file with mode: 0644]
assets/style/farming/farmHouse.png [new file with mode: 0644]
frig.frag
include/entities.hpp
main.cpp
src/world.cpp
storyXML/0000_SpawnHill.xml
storyXML/0000_SpawnHill.xml.dat
xml/playerSpawnHill1_Building1.xml

diff --git a/assets/style/farming/bg/bagels.jpg b/assets/style/farming/bg/bagels.jpg
new file mode 100644 (file)
index 0000000..fb68d2e
Binary files /dev/null and b/assets/style/farming/bg/bagels.jpg differ
diff --git a/assets/style/farming/bg/bagels.png b/assets/style/farming/bg/bagels.png
new file mode 100644 (file)
index 0000000..2ee843b
Binary files /dev/null and b/assets/style/farming/bg/bagels.png differ
diff --git a/assets/style/farming/bg/bg.png b/assets/style/farming/bg/bg.png
new file mode 100644 (file)
index 0000000..2dbc3f9
Binary files /dev/null and b/assets/style/farming/bg/bg.png differ
diff --git a/assets/style/farming/bg/bgFarMountain.png b/assets/style/farming/bg/bgFarMountain.png
new file mode 100644 (file)
index 0000000..eb703bb
Binary files /dev/null and b/assets/style/farming/bg/bgFarMountain.png differ
diff --git a/assets/style/farming/bg/bgWoodTile.png b/assets/style/farming/bg/bgWoodTile.png
new file mode 100644 (file)
index 0000000..95b0667
Binary files /dev/null and b/assets/style/farming/bg/bgWoodTile.png differ
diff --git a/assets/style/farming/bg/bgb.png b/assets/style/farming/bg/bgb.png
new file mode 100644 (file)
index 0000000..278e9b0
Binary files /dev/null and b/assets/style/farming/bg/bgb.png differ
diff --git a/assets/style/farming/bg/bgfarMountains.png b/assets/style/farming/bg/bgfarMountains.png
new file mode 100644 (file)
index 0000000..fa6b349
Binary files /dev/null and b/assets/style/farming/bg/bgfarMountains.png differ
diff --git a/assets/style/farming/bg/bgn.png b/assets/style/farming/bg/bgn.png
new file mode 100644 (file)
index 0000000..2aa3995
Binary files /dev/null and b/assets/style/farming/bg/bgn.png differ
diff --git a/assets/style/farming/bg/dirt.png b/assets/style/farming/bg/dirt.png
new file mode 100644 (file)
index 0000000..11252ac
Binary files /dev/null and b/assets/style/farming/bg/dirt.png differ
diff --git a/assets/style/farming/bg/forestTileBack.png b/assets/style/farming/bg/forestTileBack.png
new file mode 100644 (file)
index 0000000..0ea6022
Binary files /dev/null and b/assets/style/farming/bg/forestTileBack.png differ
diff --git a/assets/style/farming/bg/forestTileFar.png b/assets/style/farming/bg/forestTileFar.png
new file mode 100644 (file)
index 0000000..241e479
Binary files /dev/null and b/assets/style/farming/bg/forestTileFar.png differ
diff --git a/assets/style/farming/bg/forestTileFront.png b/assets/style/farming/bg/forestTileFront.png
new file mode 100644 (file)
index 0000000..e54f631
Binary files /dev/null and b/assets/style/farming/bg/forestTileFront.png differ
diff --git a/assets/style/farming/bg/forestTileMid.png b/assets/style/farming/bg/forestTileMid.png
new file mode 100644 (file)
index 0000000..b23afd2
Binary files /dev/null and b/assets/style/farming/bg/forestTileMid.png differ
diff --git a/assets/style/farming/bg/grass.png b/assets/style/farming/bg/grass.png
new file mode 100644 (file)
index 0000000..e05fb9b
Binary files /dev/null and b/assets/style/farming/bg/grass.png differ
diff --git a/assets/style/farming/bg/moon.png b/assets/style/farming/bg/moon.png
new file mode 100644 (file)
index 0000000..d9a5ab7
Binary files /dev/null and b/assets/style/farming/bg/moon.png differ
diff --git a/assets/style/farming/farmHouse.png b/assets/style/farming/farmHouse.png
new file mode 100644 (file)
index 0000000..a07d787
Binary files /dev/null and b/assets/style/farming/farmHouse.png differ
index f750f2d989a78bdd68e7925395b62b595d84bef3..6beb7b34179b85d73c3dfe5afe0dfcacfc6bfd74 100644 (file)
--- a/frig.frag
+++ b/frig.frag
@@ -1,4 +1,4 @@
-#version 120\r
+#version 130\r
 uniform sampler2D sampler;\r
 \r
 uniform int numLight;\r
index e7864d0b50b57e61a0091cd7c904fe91d2b4d829..f53f8e6ca3112d8437e6347adeee9717b8b89814 100644 (file)
@@ -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;
index 95d4e05bbdc173210da465b28e571f666cdb3bec..3b500f40b269fabc7c34f4ab4a92f13615b2e542 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -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();
 
index bcd4f7a297d60e6793b695f5c8f3140a24b502cc..625a33b46dd4e12b3b908a0afd2836916545c93c 100644 (file)
@@ -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"));
index 0a4119700e072b7124f591fad31f76ca95d7ca7a..7edd3b8b64169a3714ab90367618426b1c3e99d6 100644 (file)
@@ -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>
index 45a3a9fab5639d80edde63377d61a24eb663f68d..6d4f7b202c004557ed3be2aa1bb7f133f194f4b8 100644 (file)
@@ -1 +1,3 @@
+-300
+60
 dOnE
\ No newline at end of file
index 847890898c52e50e48c84e2a40e7a7ddaf2c2f5a..c4def6c927261048f09bfe873d19ed08a876572e 100644 (file)
@@ -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" />