]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
world lighting work
authorClyne Sullivan <tullivan99@gmail.com>
Tue, 8 Mar 2016 13:01:01 +0000 (08:01 -0500)
committerClyne Sullivan <tullivan99@gmail.com>
Tue, 8 Mar 2016 13:01:01 +0000 (08:01 -0500)
main.cpp
src/world.cpp

index a9b172b928a2d20fb4507c02a4730e203c0e4c69..af962db8d22f7d85188df998c6905f7fad470aeb 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -87,7 +87,7 @@ extern Menu *currentMenu;
  * The current number of ticks, used for logic operations and day/night cycles.
  */
 
-unsigned int tickCount = DAY_CYCLE;
+unsigned int tickCount = 0;
 
 /**
  * TODO
index a2baa9c8548343b5e5935ba17777cd4364cd7161..4de6e395f017d722ea1e4ce6ff1fd9f828e5fe81 100644 (file)
@@ -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 );