本文整理汇总了C++中Graphic::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ Graphic::clear方法的具体用法?C++ Graphic::clear怎么用?C++ Graphic::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Graphic
的用法示例。
在下文中一共展示了Graphic::clear方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: renderNative
void VisualMetatilePickerScene::renderNative(Graphic& dst,
Box srcbox) {
dst.clear(Color(255, 255, 255, Color::fullAlphaOpacity));
if ((tiles_ == NULL) || (metatiles_ == NULL)) {
return;
}
for (int i = 0; i < metatiles_->numMetatileMappings(); i++) {
MetatileStructure& metatile = metatiles_->metatileMapping(i);
int drawX = selectableIndexToDrawX(i);
int drawY = selectableIndexToDrawY(i);
TileRenderer::renderMetatile(dst,
Box(drawX, drawY,
MetatileStructure::metatileWidth,
MetatileStructure::metatileHeight),
metatile,
*tiles_,
*palette0_,
*palette1_,
tileOffset_);
}
}
示例2: drawMetatileEffect
void LevelEffectGraphicSceneLayer::drawMetatileEffect(
Graphic& metatileGraphic,
int indexNum,
const MetatileBehavior& behavior) {
metatileGraphic.clear(Color(0xFF, 0xFF, 0xFF, Color::fullAlphaOpacity));
switch (behavior.metatileType()) {
case MetatileTypes::nullType:
metatileGraphic.clear(
Color(0xFF, 0xFF, 0xFF, Color::fullAlphaOpacity));
break;
case MetatileTypes::climbable1:
case MetatileTypes::climbable2:
metatileGraphic.clear(
Color(0x88, 0x88, 0x88, Color::fullAlphaOpacity));
break;
// case MetatileTypes::climbable2:
// metatileGraphic.clear(
// Color(0xCC, 0xCC, 0xCC, Color::fullAlphaOpacity));
// break;
case MetatileTypes::nonclimbable:
metatileGraphic.clear(
Color(0x44, 0x44, 0x44, Color::fullAlphaOpacity));
// Color(0x22, 0x22, 0x22, Color::fullAlphaOpacity));
break;
case MetatileTypes::damaging:
metatileGraphic.clear(
Color(0xFF, 0x00, 0x00, Color::fullAlphaOpacity));
switch (indexNum) {
case 0x68:
case 0x69:
// up
for (int i = 0; i < 16; i += 8) {
metatileGraphic.drawLine(i, 15,
i + 4, 2,
Color(0xFF, 0xFF, 0x00,
Color::fullAlphaOpacity),
1);
metatileGraphic.drawLine(i + 4, 2,
i + 8, 15,
Color(0xFF, 0xFF, 0x00,
Color::fullAlphaOpacity),
1);
}
break;
case 0x6A:
case 0x6B:
// down
for (int i = 0; i < 16; i += 8) {
metatileGraphic.drawLine(i, 0,
i + 4, 13,
Color(0xFF, 0xFF, 0x00,
Color::fullAlphaOpacity),
1);
metatileGraphic.drawLine(i + 4, 13,
i + 8, 0,
Color(0xFF, 0xFF, 0x00,
Color::fullAlphaOpacity),
1);
}
break;
case 0x6C:
case 0x6D:
// right
for (int i = 0; i < 16; i += 8) {
metatileGraphic.drawLine(0, i,
13, i + 4,
Color(0xFF, 0xFF, 0x00,
Color::fullAlphaOpacity),
1);
metatileGraphic.drawLine(13, i + 4,
0, i + 8,
Color(0xFF, 0xFF, 0x00,
Color::fullAlphaOpacity),
1);
}
break;
case 0x6E:
case 0x6F:
// left
for (int i = 0; i < 16; i += 8) {
metatileGraphic.drawLine(15, i,
1, i + 4,
Color(0xFF, 0xFF, 0x00,
Color::fullAlphaOpacity),
1);
metatileGraphic.drawLine(2, i + 4,
15, i + 8,
Color(0xFF, 0xFF, 0x00,
Color::fullAlphaOpacity),
1);
}
break;
case 0x70:
case 0x71:
// all
default:
break;
}
break;
//.........这里部分代码省略.........
示例3: render
void MetatilePickerLayeredGraphicScene::render(Graphic& dst,
Box srcbox,
double scale) {
dst.clear();
int metatileNum = 0;
for (int j = 0; j < metatilesPerColumn_; j++) {
for (int i = 0; i < metatilesPerRow_; i++) {
if (bgLayerEnabled_) {
dst.blit(metatilesVisualBG_[metatileNum],
Box(i * MetatileStructure::metatileWidth,
j * MetatileStructure::metatileHeight,
MetatileStructure::metatileWidth,
MetatileStructure::metatileHeight),
Graphic::transUpdate);
}
if (fgLayerEnabled_) {
dst.blit(metatilesVisualFG_[metatileNum],
Box(i * MetatileStructure::metatileWidth,
j * MetatileStructure::metatileHeight,
MetatileStructure::metatileWidth,
MetatileStructure::metatileHeight),
Graphic::transUpdate);
}
if (effectLayerEnabled_) {
dst.blit(metatilesEffect_[metatileNum],
Box(i * MetatileStructure::metatileWidth,
j * MetatileStructure::metatileHeight,
MetatileStructure::metatileWidth,
MetatileStructure::metatileHeight),
Graphic::noTransUpdate);
}
if (verticalSolidityLayerEnabled_) {
dst.blit(metatilesVerticalSolidity_[metatileNum],
Box(i * MetatileStructure::metatileWidth,
j * MetatileStructure::metatileHeight,
MetatileStructure::metatileWidth,
MetatileStructure::metatileHeight),
Graphic::noTransUpdate);
}
if (horizontalSolidityLayerEnabled_) {
dst.blit(metatilesHorizontalSolidity_[metatileNum],
Box(i * MetatileStructure::metatileWidth,
j * MetatileStructure::metatileHeight,
MetatileStructure::metatileWidth,
MetatileStructure::metatileHeight),
Graphic::noTransUpdate);
}
++metatileNum;
}
}
if (gridLayerEnabled_) {
gridLayer_.render(dst,
Box(srcbox.x(),
srcbox.y(),
dst.w(),
dst.h()),
1.00);
}
if ((highlightedMetatileBoxEnabled_)) {
dst.drawRectBorder(metatileIndexToX(highlightedMetatileIndex_),
metatileIndexToY(highlightedMetatileIndex_),
MetatileStructure::metatileWidth,
MetatileStructure::metatileHeight,
Color(0xFF, 0xFF, 0x00, Color::fullAlphaOpacity),
2);
}
if ((toolManager_->currentTool() == LevelEditorTools::metatilePaint)) {
dst.drawRectBorder(metatileIndexToX(toolManager_->pickedMetatileIndex()),
metatileIndexToY(toolManager_->pickedMetatileIndex()),
MetatileStructure::metatileWidth,
MetatileStructure::metatileHeight,
Color(0xFF, 0x00, 0x00, Color::fullAlphaOpacity),
2);
}
}
示例4: if
void Game::play(int difficulty, Graphic &graphic, IElement &hero)
{
unsigned int i;
unsigned int j;
std::string hiScore = "HI-SCORE: 155351";
std::string score = "SCORE: 0";
std::string lives = "LIVES: ";
std::string shield = "SHIELD: NONE";
std::string bulletSkin = "|";
std::string *enemySkin;
enemySkin = new std::string [3];
enemySkin[0] = "[] []";
enemySkin[1] = "[O O]";
enemySkin[2] = "'-U-'";
int globalSpeed;
unsigned int pop = 40 / difficulty;
Input input;
this->setHero(hero);
globalSpeed = 0;
while (input.Action(getch(), this->hero, graphic, 1, this->bullet_list, &this->nbBullets))
{
if (globalSpeed % 3 == 0)
graphic.clear();
graphic.putElement(this->hero);
if (rand() % pop == 0)
{
enemy_list[nbEnemies][0] = 0;
enemy_list[nbEnemies][1] = rand() % 108;
enemy_list[nbEnemies][3] = 1;
nbEnemies += 1;
}
i = 0;
while (i < this->nbEnemies)
{
if (globalSpeed % 5 == 0)
{
this->enemy_list[i][2] = rand() % 3;
if (enemy_list[i][2] == 0)
this->enemy_list[i][1] -= 1;
else if (enemy_list[i][2] == 1)
this->enemy_list[i][1] += 1;
this->enemy_list[i][0] += 1;
}
std::string e;
std::stringstream eTmp;
eTmp << this->nbEnemies;
e = eTmp.str();
graphic.putImage(10, 0, 1, e.length(), &e);
if (enemy_list[i][3] == 1)
graphic.putImage(this->enemy_list[i][0], this->enemy_list[i][1], 3, 5, enemySkin);
if (this->collide(this->hero, this->enemy_list[i][1], this->enemy_list[i][0], 5, 3))
{
this->lives -= 1;
this->enemy_list[i][0] = 56;
enemy_list[nbEnemies][3] = 0;
}
unsigned int j = 0;
while (j < this->nbBullets)
{
if (this->collideBullet(this->bullet_list[j][1], this->bullet_list[j][0], this->enemy_list[i][1], this->enemy_list[i][0], 5, 3))
{
this->enemy_list[i][0] = 56;
enemy_list[nbEnemies][3] = 0;
this->bullet_list[j][0] = 0;
this->score += 10;
}
j++;
}
i++;
}
i = 0;
while (i < this->nbBullets)
{
this->bullet_list[i][0] -= 1;
graphic.putImage(bullet_list[i][0], bullet_list[i][1], 1, 1, &bulletSkin);
i++;
}
std::stringstream l;
l << this->lives;
lives += l.str();
std::stringstream s;
s << this->score;
score += s.str();
graphic.putImage(0, 0, 1, hiScore.length(), &hiScore);
graphic.putImage(1, 0, 1, score.length(), &score);
graphic.putImage(2, 0, 1, lives.length(), &lives);
graphic.putImage(3, 0, 1, shield.length(), &shield);
lives = "Lives: ";
score = "Score: ";
graphic.draw();
i = 0;
while (i < this->nbBullets)
{
if (this->bullet_list[i][0] <= 0)
{
j = i + 1;
while (j < this->nbBullets)
//.........这里部分代码省略.........