void
DeformDrawer::draw(DrawingContext& dc, ParticleSystem& psys)
{
  dc.draw(new DeformDrawerRequest(Vector2f(400, 300), 1200, dc.get_modelview(), 
                                  framebuffer, surface, psys, shader_program));
}
예제 #2
0
void
ResultScreenComponent::draw(DrawingContext& gc)
{
  // Paint the background wood panel
  for(int y = 0; y < gc.get_height(); y += background.get_height())
    for(int x = 0; x < gc.get_width(); x += background.get_width())
      gc.draw(background, Vector2i(x, y));

  gc.draw(blackboard, Vector2i(gc.get_width()/2, gc.get_height()/2));

  gc.print_center(Fonts::chalk_large,
                  Vector2i(gc.get_width()/2,
                           Display::get_height()/2 - 200),
                  _(result.plf.get_levelname()));

  if (result.success())
  {
    gc.print_center(Fonts::chalk_large,
                    Vector2i(gc.get_width()/2,
                             Display::get_height()/2 - 140),
                    _("Success!"));
    /*gc.print_center(Fonts::pingus_small, gc.get_width()/2, gc.get_height()-30,
      "..:: Press Space to continue ::..");*/
  }
  else
  {
    gc.print_center(Fonts::chalk_large,
                    Vector2i(gc.get_width()/2, Display::get_height()/2 - 140),
                    _("Failure!"));
    /*gc.print_center(Fonts::pingus_normal, gc.get_width()/2, gc.get_height()-30,
      "..:: Press Space to retry the level ::..");*/
  }

  std::string message;
  if (result.success())
  {
    if (result.killed == 0 && result.saved == result.total)
      message = _("Perfect! You saved everyone possible - great!");
    else if (result.killed == 0)
      message = _("No-one got killed, pretty good work.");
    else if (result.saved == result.needed)
      message = _("You saved exactly what you needed - you made it, but\n"
                  "maybe you can do better?");
    else if (result.killed >= 5)
      message = _("Not everybody was saved, but still good work!");
    else
      message = _("What can I say, you made it - congratulations!");
  }
  else
  {
    if (result.killed == result.total)
      message = _("You killed everybody, not good.");
    else if (result.saved == 0)
      message = _("No-one got saved - I know you can do better.");
    else if (result.saved > 0)
      message = _("You didn't save enough, but you saved a few.  Next\n"
                  "time you might do better.");
    else if (result.saved + 1 >= result.needed)
      message = _("Only one more and you would have made it - try again!");
    else if (result.saved + 5 >= result.needed)
      message = _("Only a handful more and you would have made it - try again!");
    else
      message = _("Better luck next time!");
  }
  gc.print_center(Fonts::chalk_normal, Vector2i(gc.get_width()/2, gc.get_height()/2 - 70), message);

  int left_x  = gc.get_width()/2 - 100;
  int right_x = gc.get_width()/2 + 100;
  int y = Display::get_height()/2 + 10;

  gc.print_left(Fonts::chalk_normal,  Vector2i(left_x,  y), _("Saved: "));
  gc.print_right(Fonts::chalk_normal, Vector2i(right_x, y), StringUtil::to_string(result.saved)
                 + "/" + StringUtil::to_string(result.needed));;

  gc.print_left(Fonts::chalk_normal,  Vector2i(left_x,  (y+=30)), _("Died: "));
  gc.print_right(Fonts::chalk_normal, Vector2i(right_x, y), StringUtil::to_string(result.killed));

  gc.print_left(Fonts::chalk_normal,  Vector2i(left_x, (y+=30)), _("Time left: "));
  gc.print_right(Fonts::chalk_normal, Vector2i(right_x, y), time_str);
}
예제 #3
0
void
CollisionMap::draw(DrawingContext& gc)
{
  Surface canvas(width, height);
  unsigned char* buffer;

  canvas.lock();
  buffer = static_cast<unsigned char*>(canvas.get_data());

#if SDL_BYTEORDER == SDL_BIG_ENDIAN
  const int red   = 3;
  const int green = 2;
  const int blue  = 1;
  const int alpha = 0;  
#else
  const int red   = 0;
  const int green = 1;
  const int blue  = 2;
  const int alpha = 3;
#endif

  uint8_t trans = 220;

  for(int i = 0; i < (width * height); ++i)
  {
    switch(colmap[i])
    {
      case Groundtype::GP_NOTHING:
        buffer[i * 4 + red  ] =   0;
        buffer[i * 4 + green] =   0;
        buffer[i * 4 + blue ] =   0;
        buffer[i * 4 + alpha] =   0;
        break;

      case Groundtype::GP_SOLID:
        buffer[i * 4 + red  ] = 100;
        buffer[i * 4 + green] = 100;
        buffer[i * 4 + blue ] = 100;
        buffer[i * 4 + alpha] = trans;
        break;

      case Groundtype::GP_BRIDGE:
        buffer[i * 4 + red  ] = 200;
        buffer[i * 4 + green] =   0;
        buffer[i * 4 + blue ] =   0;
        buffer[i * 4 + alpha] = trans;
        break;

      default:
        buffer[i * 4 + red  ] = 200;
        buffer[i * 4 + green] = 200;
        buffer[i * 4 + blue ] = 200;
        buffer[i * 4 + alpha] = trans;
        break;
    }
  }

  canvas.unlock();

  Sprite sprite(canvas);
  gc.draw(sprite, Vector2i(0, 0), 1000);
}