本文整理汇总了C++中Text::blit方法的典型用法代码示例。如果您正苦于以下问题:C++ Text::blit方法的具体用法?C++ Text::blit怎么用?C++ Text::blit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Text
的用法示例。
在下文中一共展示了Text::blit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: draw
/**
* Draws the view of all the facilities in the base, connectors
* between them and crafts landed in hangars.
*/
void BaseView::draw()
{
Surface::draw();
// Draw grid squares
for (int x = 0; x < 8; ++x)
{
for (int y = 0; y < 8; ++y)
{
Surface *frame = _texture->getFrame(0);
frame->setX(x * GRID_SIZE);
frame->setY(y * GRID_SIZE);
frame->blit(this);
}
}
std::vector<Craft*>::iterator craft = _base->getCrafts()->begin();
for (std::vector<BaseFacility*>::iterator i = _base->getFacilities()->begin(); i != _base->getFacilities()->end(); ++i)
{
// Draw facility shape
int num = 0;
for (int y = (*i)->getY(); y < (*i)->getY() + (*i)->getRules()->getSize(); ++y)
{
for (int x = (*i)->getX(); x < (*i)->getX() + (*i)->getRules()->getSize(); ++x)
{
Surface *frame;
if ((*i)->getBuildTime() == 0)
frame = _texture->getFrame((*i)->getRules()->getSpriteShape() + num);
else
frame = _texture->getFrame((*i)->getRules()->getSpriteShape() + num + 2 + (*i)->getRules()->getSize());
frame->setX(x * GRID_SIZE);
frame->setY(y * GRID_SIZE);
frame->blit(this);
num++;
}
}
}
for (std::vector<BaseFacility*>::iterator i = _base->getFacilities()->begin(); i != _base->getFacilities()->end(); ++i)
{
// Draw connectors
if ((*i)->getBuildTime() == 0)
{
// Facilities to the right
int x = (*i)->getX() + (*i)->getRules()->getSize();
if (x < BASE_SIZE)
{
for (int y = (*i)->getY(); y < (*i)->getY() + (*i)->getRules()->getSize(); ++y)
{
if (_facilities[x][y] != 0 && _facilities[x][y]->getBuildTime() == 0)
{
Surface *frame = _texture->getFrame(7);
frame->setX(x * GRID_SIZE - GRID_SIZE / 2);
frame->setY(y * GRID_SIZE);
frame->blit(this);
}
}
}
// Facilities to the bottom
int y = (*i)->getY() + (*i)->getRules()->getSize();
if (y < BASE_SIZE)
{
for (int x = (*i)->getX(); x < (*i)->getX() + (*i)->getRules()->getSize(); ++x)
{
if (_facilities[x][y] != 0 && _facilities[x][y]->getBuildTime() == 0)
{
Surface *frame = _texture->getFrame(8);
frame->setX(x * GRID_SIZE);
frame->setY(y * GRID_SIZE - GRID_SIZE / 2);
frame->blit(this);
}
}
}
}
}
for (std::vector<BaseFacility*>::iterator i = _base->getFacilities()->begin(); i != _base->getFacilities()->end(); ++i)
{
// Draw facility graphic
int num = 0;
for (int y = (*i)->getY(); y < (*i)->getY() + (*i)->getRules()->getSize(); ++y)
{
for (int x = (*i)->getX(); x < (*i)->getX() + (*i)->getRules()->getSize(); ++x)
{
if ((*i)->getRules()->getSize() == 1)
{
Surface *frame = _texture->getFrame((*i)->getRules()->getSpriteFacility() + num);
frame->setX(x * GRID_SIZE);
frame->setY(y * GRID_SIZE);
frame->blit(this);
}
//.........这里部分代码省略.........
示例2: Surface
/**
* Initializes all the elements in the test palette screen.
*/
TestPaletteState::TestPaletteState(const std::string &palette, bool highContrast)
{
// Create objects
_bg = new Surface(320, 200, 0, 0);
_btnCancel = new TextButton(60, 9, 240, 190);
// Set palette
setPalette(palette);
add(_bg);
add(_btnCancel);
centerAllSurfaces();
_btnCancel->onMouseClick((ActionHandler)&TestPaletteState::btnCancelClick);
_btnCancel->onKeyboardPress((ActionHandler)&TestPaletteState::btnCancelClick, Options::keyCancel);
bool ctrlPressed = SDL_GetModState() & KMOD_CTRL;
bool shiftPressed = SDL_GetModState() & KMOD_SHIFT;
// basic palette
if (ctrlPressed)
{
Surface surf = Surface(20, 11, 0, 0);
surf.setPalette(_bg->getPalette());
for (int row = 0; row < 16; ++row)
{
for (int column = 0; column < 16; ++column)
{
int index = row * 16 + column;
surf.setX(column * 20);
surf.setY(row * 11);
surf.drawRect(0, 0, 20, 11, index);
surf.blit(_bg);
}
}
return;
}
// small digits without/with border
if (shiftPressed)
{
NumberText text = NumberText(25, 9, 0, 0);
text.setPalette(_bg->getPalette());
text.initText(_game->getMod()->getFont("FONT_BIG"), _game->getMod()->getFont("FONT_SMALL"), _game->getLanguage());
text.setBordered(highContrast);
for (int row = 0; row < 22; ++row)
{
for (int column = 0; column < 12; ++column)
{
int index = row * 12 + column;
if (index > 255)
{
return;
}
text.setColor(index);
text.setX(column * 26);
text.setY(row * 9);
text.setValue(index);
text.blit(_bg);
}
}
return;
}
// normal text without/with high contrast
Text text = Text(25, 9, 0, 0);
text.setPalette(_bg->getPalette());
text.initText(_game->getMod()->getFont("FONT_BIG"), _game->getMod()->getFont("FONT_SMALL"), _game->getLanguage());
text.setHighContrast(highContrast);
for (int row = 0; row < 22; ++row)
{
for (int column = 0; column < 12; ++column)
{
int index = row * 12 + column;
if (index > 255)
{
return;
}
text.setColor(index);
text.setX(column * 26);
text.setY(row * 9);
std::wostringstream ss;
ss << index;
text.setText(ss.str().c_str());
text.blit(_bg);
}
}
}