]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
Stars and Stripes forevahh!
authordrumsetmonkey <abelleisle@roadrunner.com>
Mon, 16 May 2016 14:53:33 +0000 (10:53 -0400)
committerdrumsetmonkey <abelleisle@roadrunner.com>
Mon, 16 May 2016 14:53:33 +0000 (10:53 -0400)
23 files changed:
.gitattributes
assets/items/FOOD_CHICKEN_FRIED.png
assets/items/SWORD_WOOD.png
assets/items/arrow_crude.png
assets/items/bow.png
assets/items/bow1.png
assets/items/bow2.png
assets/items/bow3.png
assets/player/playerk.png
assets/player/playerk1.png
assets/player/playerk2.png
assets/player/playerk3.png
assets/player/playerk4.png
assets/player/playerk5.png
assets/player/playerk6.png
assets/player/playerk7.png
assets/player/playerk8.png
brice.dat
shaders/world.frag
src/entities.cpp
src/inventory.cpp
src/items.cpp
src/world.cpp

index 7bb24181c464a6e1b69d4798bcb6587797968d75..d10ef482a04a4ee62a3cfcb359511afc54072527 100644 (file)
@@ -1,6 +1,11 @@
 include/tinyxml2.h linguist-vendored
 src/tinyxml2.cpp linguist-vendored
-src/threadpool.cpp linguist-vendored
+
 include/threadpool.h linguist-vendored
+src/threadpool.cpp linguist-vendored
+
 include/SDL2/* linguist-vendored
+
 include/freetype/* linguist-vendored
+
+include/glm/* linguist-vendored
index d086400e25ce351f283952c79fa7c5f6bd5d81a6..5dd27e9ed63de55fb8c10e1a3fef57ffeef03341 100644 (file)
Binary files a/assets/items/FOOD_CHICKEN_FRIED.png and b/assets/items/FOOD_CHICKEN_FRIED.png differ
index 479eba9f9cf35edfaab8185a1a4ab79a6f64c41e..90e8ee3af0f977dbd7e34c44d5638122f800b587 100644 (file)
Binary files a/assets/items/SWORD_WOOD.png and b/assets/items/SWORD_WOOD.png differ
index 3d820749a68eec9260ed1b712519692fbcc5aa53..5fba709c5c36390612d2f929b715348f3e7a7d24 100644 (file)
Binary files a/assets/items/arrow_crude.png and b/assets/items/arrow_crude.png differ
index 62be2dcb2751d668fe05822a4235baa8a383edd0..7affffb116475a2a37207252a75a2f11cca15067 100644 (file)
Binary files a/assets/items/bow.png and b/assets/items/bow.png differ
index a37ca719974ab4932bf9d783f42e505d58f38944..1f3562671b771f13f4fdc9e2b5763c401a80fb67 100644 (file)
Binary files a/assets/items/bow1.png and b/assets/items/bow1.png differ
index 29ba192261fe3d6e6501c99cfe74f09b9815c54a..9bab2df06e401bf10979cd098ad48c34cb9b2a00 100644 (file)
Binary files a/assets/items/bow2.png and b/assets/items/bow2.png differ
index 3c8ed6c3d9351bb487aab78ae5db981e82e45021..a5f550fcd12e32b1108acef93fd8207c616db265 100644 (file)
Binary files a/assets/items/bow3.png and b/assets/items/bow3.png differ
index ea0a7ab5300cfed329f44298e7dd2a5702283c80..570bc8ef2590b12a7b550a0cb2d1b554795938ac 100644 (file)
Binary files a/assets/player/playerk.png and b/assets/player/playerk.png differ
index 1c4fb490c5338d40ba8f33ec797ec4efe55096c3..6e549cfcf615d61de063a8545ccdcf6e83ad4fc9 100644 (file)
Binary files a/assets/player/playerk1.png and b/assets/player/playerk1.png differ
index 97f769bbaa7955a3f356cef4cf89e3175eb45cac..f6966ee3205110b7e6dd67f5442a244ecf287010 100644 (file)
Binary files a/assets/player/playerk2.png and b/assets/player/playerk2.png differ
index 19b97c44466733cebed624abd9d4a1b5e5245991..44ca2b8f7da7f39ab3d6e00a806785cf9f44817d 100644 (file)
Binary files a/assets/player/playerk3.png and b/assets/player/playerk3.png differ
index c32a9b387a353a133bd3428480706bc5b611441d..767a6fc2c0b894aad91c45cbdae647ecf79831d8 100644 (file)
Binary files a/assets/player/playerk4.png and b/assets/player/playerk4.png differ
index fabfa60e5013bed00592b200e981c517064890b1..8c91fa1532ddb4537ad7639b5e7715262aa6f5ed 100644 (file)
Binary files a/assets/player/playerk5.png and b/assets/player/playerk5.png differ
index 269fccb8417ff63de39a7bb41b88003dde9a1f94..e10d3cff2ae70b0ea883108ce97c6a5b968851c8 100644 (file)
Binary files a/assets/player/playerk6.png and b/assets/player/playerk6.png differ
index aeac12098021aa735dfa1b514b8b8186d4cdfa03..777af2b593c80b69c72690208a8884fef1ca08e4 100644 (file)
Binary files a/assets/player/playerk7.png and b/assets/player/playerk7.png differ
index ff03a02091f055cb94164dc5abb1ad5c9cd893b4..50175e8eabc4f7fcdc81d5b62d494a1381061643 100644 (file)
Binary files a/assets/player/playerk8.png and b/assets/player/playerk8.png differ
index 61d57c2785952fa6cb22f35f6db947ff5ddf91d2..ea71945339f7a7cd6d35324a11df49578bb93bfc 100644 (file)
--- a/brice.dat
+++ b/brice.dat
@@ -1,5 +1,5 @@
 2
-canJump
-0
 canSprint
 0
+canJump
+0
index 80af175c856488d1018f377695022b0cf3ff1b42..c10343350f79d413720df7ee4f89343b002dfed7 100644 (file)
@@ -5,7 +5,7 @@ varying vec4 color;
 
 void main(){
     vec4 pixTex = texture2D(sampler, vec2(texCoord.x, 1-texCoord.y));
-    if(pixTex.a <= .1)
+    if(pixTex.a == 0.0)
         discard;
     gl_FragColor = pixTex * color;
 }
index 8dc32e2c28873da93cf3ce3b60106e8de9eb99c1..ff8dd5d2f11af1099a3d26996e78c3968c3dd01f 100644 (file)
@@ -349,14 +349,23 @@ void NPC::drawThingy(void) const
                        c[2], c[3], z, c[0], c[3], z, c[0], c[1], z
                };
                
+               // TODO use texture made for this
+               static GLuint thingyColor = Texture::genColor(Color(236, 238, 15));
+       
                glUseProgram(worldShader);
+               
                glEnableVertexAttribArray(worldShader_attribute_coord);
                glEnableVertexAttribArray(worldShader_attribute_tex);
+               
+               glBindTexture(GL_TEXTURE_2D, thingyColor);
+                       
                glVertexAttribPointer(worldShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, 0, coords);
                glVertexAttribPointer(worldShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, 0, tex_coord);
                glDrawArrays(GL_TRIANGLES, 0, 6);
+               
                glDisableVertexAttribArray(worldShader_attribute_coord);
                glDisableVertexAttribArray(worldShader_attribute_tex);
+               
                glUseProgram(0);
        }
 }
index 29e2dc9c92082533aa0bc962f767084d18cf9e96..8c662c43644924a32d728616c8588cea40d3bd58 100644 (file)
@@ -104,7 +104,9 @@ void items(void)
                ItemMap.back()->tex = new Texturec(1, exml->Attribute("sprite"));
 
                // get the width and height of the object based off of its sprite
-               ItemMap.back()->dim = Texture::imageDim(exml->Attribute("sprite"));
+               dim2 tmpDim = Texture::imageDim(exml->Attribute("sprite"));
+               ItemMap.back()->dim.x = HLINES(tmpDim.x/2);
+               ItemMap.back()->dim.y = HLINES(tmpDim.y/2);
 
                ItemMap.back()->name = exml->Attribute("name");
 
index 21484b4b8de4f15b244115a1627f9197f67cf9a7..99c143bed3805f1528fa4041f5c0fca38ba0f4c4 100644 (file)
@@ -60,20 +60,45 @@ int Sword::useItem()
                                        float dist = 0.0f;
                                        while (dist < dim.y) {
                                                hitbox.end = hitbox.start;
-                                               hitbox.end.x += dist * cos(rotation*PI/180);
+                                               if (player->left)
+                                                       hitbox.end.x -= dist * cos(rotation*PI/180);
+                                               else 
+                                                       hitbox.end.x += dist * cos(rotation*PI/180);
+
                                                hitbox.end.y += dist * sin(rotation*PI/180);
 
                                                if (hitbox.end.x > e->loc.x && hitbox.end.x < e->loc.x + e->width) {
                                                        if (hitbox.end.y > e->loc.y && hitbox.end.y < e->loc.y + e->height) {
                                                                e->takeHit(damage, 600);
 
+                                               static GLuint sColor = Texture::genColor(Color(255,0,0));
+
+                                               GLfloat t[] = {0.0, 0.0,
+                                                                          1.0, 1.0};
+
+                                               GLfloat v[] = {hitbox.start.x,  hitbox.start.y, 1.0,
+                                                                          hitbox.end.x,        hitbox.end.y,   1.0};
+
+                                       
+                                               glBindTexture(GL_TEXTURE_2D, sColor);
+                                               glUseProgram(worldShader);
+                                               glEnableVertexAttribArray(worldShader_attribute_coord);
+                                               glEnableVertexAttribArray(worldShader_attribute_tex);
+                                               
+                                               glVertexAttribPointer(worldShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, 0, v);
+                                               glVertexAttribPointer(worldShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, 0, t);
+                                               glDrawArrays(GL_LINES, 0, 2);
+
+                                               glDisableVertexAttribArray(worldShader_attribute_coord);
+                                               glDisableVertexAttribArray(worldShader_attribute_tex);
+                                               glUseProgram(0);
                                                                // add some blood
                                                                // for(int r = 0; r < (rand()%5);r++)
                                                                //      currentWorld->addParticle(rand()%game::HLINE*3 + e->loc.x - .05f,e->loc.y + e->height*.5, game::HLINE,game::HLINE, -(rand()%10)*.01,((rand()%4)*.001-.002), {(rand()%75+10)/100.0f,0,0}, 10000);
                                                        }
                                                }
 
-                                               dist += HLINES(1);
+                                               dist += HLINES(0.5f);
                                        }
                                }
                        }
index 0c5007dc362c62e04956774691a13c8fed8c7ba3..70ba9678ca3ba7de561d6dac7ba4810447f7e15e 100644 (file)
@@ -254,7 +254,6 @@ void World::drawBackgrounds(void)
         alpha = 255 - worldShade * 4;
         break;
     }
-    (void)alpha;
 
     glActiveTexture(GL_TEXTURE0);
     glUniform1i(worldShader_uniform_texture, 0);
@@ -276,7 +275,6 @@ void World::drawBackgrounds(void)
                             vec2(0.0f, 1.0f),
                             vec2(0.0f, 0.0f)};
 
-    bgTex(0);
     GLfloat back_tex_coord[] = {offset.x - backgroundOffset.x - 5, offset.y + backgroundOffset.y, 10.0f,
                                 offset.x + backgroundOffset.x + 5, offset.y + backgroundOffset.y, 10.0f,
                                 offset.x + backgroundOffset.x + 5, offset.y - backgroundOffset.y, 10.0f,
@@ -290,18 +288,85 @@ void World::drawBackgrounds(void)
     glEnableVertexAttribArray(worldShader_attribute_coord);
     glEnableVertexAttribArray(worldShader_attribute_tex);
 
+    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, tex_coord);
     glDrawArrays(GL_TRIANGLES, 0 , 6);
 
+       bgTex++;
+       glUniform4f(worldShader_uniform_color, .8, .8, .8, 1.3 - static_cast<float>(alpha)/255.0f);
+    glVertexAttribPointer(worldShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, 0, back_tex_coord);
+    glVertexAttribPointer(worldShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, 0, tex_coord);
+    glDrawArrays(GL_TRIANGLES, 0 , 6);
+
+               
+       static GLuint starTex = Texture::genColor(Color(255, 255, 255));
+       const static float stardim = 2;
+       GLfloat star_coord[star.size() * 5 * 6 + 1];
+    GLfloat *si = &star_coord[0];              
+
+       if (worldShade > 0) {
+
+               auto xcoord = offset.x * 0.9f;
+               
+               for (auto &s : star) {
+                       *(si++) = s.x + xcoord;
+                       *(si++) = s.y,
+                       *(si++) = 9.8;
+
+                       *(si++) = 0.0;
+                       *(si++) = 0.0;
+                       
+                       *(si++) = s.x + xcoord + stardim;
+                       *(si++) = s.y,
+                       *(si++) = 9.8;
+                       
+                       *(si++) = 1.0;
+                       *(si++) = 0.0;
+                       
+                       *(si++) = s.x + xcoord + stardim;
+                       *(si++) = s.y + stardim,
+                       *(si++) = 9.8;
+                       
+                       *(si++) = 1.0;
+                       *(si++) = 1.0;
+                       
+                       *(si++) = s.x + xcoord + stardim;
+                       *(si++) = s.y + stardim,
+                       *(si++) = 9.8;
+                       
+                       *(si++) = 1.0;
+                       *(si++) = 1.0;
+                       
+                       *(si++) = s.x + xcoord;
+                       *(si++) = s.y + stardim,
+                       *(si++) = 9.8;
+                       
+                       *(si++) = 0.0;
+                       *(si++) = 1.0;
+                       
+                       *(si++) = s.x + xcoord;
+                       *(si++) = s.y,
+                       *(si++) = 9.8;
+                       
+                       *(si++) = 0.0;
+                       *(si++) = 0.0;
+               }
+               glBindTexture(GL_TEXTURE_2D, starTex);
+               glUniform4f(worldShader_uniform_color, 1.0, 1.0, 1.0, (255.0f - (randGet() % 200 - 100)) / 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);
+       }
     glDisableVertexAttribArray(worldShader_attribute_coord);
     glDisableVertexAttribArray(worldShader_attribute_tex);
 
+       glUniform4f(worldShader_uniform_color, 1.0, 1.0, 1.0, 1.0);
     glUseProgram(0);
 
 
-       bgTex++;
-
     std::vector<vec3> bg_items;
 
        bgTex++;