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


C++ Tileset::get_tiles_image方法代码示例

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


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

示例1: display

/**
 * @brief Displays the tile image on a surface.
 * @param destination the destination surface
 * @param dst_position position of the tile pattern on the destination surface
 * @param tileset the tileset of this tile
 */
void ParallaxTilePattern::display(Surface *destination, const Rectangle &dst_position, Tileset &tileset) {

  Rectangle src = position_in_tileset;
  Rectangle dst = dst_position;

  int offset_x, offset_y; // display the tile with an offset that depends on its position modulo its size

  if (dst.get_x() >= 0) {
    offset_x = dst.get_x() % src.get_width();
  }
  else { // the modulo operation does not like negative numbers
    offset_x = src.get_width() - (-dst.get_x() % src.get_width());
  }

  if (dst.get_y() >= 0) {
    offset_y = dst.get_y() % src.get_height();
  }
  else {
    offset_y = src.get_height() - (-dst.get_y() % src.get_height());
  }

  // apply a scrolling ratio
  offset_x /= 2;
  offset_y /= 2;

  src.add_x(offset_x);
  src.add_width(-offset_x);
  src.add_y(offset_y);
  src.add_height(-offset_y);
  tileset.get_tiles_image()->blit(src, destination, dst);

  src = position_in_tileset;
  dst = dst_position;
  src.add_y(offset_y);
  src.add_height(-offset_y);
  dst.add_x(src.get_width() - offset_x);
  src.set_width(offset_x);
  tileset.get_tiles_image()->blit(src, destination, dst);

  src = position_in_tileset;
  dst = dst_position;
  src.add_x(offset_x);
  src.add_width(-offset_x);
  dst.add_y(src.get_height() - offset_y);
  src.set_height(offset_y);
  tileset.get_tiles_image()->blit(src, destination, dst);

  src = position_in_tileset;
  dst = dst_position;
  dst.add_x(src.get_width() - offset_x);
  src.set_width(offset_x);
  dst.add_y(src.get_height() - offset_y);
  src.set_height(offset_y);
  tileset.get_tiles_image()->blit(src, destination, dst);
}
开发者ID:ziz,项目名称:solarus,代码行数:61,代码来源:ParallaxTilePattern.cpp

示例2: draw

/**
 * \brief Draws the tile image on a surface.
 * \param dst_surface the surface to draw
 * \param dst_position position where tile pattern should be drawn on dst_surface
 * \param tileset the tileset of this tile
 * \param viewport coordinates of the top-left corner of dst_surface relative
 * to the map (may be used for scrolling tiles)
 */
void SimpleTilePattern::draw(
    const SurfacePtr& dst_surface,
    const Point& dst_position,
    Tileset& tileset,
    const Point& /* viewport */
) {
  const SurfacePtr& tileset_image = tileset.get_tiles_image();
  tileset_image->draw_region(position_in_tileset, dst_surface, dst_position);
}
开发者ID:Maxs1789,项目名称:solarus,代码行数:17,代码来源:SimpleTilePattern.cpp

示例3: draw

/**
 * \brief Draws the tile image on a surface.
 * \param dst_surface the surface to draw
 * \param dst_position position where tile pattern should be drawn on dst_surface
 * \param tileset the tileset of this tile
 * \param viewport coordinates of the top-left corner of dst_surface relative
 * to the map (may be used for scrolling tiles)
 */
void TimeScrollingTilePattern::draw(
    const SurfacePtr& dst_surface,
    const Point& dst_position,
    Tileset& tileset,
    const Point& /* viewport */
) {
  Rectangle src = position_in_tileset;
  Point dst = dst_position;

  Point offset; // draw the tile with an offset that depends on the time

  offset.x = src.get_width() - (shift % src.get_width());
  offset.y = shift % src.get_height();

  src.add_x(offset.x);
  src.add_width(-offset.x);
  src.add_y(offset.y);
  src.add_height(-offset.y);
  tileset.get_tiles_image()->draw_region(src, dst_surface, dst);

  src = position_in_tileset;
  dst = dst_position;
  src.add_y(offset.y);
  src.add_height(-offset.y);
  dst.x += src.get_width() - offset.x;
  src.set_width(offset.x);
  tileset.get_tiles_image()->draw_region(src, dst_surface, dst);

  src = position_in_tileset;
  dst = dst_position;
  src.add_x(offset.x);
  src.add_width(-offset.x);
  dst.y += src.get_height() - offset.y;
  src.set_height(offset.y);
  tileset.get_tiles_image()->draw_region(src, dst_surface, dst);

  src = position_in_tileset;
  dst = dst_position;
  dst.x += src.get_width() - offset.x;
  src.set_width(offset.x);
  dst.y += src.get_height() - offset.y;
  src.set_height(offset.y);
  tileset.get_tiles_image()->draw_region(src, dst_surface, dst);
}
开发者ID:Codex-NG,项目名称:solarus,代码行数:52,代码来源:TimeScrollingTilePattern.cpp

示例4: draw

/**
 * @brief Draws the tile image on a surface.
 * @param dst_surface the surface to draw
 * @param dst_position position where tile pattern should be drawn on dst_surface
 * @param tileset the tileset of this tile
 * @param viewport coordinates of the top-left corner of dst_surface relative
 * to the map (may be used for scrolling tiles)
 */
void ParallaxScrollingTilePattern::draw(Surface& dst_surface,
    const Rectangle& dst_position, Tileset& tileset,
    const Rectangle& viewport) {

  Surface& tileset_image = tileset.get_tiles_image();
  Rectangle dst(dst_position);
  dst.add_xy(viewport.get_x() / ratio, viewport.get_y() / ratio);
  tileset_image.draw_region(position_in_tileset, dst_surface, dst);

  // one day, we can implement several scrolling layers just by changing the ratio
}
开发者ID:lambdaloop,项目名称:solarus,代码行数:19,代码来源:ParallaxScrollingTilePattern.cpp

示例5: display

/**
 * @brief Displays the tile image on a surface.
 * @param dst_surface the surface to draw
 * @param dst_position position where tile pattern should be displayed on dst_surface
 * @param tileset the tileset of this tile
 * @param viewport coordinates of the top-left corner of dst_surface relative
 * to the map (may be used for scrolling tiles)
 */
void TimeScrollingTilePattern::display(Surface* dst_surface, const Rectangle& dst_position,
    Tileset& tileset, const Rectangle& viewport) {

  Rectangle src = position_in_tileset;
  Rectangle dst = dst_position;

  int offset_x, offset_y; // display the tile with an offset that depends on the time

  offset_x = src.get_width() - (shift % src.get_width());
  offset_y = shift % src.get_height();

  src.add_x(offset_x);
  src.add_width(-offset_x);
  src.add_y(offset_y);
  src.add_height(-offset_y);
  tileset.get_tiles_image()->blit(src, dst_surface, dst);

  src = position_in_tileset;
  dst = dst_position;
  src.add_y(offset_y);
  src.add_height(-offset_y);
  dst.add_x(src.get_width() - offset_x);
  src.set_width(offset_x);
  tileset.get_tiles_image()->blit(src, dst_surface, dst);

  src = position_in_tileset;
  dst = dst_position;
  src.add_x(offset_x);
  src.add_width(-offset_x);
  dst.add_y(src.get_height() - offset_y);
  src.set_height(offset_y);
  tileset.get_tiles_image()->blit(src, dst_surface, dst);

  src = position_in_tileset;
  dst = dst_position;
  dst.add_x(src.get_width() - offset_x);
  src.set_width(offset_x);
  dst.add_y(src.get_height() - offset_y);
  src.set_height(offset_y);
  tileset.get_tiles_image()->blit(src, dst_surface, dst);
}
开发者ID:Aerospyke,项目名称:solarus,代码行数:49,代码来源:TimeScrollingTilePattern.cpp

示例6: display

/**
 * @brief Displays the tile image on a surface.
 * @param dst_surface the surface to draw
 * @param dst_position position where tile pattern should be displayed on dst_surface
 * @param tileset the tileset of this tile
 * @param viewport coordinates of the top-left corner of dst_surface relative
 * to the map (may be used for scrolling tiles)
 */
void AnimatedTilePattern::display(Surface* dst_surface, const Rectangle& dst_position,
    Tileset& tileset, const Rectangle& viewport) {

  Surface* tileset_image = tileset.get_tiles_image();
  const Rectangle& src = position_in_tileset[current_frames[sequence]];
  Rectangle dst(dst_position);

  if (parallax) {
    dst.add_xy(viewport.get_x() / ParallaxScrollingTilePattern::ratio,
        viewport.get_y() / ParallaxScrollingTilePattern::ratio);
  }

  tileset_image->blit(src, dst_surface, dst);
}
开发者ID:Aerospyke,项目名称:solarus,代码行数:22,代码来源:AnimatedTilePattern.cpp

示例7: draw

/**
 * \brief Draws the tile image on a surface.
 * \param dst_surface the surface to draw
 * \param dst_position position where tile pattern should be drawn on dst_surface
 * \param tileset the tileset of this tile
 * \param viewport coordinates of the top-left corner of dst_surface relative
 * to the map (may be used for scrolling tiles)
 */
void AnimatedTilePattern::draw(
    const SurfacePtr& dst_surface,
    const Point& dst_position,
    Tileset& tileset,
    const Point& viewport
) {
  const SurfacePtr& tileset_image = tileset.get_tiles_image();
  const Rectangle& src = position_in_tileset[current_frames[sequence]];
  Point dst = dst_position;

  if (parallax) {
    dst += viewport / ParallaxScrollingTilePattern::ratio;
  }

  tileset_image->draw_region(src, dst_surface, dst);
}
开发者ID:Codex-NG,项目名称:solarus,代码行数:24,代码来源:AnimatedTilePattern.cpp

示例8: draw

/**
 * \brief Draws the tile image on a surface.
 * \param dst_surface the surface to draw
 * \param dst_position position where tile pattern should be drawn on dst_surface
 * \param tileset the tileset of this tile
 * \param viewport coordinates of the top-left corner of dst_surface relative
 * to the map (may be used for scrolling tiles)
 */
void SelfScrollingTilePattern::draw(
    const SurfacePtr& dst_surface,
    const Point& dst_position, Tileset& tileset,
    const Point& /* viewport */) {

  Rectangle src = position_in_tileset;
  Point dst = dst_position;

  // draw the tile with an offset that depends on its position modulo its size
  Point offset;

  if (dst.x >= 0) {
    offset.x = dst.x % src.get_width();
  }
  else { // the modulo operation does not like negative numbers
    offset.x = src.get_width() - (-dst.x % src.get_width());
  }

  if (dst.y >= 0) {
    offset.y = dst.y % src.get_height();
  }
  else {
    offset.y = src.get_height() - (-dst.y % src.get_height());
  }

  // apply a scrolling ratio
  offset /= 2;

  // draw the pattern in four steps
  const SurfacePtr& tileset_image = tileset.get_tiles_image();

  src.add_x(offset.x);
  src.add_width(-offset.x);
  src.add_y(offset.y);
  src.add_height(-offset.y);
  tileset_image->draw_region(src, dst_surface, dst);

  src = position_in_tileset;
  dst = dst_position;
  src.add_y(offset.y);
  src.add_height(-offset.y);
  dst.x += src.get_width() - offset.x;
  src.set_width(offset.x);
  tileset_image->draw_region(src, dst_surface, dst);

  src = position_in_tileset;
  dst = dst_position;
  src.add_x(offset.x);
  src.add_width(-offset.x);
  dst.y += src.get_height() - offset.y;
  src.set_height(offset.y);
  tileset_image->draw_region(src, dst_surface, dst);

  src = position_in_tileset;
  dst = dst_position;
  dst.x += src.get_width() - offset.x;
  src.set_width(offset.x);
  dst.y += src.get_height() - offset.y;
  src.set_height(offset.y);
  tileset_image->draw_region(src, dst_surface, dst);
}
开发者ID:Codex-NG,项目名称:solarus,代码行数:69,代码来源:SelfScrollingTilePattern.cpp

示例9: draw

/**
 * @brief Draws the tile image on a surface.
 * @param dst_surface the surface to draw
 * @param dst_position position where tile pattern should be drawn on dst_surface
 * @param tileset the tileset of this tile
 * @param viewport coordinates of the top-left corner of dst_surface relative
 * to the map (may be used for scrolling tiles)
 */
void SelfScrollingTilePattern::draw(Surface& dst_surface,
    const Rectangle& dst_position, Tileset& tileset,
    const Rectangle& viewport) {

  Rectangle src = position_in_tileset;
  Rectangle dst = dst_position;

  // draw the tile with an offset that depends on its position modulo its size
  int offset_x, offset_y;

  if (dst.get_x() >= 0) {
    offset_x = dst.get_x() % src.get_width();
  }
  else { // the modulo operation does not like negative numbers
    offset_x = src.get_width() - (-dst.get_x() % src.get_width());
  }

  if (dst.get_y() >= 0) {
    offset_y = dst.get_y() % src.get_height();
  }
  else {
    offset_y = src.get_height() - (-dst.get_y() % src.get_height());
  }

  // apply a scrolling ratio
  offset_x /= 2;
  offset_y /= 2;

  // draw the pattern in four steps
  Surface& tileset_image = tileset.get_tiles_image();

  src.add_x(offset_x);
  src.add_width(-offset_x);
  src.add_y(offset_y);
  src.add_height(-offset_y);
  tileset_image.draw_region(src, dst_surface, dst);

  src = position_in_tileset;
  dst = dst_position;
  src.add_y(offset_y);
  src.add_height(-offset_y);
  dst.add_x(src.get_width() - offset_x);
  src.set_width(offset_x);
  tileset_image.draw_region(src, dst_surface, dst);

  src = position_in_tileset;
  dst = dst_position;
  src.add_x(offset_x);
  src.add_width(-offset_x);
  dst.add_y(src.get_height() - offset_y);
  src.set_height(offset_y);
  tileset_image.draw_region(src, dst_surface, dst);

  src = position_in_tileset;
  dst = dst_position;
  dst.add_x(src.get_width() - offset_x);
  src.set_width(offset_x);
  dst.add_y(src.get_height() - offset_y);
  src.set_height(offset_y);
  tileset_image.draw_region(src, dst_surface, dst);
}
开发者ID:lambdaloop,项目名称:solarus,代码行数:69,代码来源:SelfScrollingTilePattern.cpp

示例10: draw

/**
 * @brief Draws the tile image on a surface.
 * @param dst_surface the surface to draw
 * @param dst_position position where tile pattern should be drawn on dst_surface
 * @param tileset the tileset of this tile
 * @param viewport coordinates of the top-left corner of dst_surface relative
 * to the map (may be used for scrolling tiles)
 */
void SimpleTilePattern::draw(Surface& dst_surface, const Rectangle& dst_position,
    Tileset& tileset, const Rectangle& viewport) {

  Surface& tileset_image = tileset.get_tiles_image();
  tileset_image.draw_region(position_in_tileset, dst_surface, dst_position);
}
开发者ID:lambdaloop,项目名称:solarus,代码行数:14,代码来源:SimpleTilePattern.cpp

示例11: display

/**
 * @brief Displays the tile on a surface.
 * @param destination the destination surface
 * @param dst_position position of the tile pattern on the destination surface
 * @param tileset the tileset of this tile pattern
 */
void AnimatedTilePattern::display(Surface *destination, const Rectangle &dst_position, Tileset &tileset) {

  Surface *tileset_image = tileset.get_tiles_image();
  tileset_image->blit(position_in_tileset[current_frames[sequence]], destination, dst_position);
}
开发者ID:ziz,项目名称:solarus,代码行数:11,代码来源:AnimatedTilePattern.cpp


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