Skip to content

Instantly share code, notes, and snippets.

Created June 24, 2012 01:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/2980990 to your computer and use it in GitHub Desktop.
Save anonymous/2980990 to your computer and use it in GitHub Desktop.
/* This is in the main game loop */
case Game_Engine::Play:
if(gk::IsDown(SDLK_w)) // Adjust light or black overlay alpha
alpha += 0.05f;
else if(gk::IsDown(SDLK_s))
alpha -= 0.05f;
if(gk::IsDown(SDLK_d))
light += 0.05f;
else if(gk::IsDown(SDLK_a))
light -= 0.05f;
this->Light.Move(x, y); // Move "light" to mouse coordinates
/* Update everything on-screen */
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
this->Background.Update();
this->Map.Update(this->Player);
this->Player.Update();
glColor4f(1, 1, 1, alpha);
glBlendFunc(GL_DST_COLOR, GL_SRC_ALPHA);
this->Light.Update();
glColor4f(1, 1, 1, light);
break;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment