From 02419534e3a0753abc74d8d15b1dc8ac0e3b31a7 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan <tullivan99@gmail.com> Date: Tue, 8 Mar 2016 08:01:01 -0500 Subject: world lighting work --- src/world.cpp | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'src/world.cpp') diff --git a/src/world.cpp b/src/world.cpp index a2baa9c..4de6e39 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -399,7 +399,7 @@ draw( Player *p ) int i, iStart, iEnd; // shade value for draws -- may be unnecessary - int shadeBackground = 0; + int shadeBackground = -worldShade; // player's offset in worldData[] int pOffset; @@ -439,20 +439,18 @@ draw( Player *p ) // draw the stars if the time deems it appropriate - if (((( weather == WorldWeather::Dark ) & ( tickCount % DAY_CYCLE )) < DAY_CYCLE / 2) || - ((( weather == WorldWeather::Sunny ) & ( tickCount % DAY_CYCLE )) > DAY_CYCLE * .75) ){ + //if (((( weather == WorldWeather::Dark ) & ( tickCount % DAY_CYCLE )) < DAY_CYCLE / 2) || + // ((( weather == WorldWeather::Sunny ) & ( tickCount % DAY_CYCLE )) > DAY_CYCLE * .75) ){ + if ( worldShade > 0 ) { - if (tickCount % DAY_CYCLE) { // The above if statement doesn't check for exact midnight. - - safeSetColorA( 255, 255, 255, 255 - (getRand() % 30 - 15) ); - - for ( i = 0; i < 100; i++ ) { - glRectf(star[i].x + offset.x * .9, - star[i].y, - star[i].x + offset.x * .9 + HLINE, - star[i].y + HLINE - ); - } + safeSetColorA( 255, 255, 255, 255 - (getRand() % 30 - 15) ); + + for ( i = 0; i < 100; i++ ) { + glRectf(star[i].x + offset.x * .9, + star[i].y, + star[i].x + offset.x * .9 + HLINE, + star[i].y + HLINE + ); } } @@ -536,7 +534,7 @@ draw( Player *p ) glUseProgram( shaderProgram ); glUniform1i( glGetUniformLocation( shaderProgram, "sampler"), 0 ); - glUniform1f( glGetUniformLocation( shaderProgram, "amb" ), 0.5f - worldShade / 50.0f ); + glUniform1f( glGetUniformLocation( shaderProgram, "amb" ), -worldShade / 50.0f ); if ( p->light ) { pointArray[2 * (light.size() + 1) ] = (float)( p->loc.x + SCREEN_WIDTH / 2 ); -- cgit v1.2.3