]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
colors
authorClyne Sullivan <tullivan99@gmail.com>
Sun, 13 Sep 2015 14:01:21 +0000 (10:01 -0400)
committerClyne Sullivan <tullivan99@gmail.com>
Sun, 13 Sep 2015 14:01:21 +0000 (10:01 -0400)
include/World.h
src/UIClass.cpp
src/World.cpp

index 6e5c3daee2f7b3b8f6566180f9dcbca5309ca0be..4d55c5dff3270110e0bae23f40cd6f4e92611df4 100644 (file)
@@ -14,6 +14,7 @@ class World {
 private:\r
        struct line_t {\r
                double start;                             // Where land begins, going down (i.e. y)\r
+               unsigned char color;\r
        } __attribute__ ((packed)) *line;\r
        unsigned int lineCount;                   // Size of line array, calculated in the constructor\r
        unsigned int entCount;                    // Count of currently bound entities\r
index 00456f59d74a5da4c7115f7e58b7fdea99e6a2a3..46c7124e227f025752639d5f350018954da31241 100644 (file)
@@ -19,8 +19,10 @@ void UIClass::handleEvents(){
                        if(e.key.keysym.sym == SDLK_a) player.left = true;
                        if(e.key.keysym.sym == SDLK_LSHIFT) player.speed = 3;
                        if(e.key.keysym.sym == SDLK_SPACE){
-                               player.loc.y += HLINE*1.2;
-                               player.vel.y += .004;
+                               if(player.vel.y<=0){
+                                       player.loc.y += HLINE*1.2;
+                                       player.vel.y += .004;
+                               }
                        }
                        if(e.key.keysym.sym == SDLK_i){
                                if(currentWorld->behind){
index cb074b0cd14c4f1a0aa482967a21df01dd606cb8..ce6a3c7e2e5f6e7a6a7ed4bcc9c22acd777864ec 100644 (file)
@@ -48,6 +48,7 @@ World::World(const float width,World *l,World *r){
                }else{\r
                        line[i].start=line[i-1].start+f;\r
                }\r
+               line[i].color=(grand()%2)*10+130;\r
        }\r
 }\r
 // Set RGB color with potentially not 8-bit values\r
@@ -83,7 +84,7 @@ LOOP2:                                                                                                                                // Should be in furthest back layer once this is first rea
                        y-=hline*2;                                                                                             // 'optimization'\r
                        glVertex2f(x+hline,y);\r
                        glVertex2f(x      ,y);\r
-                       safeSetColor(150+shade,100+shade,50+shade);                             // Set shaded brown for dirt\r
+                       safeSetColor(line[i].color+shade,line[i].color-50+shade,line[i].color-100+shade);                               // Set shaded brown for dirt\r
                        glVertex2f(x      ,y);\r
                        glVertex2f(x+hline,y);\r
                        glVertex2f(x+hline,-1);\r
@@ -108,10 +109,10 @@ void World::detect(vec2 *v,vec2 *vel,const float width){
        for(i=0;i<lineCount-10;i++){                                                                                    // For every line in world\r
                if(v->y<line[i].start){                                                                                         // If we're inside the line\r
                        if(v->x>(HLINE*i)-1&&v->x<(HLINE*i)-1+HLINE){                                   // And we're inside it ;)\r
-                               vel->y=0;v->y=line[i].start+HLINE/4;                                                    // Correct\r
+                               vel->y=0;v->y=line[i].start+HLINE/8;                                                    // Correct\r
                                return; // :/\r
                        }else if(v->x+width>(HLINE*i)-1&&v->x+width<(HLINE*i)-1+HLINE){ // Same as above, but coming from right side instead of left\r
-                               vel->y=0;v->y=line[i].start+HLINE/4;\r
+                               vel->y=0;v->y=line[i].start+HLINE/8;\r
                                return; // ;)\r
                        }\r
                }else if(v->y>line[i].start+HLINE){                                                                     // Trashy gravity handling\r