aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2015-09-13 10:01:21 -0400
committerClyne Sullivan <tullivan99@gmail.com>2015-09-13 10:01:21 -0400
commita8fb538152c5e7d83b161a3868870aa4009ea36f (patch)
tree9cae69fc2ef26b6d57bab56e3912d6a4545800ff /src
parent384005bf1ebb0f303fec721a62970a78792b49c3 (diff)
colors
Diffstat (limited to 'src')
-rw-r--r--src/UIClass.cpp6
-rw-r--r--src/World.cpp7
2 files changed, 8 insertions, 5 deletions
diff --git a/src/UIClass.cpp b/src/UIClass.cpp
index 00456f5..46c7124 100644
--- a/src/UIClass.cpp
+++ b/src/UIClass.cpp
@@ -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){
diff --git a/src/World.cpp b/src/World.cpp
index cb074b0..ce6a3c7 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -48,6 +48,7 @@ World::World(const float width,World *l,World *r){
}else{
line[i].start=line[i-1].start+f;
}
+ line[i].color=(grand()%2)*10+130;
}
}
// Set RGB color with potentially not 8-bit values
@@ -83,7 +84,7 @@ LOOP2: // Should be in furthest back layer once this is first rea
y-=hline*2; // 'optimization'
glVertex2f(x+hline,y);
glVertex2f(x ,y);
- safeSetColor(150+shade,100+shade,50+shade); // Set shaded brown for dirt
+ safeSetColor(line[i].color+shade,line[i].color-50+shade,line[i].color-100+shade); // Set shaded brown for dirt
glVertex2f(x ,y);
glVertex2f(x+hline,y);
glVertex2f(x+hline,-1);
@@ -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
if(v->y<line[i].start){ // If we're inside the line
if(v->x>(HLINE*i)-1&&v->x<(HLINE*i)-1+HLINE){ // And we're inside it ;)
- vel->y=0;v->y=line[i].start+HLINE/4; // Correct
+ vel->y=0;v->y=line[i].start+HLINE/8; // Correct
return; // :/
}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
- vel->y=0;v->y=line[i].start+HLINE/4;
+ vel->y=0;v->y=line[i].start+HLINE/8;
return; // ;)
}
}else if(v->y>line[i].start+HLINE){ // Trashy gravity handling