本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}