本文整理汇总了C++中Vec2iAdd函数的典型用法代码示例。如果您正苦于以下问题:C++ Vec2iAdd函数的具体用法?C++ Vec2iAdd怎么用?C++ Vec2iAdd使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Vec2iAdd函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawObjectiveInfo
static void DrawObjectiveInfo(
const struct MissionOptions *mo, const int idx, const Vec2i pos)
{
const MissionObjective *mobj =
CArrayGet(&mo->missionData->Objectives, idx);
const ObjectiveDef *o = CArrayGet(&mo->Objectives, idx);
const CharacterStore *store = &gCampaign.Setting.characters;
switch (mobj->Type)
{
case OBJECTIVE_KILL:
{
const Character *cd = CArrayGet(
&store->OtherChars, CharacterStoreGetSpecialId(store, 0));
const int i = cd->looks.face;
TOffsetPic pic;
pic.picIndex = cHeadPic[i][DIRECTION_DOWN][STATE_IDLE];
pic.dx = cHeadOffset[i][DIRECTION_DOWN].dx;
pic.dy = cHeadOffset[i][DIRECTION_DOWN].dy;
DrawTTPic(
pos.x + pic.dx, pos.y + pic.dy,
PicManagerGetOldPic(&gPicManager, pic.picIndex), &cd->table);
}
break;
case OBJECTIVE_RESCUE:
{
const Character *cd = CArrayGet(
&store->OtherChars, CharacterStoreGetPrisonerId(store, 0));
const int i = cd->looks.face;
TOffsetPic pic;
pic.picIndex = cHeadPic[i][DIRECTION_DOWN][STATE_IDLE];
pic.dx = cHeadOffset[i][DIRECTION_DOWN].dx;
pic.dy = cHeadOffset[i][DIRECTION_DOWN].dy;
DrawTTPic(
pos.x + pic.dx, pos.y + pic.dy,
PicManagerGetOldPic(&gPicManager, pic.picIndex), &cd->table);
}
break;
case OBJECTIVE_COLLECT:
{
const Pic *p = o->pickupClass->Pic;
Blit(&gGraphicsDevice, p, Vec2iAdd(pos, p->offset));
}
break;
case OBJECTIVE_DESTROY:
{
Vec2i picOffset;
const Pic *p =
MapObjectGetPic(IntMapObject(mobj->Index), &picOffset, false);
Blit(&gGraphicsDevice, p, Vec2iAdd(pos, picOffset));
}
break;
case OBJECTIVE_INVESTIGATE:
// Don't draw
return;
default:
CASSERT(false, "Unknown objective type");
return;
}
}
示例2: DrawActorHighlight
void DrawActorHighlight(
const ActorPics *pics, const Vec2i pos, const color_t color)
{
// Do not highlight dead, dying or transparent characters
if (pics->IsDead || pics->IsTransparent)
{
return;
}
BlitPicHighlight(
&gGraphicsDevice, pics->Head, Vec2iAdd(pos, pics->HeadOffset), color);
if (pics->Body != NULL)
{
BlitPicHighlight(
&gGraphicsDevice, pics->Body, Vec2iAdd(pos, pics->BodyOffset),
color);
}
if (pics->Legs != NULL)
{
BlitPicHighlight(
&gGraphicsDevice, pics->Legs, Vec2iAdd(pos, pics->LegsOffset),
color);
}
if (pics->Gun != NULL)
{
BlitPicHighlight(
&gGraphicsDevice, pics->Gun, Vec2iAdd(pos, pics->GunOffset), color);
}
}
示例3: MissionBriefingDraw
static void MissionBriefingDraw(void *data)
{
const MissionBriefingData *mData = data;
GraphicsClear(&gGraphicsDevice);
// Mission title
FontStrOpt(mData->Title, Vec2iZero(), mData->TitleOpts);
// Display password
FontStrOpt(mData->Password, Vec2iZero(), mData->PasswordOpts);
// Display description with typewriter effect
FontStr(mData->TypewriterBuf, mData->DescriptionPos);
// Display objectives
CA_FOREACH(
const Objective, o, mData->MissionOptions->missionData->Objectives)
// Do not brief optional objectives
if (o->Required == 0)
{
continue;
}
Vec2i offset = Vec2iNew(0, _ca_index * mData->ObjectiveHeight);
FontStr(o->Description, Vec2iAdd(mData->ObjectiveDescPos, offset));
// Draw the icons slightly offset so that tall icons don't overlap each
// other
offset.x = -16 * (_ca_index & 1);
DrawObjectiveInfo(o, Vec2iAdd(mData->ObjectiveInfoPos, offset));
CA_FOREACH_END()
}
示例4: MissionBriefingDraw
static void MissionBriefingDraw(void *data)
{
const MissionBriefingData *mData = data;
GraphicsBlitBkg(&gGraphicsDevice);
// Mission title
FontStrOpt(mData->Title, Vec2iZero(), mData->TitleOpts);
// Display password
FontStrOpt(mData->Password, Vec2iZero(), mData->PasswordOpts);
// Display description with typewriter effect
FontStr(mData->TypewriterBuf, mData->DescriptionPos);
// Display objectives
for (int i = 0;
i < (int)mData->MissionOptions->missionData->Objectives.size;
i++)
{
const MissionObjective *o =
CArrayGet(&mData->MissionOptions->missionData->Objectives, i);
// Do not brief optional objectives
if (o->Required == 0)
{
continue;
}
const Vec2i yInc = Vec2iNew(0, i * mData->ObjectiveHeight);
FontStr(o->Description, Vec2iAdd(mData->ObjectiveDescPos, yInc));
DrawObjectiveInfo(
mData->MissionOptions, i, Vec2iAdd(mData->ObjectiveInfoPos, yInc));
}
}
示例5: IsCollisionDiamond
// Check collision with a diamond shape
// This means that the bounding box could be in collision, but the bounding
// "radius" is not. The diamond is expressed with a single "radius" - that is,
// the diamond is the same height and width.
// This arrangement is used so that axis movement can slide off corners by
// moving in a diagonal direction.
// E.g. this is not a collision:
// x
// x x
// x x
// x x
// x x
// x x wwwww
// x w
// w
// Where 'x' denotes the bounding diamond, and 'w' represents a wall corner.
bool IsCollisionDiamond(const Map *map, const Vec2i pos, const Vec2i fullSize)
{
const Vec2i mapSize =
Vec2iNew(map->Size.x * TILE_WIDTH, map->Size.y * TILE_HEIGHT);
const Vec2i size = Vec2iScaleDiv(fullSize, 2);
if (pos.x - size.x < 0 || pos.x + size.x >= mapSize.x ||
pos.y - size.y < 0 || pos.y + size.y >= mapSize.y)
{
return true;
}
// Only support wider-than-taller collision diamonds for now
CASSERT(size.x >= size.y, "not implemented, taller than wider diamond");
const double gradient = (double)size.y / size.x;
// Now we need to check in a diamond pattern that the boundary does not
// collide
// Top to right
for (int i = 0; i < size.x; i++)
{
const int y = (int)Round((-size.x + i)* gradient);
const Vec2i p = Vec2iAdd(pos, Vec2iNew(i, y));
if (HitWall(p.x, p.y))
{
return true;
}
}
// Right to bottom
for (int i = 0; i < size.x; i++)
{
const int y = (int)Round(i * gradient);
const Vec2i p = Vec2iAdd(pos, Vec2iNew(size.x - i, y));
if (HitWall(p.x, p.y))
{
return true;
}
}
// Bottom to left
for (int i = 0; i < size.x; i++)
{
const int y = (int)Round((size.x - i) * gradient);
const Vec2i p = Vec2iAdd(pos, Vec2iNew(-i, y));
if (HitWall(p.x, p.y))
{
return true;
}
}
// Left to top
for (int i = 0; i < size.x; i++)
{
const int y = (int)Round(-i * gradient);
const Vec2i p = Vec2iAdd(pos, Vec2iNew(-size.x + i, y));
if (HitWall(p.x, p.y))
{
return true;
}
}
return false;
}
示例6: DrawMapItem
static void DrawMapItem(
UIObject *o, GraphicsDevice *g, Vec2i pos, void *vData)
{
UNUSED(g);
const EditorBrush *brush = vData;
DisplayMapItem(
Vec2iAdd(Vec2iAdd(pos, o->Pos), Vec2iScaleDiv(o->Size, 2)),
brush->u.MapObject);
}
示例7: DrawKey
void DrawKey(UIObject *o, GraphicsDevice *g, Vec2i pos, void *vData)
{
UNUSED(g);
EditorBrushAndCampaign *data = vData;
PicPaletted *keyPic = PicManagerGetOldPic(
&gPicManager,
cGeneralPics[gMission.keyPics[data->Brush.ItemIndex]].picIndex);
pos = Vec2iAdd(Vec2iAdd(pos, o->Pos), Vec2iScaleDiv(o->Size, 2));
DrawTPic(pos.x, pos.y, keyPic);
}
示例8: DrawPickupSpawner
static void DrawPickupSpawner(
UIObject *o, GraphicsDevice *g, Vec2i pos, void *vData)
{
const IndexedEditorBrush *data = vData;
const MapObject *mo = data->u.MapObject;
DisplayMapItem(
Vec2iAdd(Vec2iAdd(pos, o->Pos), Vec2iScaleDiv(o->Size, 2)), mo);
const Pic *pic = mo->u.PickupClass->Pic;
pos = Vec2iMinus(pos, Vec2iScaleDiv(pic->size, 2));
Blit(g, pic, Vec2iAdd(Vec2iAdd(pos, o->Pos), Vec2iScaleDiv(o->Size, 2)));
}
示例9: UITooltipDraw
void UITooltipDraw(GraphicsDevice *device, Vec2i pos, const char *s)
{
Vec2i bgSize = FontStrSize(s);
pos = Vec2iAdd(pos, Vec2iNew(10, 10)); // add offset
DrawRectangle(
device,
Vec2iAdd(pos, Vec2iScale(Vec2iUnit(), -TOOLTIP_PADDING)),
Vec2iAdd(bgSize, Vec2iScale(Vec2iUnit(), 2 * TOOLTIP_PADDING)),
bgColor,
0);
FontStr(s, pos);
}
示例10: DrawCharacter
static void DrawCharacter(
UIObject *o, GraphicsDevice *g, Vec2i pos, void *vData)
{
UNUSED(g);
EditorBrushAndCampaign *data = vData;
CharacterStore *store = &data->Campaign->Setting.characters;
Character *c = CArrayGet(&store->OtherChars, data->Brush.u.ItemIndex);
DrawCharacterSimple(
c,
Vec2iAdd(Vec2iAdd(pos, o->Pos), Vec2iScaleDiv(o->Size, 2)),
DIRECTION_DOWN, false, false);
}
示例11: UITooltipDraw
void UITooltipDraw(GraphicsDevice *device, Vec2i pos, const char *s)
{
Vec2i bgSize = TextGetSize(s);
pos = Vec2iAdd(pos, Vec2iNew(10, 10)); // add offset
DrawRectangle(
device,
Vec2iAdd(pos, Vec2iScale(Vec2iUnit(), -TOOLTIP_PADDING)),
Vec2iAdd(bgSize, Vec2iScale(Vec2iUnit(), 2 * TOOLTIP_PADDING)),
bgColor,
0);
TextString(&gTextManager, s, device, pos);
}
示例12: DrawWreck
static void DrawWreck(
UIObject *o, GraphicsDevice *g, Vec2i pos, void *vData)
{
const IndexedEditorBrush *data = vData;
const char **name =
CArrayGet(&gMapObjects.Destructibles, data->u.ItemIndex);
const MapObject *mo = StrMapObject(*name);
pos = Vec2iAdd(Vec2iAdd(pos, o->Pos), Vec2iScaleDiv(o->Size, 2));
Vec2i offset;
const Pic *pic = MapObjectGetPic(mo, &offset, true);
Blit(g, pic, Vec2iAdd(pos, offset));
}
示例13: DrawKey
void DrawKey(UIObject *o, GraphicsDevice *g, Vec2i pos, void *vData)
{
EditorBrushAndCampaign *data = vData;
if (data->Brush.ItemIndex == -1)
{
// No key; don't draw
return;
}
const Pic *pic =
KeyPickupClass(gMission.keyStyle, data->Brush.ItemIndex)->Pic;
pos = Vec2iAdd(Vec2iAdd(pos, o->Pos), Vec2iScaleDiv(o->Size, 2));
pos = Vec2iMinus(pos, Vec2iScaleDiv(pic->size, 2));
Blit(g, pic, pos);
}
示例14: DisplayCharacter
void DisplayCharacter(
const Vec2i pos, const Character *c, const bool hilite, const bool showGun)
{
DrawCharacterSimple(
c, pos,
DIRECTION_DOWN, STATE_IDLE, -1, GUNSTATE_READY, &c->table);
if (hilite)
{
FontCh('>', Vec2iAdd(pos, Vec2iNew(-8, -16)));
if (showGun)
{
FontStr(c->Gun->name, Vec2iAdd(pos, Vec2iNew(-8, 8)));
}
}
}
示例15: AreasCollide
bool AreasCollide(
const Vec2i pos1, const Vec2i pos2, const Vec2i size1, const Vec2i size2)
{
const Vec2i d = Vec2iNew(abs(pos1.x - pos2.x), abs(pos1.y - pos2.y));
const Vec2i r = Vec2iAdd(size1, size2);
return d.x < r.x && d.y < r.y;
}