]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
Player Sprite
authordrumsetmonkey <abelleisle@roadrunner.com>
Mon, 11 Jan 2016 04:04:50 +0000 (23:04 -0500)
committerdrumsetmonkey <abelleisle@roadrunner.com>
Mon, 11 Jan 2016 04:04:50 +0000 (23:04 -0500)
1  2 
assets/playerk.png
include/world.h
src/gameplay.cpp
src/ui.cpp
src/world.cpp
test.frag
xcf/player.xcf
xml/playerSpawnHill1.xml

index 0000000000000000000000000000000000000000,0000000000000000000000000000000000000000..be98f97491f96a2a5d47e1923623394589918101
new file mode 100644 (file)
Binary files differ
diff --cc include/world.h
index 5021fbb52b0632feab930b48d276be9d7e900278,5021fbb52b0632feab930b48d276be9d7e900278..0e8546290af6fdf113eaa67dbb9a3272e1d6d049
@@@ -167,7 -167,7 +167,7 @@@ public
         * loaded inside the world, with the Entity vector containing pointers to
         * the contents of all the others.
         */
--      
++
        std::vector<NPC                 *>      npc;
        std::vector<Structures  *>      build;
        std::vector<Mob                 *>      mob;
Simple merge
diff --cc src/ui.cpp
index ead9d8cc48cae1e1d246d1e437307b26bbe91cc8,6e33692dce172b295d8dc0a4f58d99f547041f64..64ebe92062af0f3fc5a7db8ef7fc490e648d4d35
@@@ -815,9 -816,9 +816,12 @@@ DONE
                                case SDLK_RIGHT:
                                        player->inv->sel++;
                                        break;
--                              case SDLK_f:
++                              case SDLK_l:
                                        player->light^=true;
                                        break;
++                              case SDLK_f:
++                                      currentWorld->addLight({player->loc.x + SCREEN_WIDTH/2, player->loc.y},{1.0f,1.0f,1.0f});
++                                      break;
                                default:
                                        break;
                                }
diff --cc src/world.cpp
index fea0e3e1e12fbd14d8ce92c4a8df6289447fa33b,68d5d2f83c0a12d936a5465cf7d01cb46c747810..e66fb0d64c37bae4d2da6ace5cc9dd33d4abb16c
@@@ -669,7 -669,7 +669,7 @@@ LOOP2
        glActiveTexture(GL_TEXTURE0);
        bgTex->bindNext();
  
--      GLfloat pointArray[light.size()][2];
++      GLfloat pointArray[light.size() + (int)p->light][2];
        for(uint w = 0; w < light.size(); w++){
                pointArray[w][0] = light[w].loc.x - offset.x;
                pointArray[w][1] = light[w].loc.y;
        glUniform1i(glGetUniformLocation(shaderProgram, "sampler"), 0);
        glUniform1f(glGetUniformLocation(shaderProgram, "amb"), float(shade+50.0f)/100.0f);
        if(p->light){
--              glUniform1i(glGetUniformLocation(shaderProgram, "numLight"), 1);
--              glUniform2f(glGetUniformLocation(shaderProgram, "lightLocation"), p->loc.x - offset.x+SCREEN_WIDTH/2, p->loc.y);
--              glUniform3f(glGetUniformLocation(shaderProgram, "lightColor"), 1.0f,1.0f,1.0f);
--      }else if(!light.size()){
++              //glUniform1i(glGetUniformLocation(shaderProgram, "numLight"), 1);
++              //glUniform2f(glGetUniformLocation(shaderProgram, "lightLocation"), p->loc.x - offset.x+SCREEN_WIDTH/2, p->loc.y);
++              //glUniform3f(glGetUniformLocation(shaderProgram, "lightColor"), 1.0f,1.0f,1.0f);
++              pointArray[light.size()+1][0] = (float)(p->loc.x + SCREEN_WIDTH/2);
++              pointArray[light.size()+1][1] = (float)(p->loc.y);
++      }
++      if(light.size()+(int)p->light == 0){
                glUniform1i(glGetUniformLocation(shaderProgram, "numLight"), 0);
        }else{
--              glUniform1i(glGetUniformLocation(shaderProgram, "numLight"), light.size());
--              glUniform2fv(glGetUniformLocation(shaderProgram, "lightLocation"), light.size(), (GLfloat *)&pointArray); 
--              glUniform3f(glGetUniformLocation(shaderProgram, "lightColor"), 1.0f,1.0f,1.0f);
++              glUniform1i (glGetUniformLocation(shaderProgram, "numLight"),      light.size()+(int)p->light);
++              glUniform2fv(glGetUniformLocation(shaderProgram, "lightLocation"), light.size()+(int)p->light, (GLfloat *)&pointArray); 
++              glUniform3f (glGetUniformLocation(shaderProgram, "lightColor"),    1.0f,1.0f,1.0f);
        }
  
        glBegin(GL_QUADS);
diff --cc test.frag
index 9bb5e3db8e0e3d87fba7e7cdd6a66dcc9029c257,3b11ebb9e49e593499e2fd6c265011a558550551..1c1e77b2dec34e316d50e7c4369b9998266ed25a
+++ b/test.frag
@@@ -2,7 -1,7 +2,7 @@@
  uniform sampler2D sampler;\r
  \r
  uniform int numLight;\r
--uniform vec2 lightLocation[10];\r
++uniform vec2 lightLocation[255];\r
  uniform vec3 lightColor;\r
  uniform float amb;\r
  // uniform float lightStrength;\r
diff --cc xcf/player.xcf
index 0000000000000000000000000000000000000000,0000000000000000000000000000000000000000..8815a08fd51ac0d85ba6fa0b41f4da670f922119
new file mode 100644 (file)
Binary files differ
index c924d7e6af74a874324e84c84e71cc2bbaf7c6b5,f3036a5f0503e0c0fa5babf12d7502607aac1db9..5a0e51f690d38621d1405581864b5710fc0913aa
@@@ -1,11 -1,12 +1,12 @@@
  <?xml version="1.0"?>
  <World>
        <style background="0" bgm="assets/music/embark.wav" />
--      <generation type="Random" width="500" />
++      <generation type="Random" width="2000" />
        
-       <!--<mob type="1" x="250" y="100" />-->
+       <mob type="1" />
        
-       <npc name="Ralph" x="0" y="100" hasDialog="true"/>
+       <npc name="Ralph" hasDialog="true" />
+       <npc name="Johnny" hasDialog="true" />
  
  </World>