当前位置: 首页>>代码示例>>C++>>正文


C++ DrawingContext::draw方法代码示例

本文整理汇总了C++中DrawingContext::draw方法的典型用法代码示例。如果您正苦于以下问题:C++ DrawingContext::draw方法的具体用法?C++ DrawingContext::draw怎么用?C++ DrawingContext::draw使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DrawingContext的用法示例。


在下文中一共展示了DrawingContext::draw方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: DeformDrawerRequest

void
DeformDrawer::draw(DrawingContext& dc, ParticleSystem& psys)
{
  dc.draw(new DeformDrawerRequest(Vector2f(400, 300), 1200, dc.get_modelview(), 
                                  framebuffer, surface, psys, shader_program));
}
开发者ID:BackupTheBerlios,项目名称:windstille-svn,代码行数:6,代码来源:deform_drawer.cpp

示例2: if

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);
}
开发者ID:drewbug,项目名称:pingus,代码行数:80,代码来源:result_screen.cpp

示例3: canvas

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);
}
开发者ID:jcs12311,项目名称:pingus,代码行数:62,代码来源:collision_map.cpp


注:本文中的DrawingContext::draw方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。