예제 #1
0
void CreditScene::update(float) {
  if (_buttons.empty())
      return;
  if(_trigged) {
      if (Graphics::getInstance()->isBlack()) {
	  (*_cursor)->GET_CMP(ButtonCmp)->execute();
      }
      return;
  }
  auto playerInputCmp = Scene::getPlayerInput()->GET_CMP(InputCmp);
  if (checkConfirmButton(playerInputCmp->_isJump)){
      Graphics::getInstance()->fadeOut(1.5f);
      _trigged = true;
  } else if (checkUpButton(playerInputCmp->_isUp)) {
	  _darker();
	  if (_cursor == _buttons.begin()) {
		  _cursor = --(_buttons.end());
	  } else {
		  --_cursor;
	  }
	  _brighter();
  } else if (checkDownButton(playerInputCmp->_isDown)) {
	  _darker();
	  ++_cursor;
	  if (_cursor == _buttons.end()) {
		  _cursor = _buttons.begin();
	  }
	  _brighter();
  }
}
예제 #2
0
static colour
brighten(colour c, colour against)
{
  uint r = red(c), g = green(c), b = blue(c);
  // "brighten" away from the background:
  // if we are closer to black than the contrast reference, rather darken
  bool darken = colour_dist(c, 0) < colour_dist(against, 0);
#ifdef debug_brighten
  printf ("%s %06X against %06X\n", darken ? "darkening" : "brighting", c, against);
#endif

  uint _brighter() {
    uint s = min(85, 255 - max(max(r, g), b));
    return make_colour(r + s, g + s, b + s);
  }
  uint _darker() {
    int sub = 70;
    return make_colour(max(0, (int)r - sub), max(0, (int)g - sub), max(0, (int)b - sub));
  }

  colour bright;
  uint thrsh = 22222;  // contrast threshhold;
                       // if we're closer to either fg or bg,
                       // turn "brightening" into the other direction

  if (darken) {
    bright = _darker();
#ifdef debug_brighten
    printf ("darker %06X -> %06X dist %d\n", c, bright, colour_dist(c, bright));
#endif
    if (colour_dist(bright, c) < thrsh || colour_dist(bright, against) < thrsh) {
      bright = _brighter();
#ifdef debug_brighten
      printf ("   fix %06X -> %06X dist %d/%d\n", c, bright, colour_dist(bright, c), colour_dist(bright, against));
#endif
    }
  }
  else {
    bright = _brighter();
#ifdef debug_brighten
    printf ("lightr %06X -> %06X dist %d\n", c, bright, colour_dist(c, bright));
#endif
    if (colour_dist(bright, c) < thrsh || colour_dist(bright, against) < thrsh) {
      bright = _darker();
#ifdef debug_brighten
      printf ("   fix %06X -> %06X dist %d/%d\n", c, bright, colour_dist(bright, c), colour_dist(bright, against));
#endif
    }
  }

  return bright;
}