aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/common.h7
-rw-r--r--main.cpp76
2 files changed, 79 insertions, 4 deletions
diff --git a/include/common.h b/include/common.h
index db60dd6..41cc7b9 100644
--- a/include/common.h
+++ b/include/common.h
@@ -39,7 +39,7 @@ typedef unsigned int uint;
* This flag lets the compiler know that we are using shaders
*/
-#define SHADERS
+#define SHADERSf
/*
* Create a basic 2-point structure for coordinate saving
@@ -50,6 +50,11 @@ typedef struct {
float y;
} vec2;
+typedef struct {
+ vec2 start;
+ vec2 end;
+} Ray;
+
/*
* Define the game's name (displayed in the window title),
* the desired window dimensions,
diff --git a/main.cpp b/main.cpp
index dee78c7..a49873c 100644
--- a/main.cpp
+++ b/main.cpp
@@ -764,7 +764,6 @@ void render(){
*/
#ifdef SHADERS
-
glUseProgramObjectARB(shaderProgram);
glUniform2f(glGetUniformLocation(shaderProgram, "lightLocation"), 640,100);
glUniform3f(glGetUniformLocation(shaderProgram, "lightColor"), 1,1,1);
@@ -773,9 +772,80 @@ void render(){
glColor4ub(0,0,0,200);
glRectf(offset.x-SCREEN_WIDTH/2,0,offset.x+SCREEN_WIDTH/2,SCREEN_HEIGHT);
glUseProgramObjectARB(0);
-
#endif //SHADERS
-
+
+ #define pi 3.1415926535
+ #define raysNOPE
+
+ #ifdef rays
+ //LIGHT
+ static vec2 light;
+ float lightStr = 100;
+ vec2 curCoord;
+ light.x = player->loc.x;
+ light.y = player->loc.y;
+ std::vector<Ray>ray(30);
+ unsigned int a = 0;
+ int angle = 0;
+ glColor3f(0.0f, 0.0f, 0.0f);
+ for(auto &r : ray){
+ r.start = light;
+ angle = 12*a;
+ for(int l = 0;l<lightStr;l+=36){
+ //switch
+ switch(angle){
+ case 0:
+ curCoord.x += HLINE;
+ curCoord.y += 0;
+ break;
+ case 180:
+ curCoord.x -= HLINE;
+ curCoord.y -= 0;
+ break;
+ case 360:
+ curCoord.x += HLINE;
+ curCoord.y += 0;
+ angle = 0;
+ break;
+ default:
+ if(angle > 0 && angle < 90){
+ curCoord.x = r.start.x + float(HLINE / cos(angle*pi/180));
+ curCoord.y = r.start.y + float(HLINE / sin(angle*pi/180));
+ }
+ if(angle > 90 && angle < 180){
+ curCoord.x = r.start.x - float(HLINE / cos((90-angle)*pi/180));
+ curCoord.y = r.start.y + float(HLINE / sin((90-angle)*pi/180));
+ }
+ if(angle > 180 && angle < 270){
+ curCoord.x = r.start.x - float(HLINE / cos((270-angle)*pi/180));
+ curCoord.y = r.start.y - float(HLINE / sin((270-angle)*pi/180));
+ }
+ if(angle > 270 && angle < 360){
+ curCoord.x = r.start.x + float(HLINE / cos((360-angle)*pi/180));
+ curCoord.y = r.start.y - float(HLINE / sin((360-angle)*pi/180));
+ }
+ }//end swtich
+ /*for(auto &en : entity){
+ if(curCoord.x > en->loc.x && curCoord.x < en->loc.x + en->width){
+ if(curCoord.y > en->loc.y && curCoord .y < en->loc.y + en->height){
+ r.end = curCoord;
+ }
+ }
+ }*/
+
+ }//end length
+ r.end = curCoord;
+ glBegin(GL_LINES);
+ glVertex2f(r.start.x,r.start.y);
+ glVertex2f(r.end.x, r.end.y);
+ glEnd();
+ //std::cout << angle << "\n";
+ a++;
+ }
+ #endif //rays
+
+
+ //LIGHT
player->inv->draw();
/*