]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
Player has a light
authordrumsetmonkey <abelleisle@roadrunner.com>
Thu, 7 Jan 2016 13:47:59 +0000 (08:47 -0500)
committerdrumsetmonkey <abelleisle@roadrunner.com>
Thu, 7 Jan 2016 13:47:59 +0000 (08:47 -0500)
main.cpp
src/ui.cpp
src/world.cpp

index 1725ccfd91b911d949e81b959ab7593f083f1086..d5b9f780f2dd0f420116f27889e56af1e6224af1 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -624,7 +624,7 @@ void render(){
        if(ui::mouse.x > player->loc.x && ui::mouse.y < player->loc.y+player->height/2 && handAngle <= 0) handAngle = 360+handAngle;
        //if(ui::mouse.x < player->loc.x + (player->width/2)){player->left = true;player->right=false;}
        //if(ui::mouse.x >= player->loc.x + (player->width/2)){player->right = true;player->left=false;}
-       if(player->light){
+       /*if(player->light){
                vec2 light;
                int lightStr = 150;
                vec2 curCoord;
@@ -655,12 +655,12 @@ void render(){
                                                }
                                        }
                                }
-                               /*if(curCoord.x > player->loc.x && curCoord.x < player->loc.x + player->width){
+                               if(curCoord.x > player->loc.x && curCoord.x < player->loc.x + player->width){
                                                if(curCoord.y > player->loc.y && curCoord .y < player->loc.y + player->height){
                                                        r.end = curCoord;
                                                        l=lightStr;
                                                }
-                               }*/if(l==lightStr)r.end = curCoord;
+                               }if(l==lightStr)r.end = curCoord;
                        }//end length
                        glBegin(GL_LINES);
                                glVertex2f(r.start.x,r.start.y);
@@ -683,7 +683,7 @@ void render(){
                        glEnd();
                }
                glUseProgramObjectARB(0);
-       }
+       }*/
 
        
        player->inv->draw();
index 7979138b745316672e56836e8517a2fd68f0939f..cf5e31ee1f9cbf5c45be57f23d7ea6cdfb64d158 100644 (file)
@@ -815,7 +815,7 @@ DONE:
                                        player->inv->sel++;
                                        break;
                                case SDLK_f:
-                                       
+                                       player->light^=true;
                                        break;
                                default:
                                        break;
index c6ab6e1a454455c32ed9e51b996d93a95b514d15..6fc84f8404e9184b9afc9ee60e91a47bb22f31fb 100644 (file)
@@ -617,7 +617,10 @@ LOOP2:
        glUseProgram(shaderProgram);
        glUniform1i(glGetUniformLocation(shaderProgram, "sampler"), 0);
        glUniform1f(glGetUniformLocation(shaderProgram, "amb"), float(shade+50.0f)/100.0f);
-       if(light.size() == 0){
+       if(p->light){
+               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() == 0){
                glUniform2f(glGetUniformLocation(shaderProgram, "lightLocation"), 0,-1000);
                glUniform3f(glGetUniformLocation(shaderProgram, "lightColor"), 0.0f,0.0f,0.0f);
        }else{
@@ -1211,7 +1214,10 @@ void IndoorWorld::draw(Player *p){
        glUseProgram(shaderProgram);
        glUniform1i(glGetUniformLocation(shaderProgram, "sampler"), 0);
        glUniform1f(glGetUniformLocation(shaderProgram, "amb"), 0.0f);
-       if(light.size() == 0){
+       if(p->light){
+               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() == 0){
                glUniform2f(glGetUniformLocation(shaderProgram, "lightLocation"), 0,-1000);
                glUniform3f(glGetUniformLocation(shaderProgram, "lightColor"), 0.0f,0.0f,0.0f);
        }else{