public
Created

  • Download Gist
void Engine::GameLoop()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
/* 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;

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.