本文整理汇总了C++中ViewObject类的典型用法代码示例。如果您正苦于以下问题:C++ ViewObject类的具体用法?C++ ViewObject怎么用?C++ ViewObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ViewObject类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: getSpriteTile
Tile getSpriteTile(const ViewObject& obj) {
if (obj.id() == ViewId::SPECIAL_BEAST)
return getSpecialCreatureSprite(obj, false);
if (obj.id() == ViewId::SPECIAL_HUMANOID)
return getSpecialCreatureSprite(obj, true);
return getSprite(obj.id());
}
开发者ID:Nekoninja,项目名称:keeperrl,代码行数:7,代码来源:tile.cpp
示例2: Vec2
Vec2 MapGui::getMovementOffset(const ViewObject& object, Vec2 size, double time, int curTimeReal) {
if (!object.hasAnyMovementInfo())
return Vec2(0, 0);
double state;
Vec2 dir;
if (screenMovement &&
curTimeReal >= screenMovement->startTimeReal &&
curTimeReal <= screenMovement->endTimeReal) {
state = (double(curTimeReal) - screenMovement->startTimeReal) /
(screenMovement->endTimeReal - screenMovement->startTimeReal);
dir = object.getMovementInfo(screenMovement->startTimeGame, screenMovement->endTimeGame,
screenMovement->creatureId);
} else if (object.hasAnyMovementInfo() && !screenMovement) {
ViewObject::MovementInfo info = object.getLastMovementInfo();
dir = info.direction;
if (info.direction.length8() == 0 || time >= info.tEnd || time <= info.tBegin)
return Vec2(0, 0);
state = (time - info.tBegin) / (info.tEnd - info.tBegin);
double minStopTime = 0.2;
state = min(1.0, max(0.0, (state - minStopTime) / (1.0 - 2 * minStopTime)));
} else
return Vec2(0, 0);
if (object.getLastMovementInfo().type == ViewObject::MovementInfo::ATTACK)
if (dir.length8() == 1)
return Vec2(0.8 * (state < 0.5 ? state : 1 - state) * dir.x * size.x,
(0.8 * (state < 0.5 ? state : 1 - state)* dir.y - getJumpOffset(object, state)) * size.y);
return Vec2((state - 1) * dir.x * size.x, ((state - 1)* dir.y - getJumpOffset(object, state)) * size.y);
}
开发者ID:bstahly,项目名称:keeperrl,代码行数:28,代码来源:map_gui.cpp
示例3: insert
void ViewIndex::insert(ViewObject obj) {
PROFILE;
int ind = objIndex[int(obj.layer())];
if (ind < 100)
objects[ind] = std::move(obj);
else {
objIndex[int(obj.layer())] = objects.size();
objects.push_back(std::move(obj));
}
}
开发者ID:miki151,项目名称:keeperrl,代码行数:10,代码来源:view_index.cpp
示例4: animation_thread
static int32 animation_thread(void *cookie)
{
ViewObject *view = (ViewObject *) cookie;
while (1)
{
view->Render();
view->GLCheckError();
snooze(1);
}
return B_OK; // keep compiler happy
}
开发者ID:yunxiaoxiao110,项目名称:haiku,代码行数:11,代码来源:MainWindow.cpp
示例5: drawMorale
void MapGui::drawCreatureHighlights(Renderer& renderer, const ViewObject& object, Rectangle tile) {
if (object.hasModifier(ViewObject::Modifier::PLAYER)) {
renderer.drawFilledRectangle(tile, Color::Transparent, colors[ColorId::LIGHT_GRAY]);
}
if (object.hasModifier(ViewObject::Modifier::DRAW_MORALE) && showMorale)
drawMorale(renderer, tile, object.getAttribute(ViewObject::Attribute::MORALE));
if (object.hasModifier(ViewObject::Modifier::TEAM_LEADER_HIGHLIGHT)) {
renderer.drawFilledRectangle(tile, Color::Transparent, colors[ColorId::YELLOW]);
} else
if (object.hasModifier(ViewObject::Modifier::TEAM_HIGHLIGHT)) {
renderer.drawFilledRectangle(tile, Color::Transparent, transparency(colors[ColorId::YELLOW], 120));
}
}
开发者ID:silidur,项目名称:keeperrl,代码行数:13,代码来源:map_gui.cpp
示例6: getSpecialCreature
Tile getSpecialCreature(const ViewObject& obj, bool humanoid) {
RandomGen r;
r.init(hash<string>()(obj.getBareDescription()));
string let = humanoid ? "WETUIPLKJHFAXBM" : "qwetyupkfaxbnm";
char c;
if (contains(let, obj.getBareDescription()[0]))
c = obj.getBareDescription()[0];
else
if (contains(let, tolower(obj.getBareDescription()[0])))
c = tolower(obj.getBareDescription()[0]);
else
c = let[r.get(let.size())];
return Tile::unicode(c, ColorId(Random.get(EnumInfo<ColorId>::getSize())));
}
开发者ID:Ancurio,项目名称:keeperrl,代码行数:14,代码来源:tile.cpp
示例7: getColor
Color Tile::getColor(const ViewObject& object) {
if (object.hasModifier(ViewObject::Modifier::INVISIBLE))
return colors[ColorId::DARK_GRAY];
if (object.hasModifier(ViewObject::Modifier::HIDDEN))
return colors[ColorId::LIGHT_GRAY];
double bleeding = object.getAttribute(ViewObject::Attribute::BLEEDING);
if (bleeding > 0)
bleeding = 0.5 + bleeding / 2;
bleeding = min(1., bleeding);
Color color = getAsciiTile(object).color;
return Color(
(1 - bleeding) * color.r + bleeding * 255,
(1 - bleeding) * color.g,
(1 - bleeding) * color.b);
}
开发者ID:hhirsch,项目名称:keeperrl,代码行数:15,代码来源:tile.cpp
示例8: getColor
Color Tile::getColor(const ViewObject& object) {
if (object.hasModifier(ViewObject::INVISIBLE))
return darkGray;
if (object.hasModifier(ViewObject::HIDDEN))
return lightGray;
double bleeding = object.getBleeding();
if (bleeding > 0)
bleeding = 0.5 + bleeding / 2;
bleeding = min(1., bleeding);
Color color = getAsciiTile(object).color;
return Color(
(1 - bleeding) * color.r + bleeding * 255,
(1 - bleeding) * color.g,
(1 - bleeding) * color.b);
}
开发者ID:Nekoninja,项目名称:keeperrl,代码行数:15,代码来源:tile.cpp
示例9: getSpecialCreature
Tile getSpecialCreature(const ViewObject& obj, bool humanoid) {
RandomGen r;
r.init(hash<string>()(obj.getBareDescription()));
string let = humanoid ? "WETUIPLKJHFAXBM" : "qwetyupkfaxbnm";
char c;
if (contains(let, obj.getBareDescription()[0]))
c = obj.getBareDescription()[0];
else
if (contains(let, tolower(obj.getBareDescription()[0])))
c = tolower(obj.getBareDescription()[0]);
else
c = let[r.getRandom(let.size())];
Color col(r.getRandom(80, 250), r.getRandom(80, 250), 0);
return Tile(c, col);
}
开发者ID:Nekoninja,项目名称:keeperrl,代码行数:15,代码来源:tile.cpp
示例10: getSpecialCreatureSprite
Tile getSpecialCreatureSprite(const ViewObject& obj, bool humanoid) {
RandomGen r;
r.init(hash<string>()(obj.getBareDescription()));
if (humanoid)
return Tile::byCoord(r.get(7), 10);
else
return Tile::byCoord(r.get(7, 10), 10);
}
开发者ID:Ancurio,项目名称:keeperrl,代码行数:8,代码来源:tile.cpp
示例11: getJumpOffset
static double getJumpOffset(const ViewObject& object, double state) {
if (object.hasModifier(ViewObjectModifier::NO_UP_MOVEMENT))
return 0;
if (state > 0.5)
state -= 0.5;
state *= 2;
const double maxH = 0.09;
return maxH * (1.0 - (2.0 * state - 1) * (2.0 * state - 1));
}
开发者ID:bstahly,项目名称:keeperrl,代码行数:9,代码来源:map_gui.cpp
示例12: getAsciiTile
Tile getAsciiTile(const ViewObject& obj) {
ViewId id = obj.id();
if (id == ViewId::SPECIAL_BEAST)
return getSpecialCreature(obj, false);
if (id == ViewId::SPECIAL_HUMANOID)
return getSpecialCreature(obj, true);
if (symbols.count(id))
return symbols.at(id);
else
FAIL << "unhandled view id " << EnumInfo<ViewId>::getString(id);
return Tile::unicode(' ', ColorId(0));
}
开发者ID:hhirsch,项目名称:keeperrl,代码行数:12,代码来源:tile.cpp
示例13: updateObjects
void MapGui::updateObjects(const MapMemory* mem) {
lastMemory = mem;
floorIds.clear();
shadowed.clear();
for (Vec2 wpos : layout->getAllTiles(getBounds(), objects.getBounds()))
if (auto& index = objects[wpos]) {
if (index->hasObject(ViewLayer::FLOOR)) {
ViewObject object = index->getObject(ViewLayer::FLOOR);
if (object.hasModifier(ViewObject::Modifier::CASTS_SHADOW)) {
shadowed.erase(wpos);
shadowed.insert(wpos + Vec2(0, 1));
}
if (auto id = getConnectionId(object))
floorIds.insert(make_pair(wpos, *id));
} else if (index->hasObject(ViewLayer::FLOOR_BACKGROUND)) {
if (auto id = getConnectionId(index->getObject(ViewLayer::FLOOR_BACKGROUND)))
floorIds.insert(make_pair(wpos, *id));
} else if (auto viewId = index->getHiddenId())
if (auto id = getConnectionId(*viewId))
floorIds.insert(make_pair(wpos, *id));
}
}
开发者ID:pipehat,项目名称:keeperrl,代码行数:22,代码来源:map_gui.cpp
示例14: drawCreatureHighlight
void MapGui::drawCreatureHighlights(Renderer& renderer, const ViewObject& object, Vec2 pos, Vec2 sz, int curTime) {
if (object.hasModifier(ViewObject::Modifier::PLAYER))
drawCreatureHighlight(renderer, pos, sz, colors[ColorId::ALMOST_WHITE]);
if (object.hasModifier(ViewObject::Modifier::DRAW_MORALE) && showMorale)
drawCreatureHighlight(renderer, pos, sz, getMoraleColor(object.getAttribute(ViewObject::Attribute::MORALE)));
if (object.hasModifier(ViewObject::Modifier::TEAM_LEADER_HIGHLIGHT) && (curTime / 1000) % 2) {
drawCreatureHighlight(renderer, pos, sz, colors[ColorId::YELLOW]);
} else
if (object.hasModifier(ViewObject::Modifier::TEAM_HIGHLIGHT))
drawCreatureHighlight(renderer, pos, sz, colors[ColorId::YELLOW]);
if (object.getCreatureId()) {
Color c = getCreatureHighlight(*object.getCreatureId(), curTime);
if (c.a > 0)
drawCreatureHighlight(renderer, pos, sz, c);
}
}
开发者ID:bstahly,项目名称:keeperrl,代码行数:16,代码来源:map_gui.cpp
示例15: drawViewObject
void Renderer::drawViewObject(Vec2 pos, const ViewObject& object, bool useSprite, double scale) {
drawViewObject(pos, object.id(), useSprite, scale, getBleedingColor(object));
}
开发者ID:Eldhelion,项目名称:keeperrl,代码行数:3,代码来源:renderer.cpp
示例16: getBleedingColor
Color Renderer::getBleedingColor(const ViewObject& object) {
double bleeding = object.getAttribute(ViewObject::Attribute::BLEEDING);
if (bleeding > 0)
bleeding = 0.3 + bleeding * 0.7;
return Color(255, max(0., (1 - bleeding) * 255), max(0., (1 - bleeding) * 255));
}
开发者ID:Eldhelion,项目名称:keeperrl,代码行数:6,代码来源:renderer.cpp
示例17: drawMorale
void MapGui::drawObjectAbs(Renderer& renderer, int x, int y, const ViewObject& object,
int sizeX, int sizeY, Vec2 tilePos) {
if (object.hasModifier(ViewObject::Modifier::PLAYER)) {
renderer.drawFilledRectangle(x, y, x + sizeX, y + sizeY, Color::Transparent, colors[ColorId::LIGHT_GRAY]);
}
if (object.hasModifier(ViewObject::Modifier::DRAW_MORALE))
drawMorale(renderer, Rectangle(x, y, x + sizeX, y + sizeY), object.getAttribute(ViewObject::Attribute::MORALE));
if (object.hasModifier(ViewObject::Modifier::TEAM_HIGHLIGHT)) {
renderer.drawFilledRectangle(x, y, x + sizeX, y + sizeY, Color::Transparent, colors[ColorId::DARK_GREEN]);
}
const Tile& tile = Tile::getTile(object, spriteMode);
Color color = Renderer::getBleedingColor(object);
if (object.hasModifier(ViewObject::Modifier::INVISIBLE) || object.hasModifier(ViewObject::Modifier::HIDDEN))
color = transparency(color, 70);
else
if (tile.translucent > 0)
color = transparency(color, 255 * (1 - tile.translucent));
else if (object.hasModifier(ViewObject::Modifier::ILLUSION))
color = transparency(color, 150);
if (object.hasModifier(ViewObject::Modifier::PLANNED))
color = transparency(color, 100);
double waterDepth = object.getAttribute(ViewObject::Attribute::WATER_DEPTH);
if (waterDepth > 0) {
int val = max(0.0, 255.0 - min(2.0, waterDepth) * 60);
color = Color(val, val, val);
}
if (tile.hasSpriteCoord()) {
Vec2 move;
Vec2 sz = Renderer::tileSize[tile.getTexNum()];
Vec2 off = (Renderer::nominalSize - sz).mult(Vec2(sizeX, sizeY)).div(Renderer::nominalSize * 2);
int width = sz.x * sizeX / Renderer::nominalSize.x;
int height = sz.y* sizeY / Renderer::nominalSize.y;
if (sz.y > Renderer::nominalSize.y)
off.y *= 2;
EnumSet<Dir> dirs;
EnumSet<Dir> borderDirs;
if (!object.hasModifier(ViewObject::Modifier::PLANNED))
if (auto connectionId = getConnectionId(object))
for (Vec2 dir : getConnectionDirs(object.id())) {
if (tileConnects(*connectionId, tilePos + dir))
dirs.insert(dir.getCardinalDir());
else
borderDirs.insert(dir.getCardinalDir());
}
Vec2 coord = tile.getSpriteCoord(dirs);
if (object.hasModifier(ViewObject::Modifier::MOVE_UP))
move.y = -4* sizeY / Renderer::nominalSize.y;
if ((object.layer() == ViewLayer::CREATURE && object.id() != ViewId::BOULDER)
|| object.hasModifier(ViewObject::Modifier::ROUND_SHADOW)) {
renderer.drawSprite(x, y - 2, 2 * Renderer::nominalSize.x, 22 * Renderer::nominalSize.y,
Renderer::nominalSize.x, Renderer::nominalSize.y, Renderer::tiles[0],
min(Renderer::nominalSize.x, width), min(Renderer::nominalSize.y, height));
move.y = -4* sizeY / Renderer::nominalSize.y;
}
if (auto background = tile.getBackgroundCoord()) {
renderer.drawSprite(x + off.x, y + off.y, background->x * sz.x,
background->y * sz.y, sz.x, sz.y, Renderer::tiles[tile.getTexNum()], width, height, color);
if (shadowed.count(tilePos))
renderer.drawSprite(x, y, 1 * Renderer::nominalSize.x, 21 * Renderer::nominalSize.y,
Renderer::nominalSize.x, Renderer::nominalSize.y, Renderer::tiles[5], width, height);
}
if (coord.x < 0)
return;
if (auto dir = object.getAttachmentDir())
move = getAttachmentOffset(*dir, width, height);
renderer.drawSprite(x + off.x + move.x, y + move.y + off.y, coord.x * sz.x,
coord.y * sz.y, sz.x, sz.y, Renderer::tiles[tile.getTexNum()], width, height, color);
if (tile.hasCorners()) {
for (Vec2 coord : tile.getCornerCoords(dirs))
renderer.drawSprite(x + off.x + move.x, y + move.y + off.y, coord.x * sz.x,
coord.y * sz.y, sz.x, sz.y, Renderer::tiles[tile.getTexNum()], width, height, color);
}
if (tile.floorBorders) {
drawFloorBorders(renderer, borderDirs, x, y);
}
if (contains({ViewLayer::FLOOR, ViewLayer::FLOOR_BACKGROUND}, object.layer()) &&
shadowed.count(tilePos) && !tile.noShadow)
renderer.drawSprite(x, y, 1 * Renderer::nominalSize.x, 21 * Renderer::nominalSize.y,
Renderer::nominalSize.x, Renderer::nominalSize.y, Renderer::tiles[5], width, height);
if (object.getAttribute(ViewObject::Attribute::BURNING) > 0) {
renderer.drawSprite(x, y, Random.get(10, 12) * Renderer::nominalSize.x, 0 * Renderer::nominalSize.y,
Renderer::nominalSize.x, Renderer::nominalSize.y, Renderer::tiles[2], width, height);
}
if (object.hasModifier(ViewObject::Modifier::LOCKED))
renderer.drawSprite(x + (Renderer::nominalSize.x - Renderer::tileSize[3].x) / 2, y,
5 * Renderer::tileSize[3].x, 6 * Renderer::tileSize[3].y,
Renderer::tileSize[3].x, Renderer::tileSize[3].y, Renderer::tiles[3], width / 2, height / 2);
} else {
renderer.drawText(tile.symFont ? Renderer::SYMBOL_FONT : Renderer::TILE_FONT, sizeY, Tile::getColor(object),
x + sizeX / 2, y - 3, tile.text, true);
double burningVal = object.getAttribute(ViewObject::Attribute::BURNING);
if (burningVal > 0) {
renderer.drawText(Renderer::SYMBOL_FONT, sizeY, getFireColor(), x + sizeX / 2, y - 3, L'ѡ', true);
if (burningVal > 0.5)
renderer.drawText(Renderer::SYMBOL_FONT, sizeY, getFireColor(), x + sizeX / 2, y - 3, L'Ѡ', true);
}
}
}
开发者ID:pipehat,项目名称:keeperrl,代码行数:98,代码来源:map_gui.cpp
示例18: getConnectionId
Optional<ViewId> getConnectionId(const ViewObject& object) {
if (object.hasModifier(ViewObject::Modifier::PLANNED))
return Nothing();
else
return getConnectionId(object.id());
}
开发者ID:pipehat,项目名称:keeperrl,代码行数:6,代码来源:map_gui.cpp
示例19: transparency
void MapGui::drawObjectAbs(Renderer& renderer, Vec2 pos, const ViewObject& object, Vec2 size,
Vec2 tilePos, int curTimeReal, const EnumMap<HighlightType, double>& highlightMap) {
const Tile& tile = Tile::getTile(object.id(), spriteMode);
Color color = Renderer::getBleedingColor(object);
if (object.hasModifier(ViewObject::Modifier::INVISIBLE) || object.hasModifier(ViewObject::Modifier::HIDDEN))
color = transparency(color, 70);
else
if (tile.translucent > 0)
color = transparency(color, 255 * (1 - tile.translucent));
else if (object.hasModifier(ViewObject::Modifier::ILLUSION))
color = transparency(color, 150);
if (object.hasModifier(ViewObject::Modifier::PLANNED))
color = transparency(color, 100);
double waterDepth = object.getAttribute(ViewObject::Attribute::WATER_DEPTH);
if (waterDepth > 0) {
int val = max(0.0, 255.0 - min(2.0, waterDepth) * 60);
color = Color(val, val, val);
}
if (spriteMode && tile.hasSpriteCoord()) {
DirSet dirs;
DirSet borderDirs;
if (auto connectionId = getConnectionId(object))
for (Vec2 dir : getConnectionDirs(object.id())) {
if ((tilePos + dir).inRectangle(levelBounds) && connectionMap.has(tilePos + dir, *connectionId))
dirs.insert(dir.getCardinalDir());
else
borderDirs.insert(dir.getCardinalDir());
}
Vec2 move;
Vec2 movement = getMovementOffset(object, size, currentTimeGame, curTimeReal);
drawCreatureHighlights(renderer, object, pos + movement, size, curTimeReal);
if ((object.layer() == ViewLayer::CREATURE && object.id() != ViewId::BOULDER)
|| object.hasModifier(ViewObject::Modifier::ROUND_SHADOW)) {
static auto coord = renderer.getTileCoord("round_shadow");
renderer.drawTile(pos + movement, coord, size, sf::Color(255, 255, 255, 160));
move.y = -4* size.y / renderer.getNominalSize().y;
}
static auto shortShadow = renderer.getTileCoord("short_shadow");
if (auto background = tile.getBackgroundCoord()) {
renderer.drawTile(pos, *background, size, color);
if (shadowed.count(tilePos))
renderer.drawTile(pos, shortShadow, size, sf::Color(255, 255, 255, 170));
}
if (auto dir = object.getAttachmentDir())
move = getAttachmentOffset(*dir, size);
move += movement;
if (mirrorSprite(object.id()))
renderer.drawTile(pos + move, tile.getSpriteCoord(dirs), size, color,
object.getPositionHash() % 2, object.getPositionHash() % 4 > 1);
else
renderer.drawTile(pos + move, tile.getSpriteCoord(dirs), size, color);
if (object.layer() == ViewLayer::FLOOR && highlightMap[HighlightType::CUT_TREE] > 0)
if (auto coord = tile.getHighlightCoord())
renderer.drawTile(pos + move, *coord, size, color);
if (!buttonViewId)
if (auto id = object.getCreatureId())
creatureMap.push_back(CreatureInfo{Rectangle(pos + move, pos + move + size), *id, object.id()});
if (tile.hasCorners()) {
for (auto coord : tile.getCornerCoords(dirs))
renderer.drawTile(pos + move, coord, size, color);
}
/* if (tile.floorBorders) {
drawFloorBorders(renderer, borderDirs, x, y);
}*/
if ((object.layer() == ViewLayer::FLOOR || object.layer() == ViewLayer::FLOOR_BACKGROUND) &&
shadowed.count(tilePos) && !tile.noShadow)
renderer.drawTile(pos, shortShadow, size, sf::Color(255, 255, 255, 170));
if (object.getAttribute(ViewObject::Attribute::BURNING) > 0) {
static auto fire1 = renderer.getTileCoord("fire1");
static auto fire2 = renderer.getTileCoord("fire2");
renderer.drawTile(pos, Random.choose({fire1, fire2}), size);
}
static auto key = renderer.getTileCoord("key");
if (object.hasModifier(ViewObject::Modifier::LOCKED))
renderer.drawTile(pos, key, size);
} else {
Vec2 movement = getMovementOffset(object, size, currentTimeGame, curTimeReal);
Vec2 tilePos = pos + movement + Vec2(size.x / 2, -3);
drawCreatureHighlights(renderer, object, pos, size, curTimeReal);
renderer.drawText(tile.symFont ? Renderer::SYMBOL_FONT : Renderer::TILE_FONT, size.y, Tile::getColor(object),
tilePos.x, tilePos.y, tile.text, Renderer::HOR);
if (!buttonViewId)
if (auto id = object.getCreatureId())
creatureMap.push_back(CreatureInfo{Rectangle(tilePos, tilePos + size), *id, object.id()});
double burningVal = object.getAttribute(ViewObject::Attribute::BURNING);
if (burningVal > 0) {
renderer.drawText(Renderer::SYMBOL_FONT, size.y, getFireColor(), pos.x + size.x / 2, pos.y - 3, L'ѡ',
Renderer::HOR);
if (burningVal > 0.5)
renderer.drawText(Renderer::SYMBOL_FONT, size.y, getFireColor(), pos.x + size.x / 2, pos.y - 3, L'Ѡ',
Renderer::HOR);
}
}
}
开发者ID:bstahly,项目名称:keeperrl,代码行数:94,代码来源:map_gui.cpp
示例20: getConnectionId
optional<ViewId> getConnectionId(const ViewObject& object) {
return getConnectionId(object.id());
}
开发者ID:bstahly,项目名称:keeperrl,代码行数:3,代码来源:map_gui.cpp
注:本文中的ViewObject类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论