From: drumsetmonkey Date: Mon, 11 Jan 2016 04:04:50 +0000 (-0500) Subject: Player Sprite X-Git-Url: https://code.bitgloo.com/?a=commitdiff_plain;h=a2284d1c9be35744cb43a91148c82cff64be7a43;p=clyne%2Fgamedev.git Player Sprite --- a2284d1c9be35744cb43a91148c82cff64be7a43 diff --cc assets/playerk.png index 0000000,0000000..be98f97 new file mode 100644 Binary files differ diff --cc include/world.h index 5021fbb,5021fbb..0e85462 --- a/include/world.h +++ b/include/world.h @@@ -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; std::vector build; std::vector mob; diff --cc src/ui.cpp index ead9d8c,6e33692..64ebe92 --- a/src/ui.cpp +++ b/src/ui.cpp @@@ -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 fea0e3e,68d5d2f..e66fb0d --- a/src/world.cpp +++ b/src/world.cpp @@@ -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; @@@ -680,15 -680,15 +680,18 @@@ 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 9bb5e3d,3b11ebb..1c1e77b --- a/test.frag +++ b/test.frag @@@ -2,7 -1,7 +2,7 @@@ uniform sampler2D sampler; uniform int numLight; --uniform vec2 lightLocation[10]; ++uniform vec2 lightLocation[255]; uniform vec3 lightColor; uniform float amb; // uniform float lightStrength; diff --cc xcf/player.xcf index 0000000,0000000..8815a08 new file mode 100644 Binary files differ diff --cc xml/playerSpawnHill1.xml index c924d7e,f3036a5..5a0e51f --- a/xml/playerSpawnHill1.xml +++ b/xml/playerSpawnHill1.xml @@@ -1,11 -1,12 +1,12 @@@