本文整理汇总了C++中DrawingContext::draw_surface方法的典型用法代码示例。如果您正苦于以下问题:C++ DrawingContext::draw_surface方法的具体用法?C++ DrawingContext::draw_surface怎么用?C++ DrawingContext::draw_surface使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DrawingContext
的用法示例。
在下文中一共展示了DrawingContext::draw_surface方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Vector
void
InfoBox::draw(DrawingContext& context)
{
float x1 = 200;
float y1 = 100;
float width = 400;
float height = 200;
context.draw_filled_rect(Vector(x1, y1), Vector(width, height),
Color(0.6f, 0.7f, 0.8f, 0.5f), LAYER_GUI-1);
float y = y1;
for(size_t i = firstline; i < lines.size(); ++i) {
if(y >= y1 + height) break;
lines[i]->draw(context, Vector(x1, y), LAYER_GUI);
y += lines[i]->get_height();
// draw the scrolling arrows
if (arrow_scrollup && firstline > 0)
context.draw_surface(arrow_scrollup,
Vector( x1 + width - arrow_scrollup->get_width(), // top-right corner of box
y1), LAYER_GUI);
if (arrow_scrolldown && firstline < lines.size()-1)
context.draw_surface(arrow_scrolldown,
Vector( x1 + width - arrow_scrolldown->get_width(), // bottom-light corner of box
y1 + height - arrow_scrolldown->get_height()),
LAYER_GUI);
}
}
示例2: int
void
Background::draw(DrawingContext& context)
{
if(image.get() == NULL)
return;
int w = (int) image->get_width();
int h = (int) image->get_height();
int sx = int(pos.x-context.get_translation().x * speed) % w - w;
int sy = int(pos.y-context.get_translation().y * speed_y) % h - h;
int center_image_py = int(pos.y-context.get_translation().y * speed_y);
int bottom_image_py = int(pos.y-context.get_translation().y * speed_y) + h;
context.push_transform();
context.set_translation(Vector(0, 0));
for(int x = sx; x < SCREEN_WIDTH; x += w) {
for(int y = sy; y < SCREEN_HEIGHT; y += h) {
if (image_top.get() != NULL && (y < center_image_py)) {
context.draw_surface(image_top.get(), Vector(x, y), layer);
continue;
}
if (image_bottom.get() != NULL && (y >= bottom_image_py)) {
context.draw_surface(image_bottom.get(), Vector(x, y), layer);
continue;
}
context.draw_surface(image.get(), Vector(x, y), layer);
}
}
context.pop_transform();
}
示例3: if
void
Tile::draw(DrawingContext& context, const Vector& pos, int z_pos) const
{
if(images.size() > 1) {
size_t frame = size_t(game_time * anim_fps) % images.size();
context.draw_surface(images[frame], pos, z_pos);
} else if (images.size() == 1) {
context.draw_surface(images[0], pos, z_pos);
}
}
示例4: Vector
void
Console::draw(DrawingContext& context)
{
if (m_height == 0)
return;
int layer = LAYER_GUI + 1;
context.push_transform();
context.set_alpha(m_alpha);
context.draw_surface(m_background2,
Vector(SCREEN_WIDTH/2 - m_background->get_width()/2 - m_background->get_width() + m_backgroundOffset,
m_height - m_background->get_height()),
layer);
context.draw_surface(m_background2,
Vector(SCREEN_WIDTH/2 - m_background->get_width()/2 + m_backgroundOffset,
m_height - m_background->get_height()),
layer);
for (int x = (SCREEN_WIDTH/2 - m_background->get_width()/2
- (static_cast<int>(ceilf((float)SCREEN_WIDTH /
(float)m_background->get_width()) - 1) * m_background->get_width()));
x < SCREEN_WIDTH;
x += m_background->get_width())
{
context.draw_surface(m_background, Vector(x, m_height - m_background->get_height()), layer);
}
m_backgroundOffset+=10;
if (m_backgroundOffset > (int)m_background->get_width()) m_backgroundOffset -= (int)m_background->get_width();
int lineNo = 0;
if (m_focused) {
lineNo++;
float py = m_height-4-1 * m_font->get_height();
context.draw_text(m_font, "> "+m_inputBuffer, Vector(4, py), ALIGN_LEFT, layer);
if (SDL_GetTicks() % 1000 < 750) {
int cursor_px = 2 + m_inputBufferPosition;
context.draw_text(m_font, "_", Vector(4 + (cursor_px * m_font->get_text_width("X")), py), ALIGN_LEFT, layer);
}
}
int skipLines = -m_offset;
for (std::list<std::string>::iterator i = m_buffer.m_lines.begin(); i != m_buffer.m_lines.end(); i++)
{
if (skipLines-- > 0) continue;
lineNo++;
float py = m_height - 4 - lineNo * m_font->get_height();
if (py < -m_font->get_height()) break;
context.draw_text(m_font, *i, Vector(4, py), ALIGN_LEFT, layer);
}
context.pop_transform();
}
示例5: draw
void ParticleSystem::draw(DrawingContext& context)
{
float scrollx = context.get_translation().x;
float scrolly = context.get_translation().y;
context.push_transform();
context.set_translation(Vector(max_particle_size,max_particle_size));
std::vector<Particle*>::iterator i;
for(i = particles.begin(); i != particles.end(); ++i) {
Particle* particle = *i;
// remap x,y coordinates onto screencoordinates
Vector pos;
pos.x = fmodf(particle->pos.x - scrollx, virtual_width);
if(pos.x < 0) pos.x += virtual_width;
pos.y = fmodf(particle->pos.y - scrolly, virtual_height);
if(pos.y < 0) pos.y += virtual_height;
//if(pos.x > virtual_width) pos.x -= virtual_width;
//if(pos.y > virtual_height) pos.y -= virtual_height;
context.draw_surface(particle->texture, pos, particle->angle, Color(1.0f, 1.0f, 1.0f), Blend(), z_pos);
}
context.pop_transform();
}
示例6: Vector
void
ItemToggle::draw(DrawingContext& context, const Vector& pos, int menu_width, bool active) {
context.draw_text(Resources::normal_font, text,
Vector(pos.x + 16, pos.y - (Resources::normal_font->get_height()/2)),
ALIGN_LEFT, LAYER_GUI, active ? ColorScheme::Menu::active_color : get_color());
if(*toggled) {
context.draw_surface(Resources::checkbox_checked,
Vector(pos.x + menu_width-16 - Resources::checkbox->get_width(), pos.y - 8),
LAYER_GUI + 1);
} else {
context.draw_surface(Resources::checkbox,
Vector(pos.x + menu_width-16 - Resources::checkbox->get_width(), pos.y - 8),
LAYER_GUI + 1);
}
}
示例7: Vector
void
ItemBack::draw(DrawingContext& context, Vector pos, int menu_width, bool active) {
float text_width = Resources::normal_font->get_text_width(text);
context.draw_text(Resources::normal_font, text,
Vector( pos.x + menu_width/2 , pos.y - int(Resources::normal_font->get_height()/2)),
ALIGN_CENTER, LAYER_GUI, active ? ColorScheme::Menu::active_color : get_color());
context.draw_surface(Resources::back,
Vector(pos.x + menu_width/2 + text_width/2 + 16, pos.y - 8),
LAYER_GUI);
}
示例8: Vector
void
ItemStringSelect::draw(DrawingContext& context, const Vector& pos, int menu_width, bool active) {
float roff = Resources::arrow_left->get_width();
float sel_width = Resources::normal_font->get_text_width(list[*selected]);
// Draw left side
context.draw_text(Resources::normal_font, text,
Vector(pos.x + 16, pos.y - int(Resources::normal_font->get_height()/2)),
ALIGN_LEFT, LAYER_GUI, active ? ColorScheme::Menu::active_color : get_color());
// Draw right side
context.draw_surface(Resources::arrow_left,
Vector(pos.x + menu_width - sel_width - 2*roff - 8, pos.y - 8),
LAYER_GUI);
context.draw_surface(Resources::arrow_right,
Vector(pos.x + menu_width - roff - 8, pos.y - 8),
LAYER_GUI);
context.draw_text(Resources::normal_font, list[*selected],
Vector(pos.x + menu_width - roff - 8, pos.y - int(Resources::normal_font->get_height()/2)),
ALIGN_RIGHT, LAYER_GUI, active ? ColorScheme::Menu::active_color : get_color());
}
示例9: if
void
Tile::draw(DrawingContext& context, const Vector& pos, int z_pos) const
{
if(draw_editor_images) {
if(editor_images.size() > 1) {
size_t frame = size_t(game_time * fps) % editor_images.size();
context.draw_surface(editor_images[frame], pos, z_pos);
return;
} else if (editor_images.size() == 1) {
context.draw_surface(editor_images[0], pos, z_pos);
return;
}
}
if(images.size() > 1) {
size_t frame = size_t(game_time * fps) % images.size();
context.draw_surface(images[frame], pos, z_pos);
} else if (images.size() == 1) {
context.draw_surface(images[0], pos, z_pos);
}
}
示例10: draw
void ParticleSystem_Interactive::draw(DrawingContext& context)
{
context.push_transform();
std::vector<Particle*>::iterator i;
for(i = particles.begin(); i != particles.end(); ++i) {
Particle* particle = *i;
context.draw_surface(particle->texture, particle->pos, z_pos);
}
context.pop_transform();
}
示例11: draw
void ParticleSystem_Interactive::draw(DrawingContext& context)
{
if(!enabled)
return;
context.push_transform();
for(auto& particle : particles) {
context.draw_surface(particle->texture, particle->pos, z_pos);
}
context.pop_transform();
}
示例12:
void
BonusBlock::draw(DrawingContext& context){
// do the regular drawing first
Block::draw(context);
// then Draw the light if on.
if(sprite->get_action() == "on") {
Vector pos = get_pos() + (bbox.get_size().as_vector() - lightsprite->get_size()) / 2;
context.push_target();
context.set_target(DrawingContext::LIGHTMAP);
context.draw_surface(lightsprite, pos, 10);
context.pop_target();
}
}
示例13: Vector
void
InfoBox::draw(DrawingContext& context)
{
float x1 = SCREEN_WIDTH/2-200;
float y1 = SCREEN_HEIGHT/2-200;
float width = 400;
float height = 200;
context.draw_filled_rect(Vector(x1, y1), Vector(width, height),
Color(0.6f, 0.7f, 0.8f, 0.5f), LAYER_GUI-1);
float y = y1;
bool linesLeft = false;
for(size_t i = firstline; i < lines.size(); ++i) {
if(y >= y1 + height) {
linesLeft = true;
break;
}
lines[i]->draw(context, Rectf(x1, y, x1+width, y), LAYER_GUI);
y += lines[i]->get_height();
}
{
// draw the scrolling arrows
if (arrow_scrollup.get() && firstline > 0)
context.draw_surface(arrow_scrollup,
Vector( x1 + width - arrow_scrollup->get_width(), // top-right corner of box
y1), LAYER_GUI);
if (arrow_scrolldown.get() && linesLeft && firstline < lines.size()-1)
context.draw_surface(arrow_scrolldown,
Vector( x1 + width - arrow_scrolldown->get_width(), // bottom-light corner of box
y1 + height - arrow_scrolldown->get_height()),
LAYER_GUI);
}
}
示例14: Vector
void
LayerIcon::draw(DrawingContext& context, Vector pos) {
if (!is_valid()) return;
ObjectIcon::draw(context,pos);
int l = get_zpos();
if (l != std::numeric_limits<int>::min()) {
context.draw_text(Resources::small_font, std::to_string(l),
pos + Vector(16,16),
ALIGN_CENTER, LAYER_GUI, ColorScheme::Menu::default_color);
if (is_tilemap) if (((TileMap*)layer)->editor_active) {
context.draw_surface(selection, pos, LAYER_GUI - 1);
}
}
}
示例15: switch
void
InfoBoxLine::draw(DrawingContext& context, const Vector& position, int layer)
{
switch (lineType) {
case IMAGE:
context.draw_surface(image, Vector( (SCREEN_WIDTH - image->get_width()) / 2, position.y), layer);
break;
case NORMAL_LEFT:
context.draw_text(font, text, Vector(position.x, position.y), LEFT_ALLIGN, layer);
break;
default:
context.draw_text(font, text, Vector(SCREEN_WIDTH/2, position.y), CENTER_ALLIGN, layer);
break;
}
}