本文整理汇总了C++中TVector::Set方法的典型用法代码示例。如果您正苦于以下问题:C++ TVector::Set方法的具体用法?C++ TVector::Set怎么用?C++ TVector::Set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TVector
的用法示例。
在下文中一共展示了TVector::Set方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Create
void CGunShotgun::Create()
{
TVector<int, 2> frameLayout;
frameLayout.Set(8, 2);
m_entity = CLasagne::GetInstance()->LoadAnimatedImage("./media/graphics/characters/guns/shotgun/gun.png", frameLayout);
if (!m_entity)
return;
m_audio = CLasagne::GetInstance()->LoadAudioFile("./media/sound/guns/shotgun.wav");
m_entity->SetDepth(5);
static const int NoofBullets = 9;
for (int bulletIndex = 0; bulletIndex < NoofBullets; ++bulletIndex)
{
CBulletBase *bulletBase = new CBulletShotgun();
bulletBase->Create();
m_bullet.push_back(bulletBase);
}
}
开发者ID:SamOatesUniversity,项目名称:Year-3---Device-Programming---Memory-Manager---Horde,代码行数:21,代码来源:gunshotgun.cpp
示例2: DDCall
// JoystickInputStreamImpl(IDirectInputDevice2* pdid, HWND hwnd) :
JoystickInputStreamImpl(IDirectInputDevice7* pdid, HWND hwnd) : // mdvalley: DInput7
m_pdid(pdid),
m_bFocus(false),
m_vvalueObject(5)
{
DDCall(m_pdid->GetCapabilities(&m_didc));
DDCall(m_pdid->GetDeviceInfo(&m_didi));
//
// Enumerate the buttons and values
//
DDCall(m_pdid->EnumObjects(StaticEnumObjectsCallback, this, DIDFT_ALL));
//
// Remove any holes in the value vector
//
int index;
int countValues = m_vvalueObject.GetCount();
index = 0;
while (index < countValues) {
if (m_vvalueObject[index] == NULL) {
if (index != countValues - 1) {
m_vvalueObject.Set(index, m_vvalueObject[countValues - 1]);
}
countValues--;
m_vvalueObject.SetCount(countValues);
} else {
index++;
}
}
//
// Build the data format
//
int countButtons = m_vbuttonObject.GetCount();
m_sizeData = NextMultipleOf(4, countValues * 4 + countButtons * 1);
DIDataFormat didf;
didf.dwObjSize = sizeof(DIOBJECTDATAFORMAT);
didf.dwFlags = 0;
didf.dwDataSize = m_sizeData;
didf.dwNumObjs = countValues + countButtons;
DIObjectDataFormat* pdiodf = new DIObjectDataFormat[didf.dwNumObjs];
didf.rgodf = pdiodf;
for (index = 0; index < countValues; index++) {
ValueDDInputObject* pobject = m_vvalueObject[index];
DIOBJECTDATAFORMAT& diodf = didf.rgodf[index];
diodf.pguid = (GUID*)&(pobject->GetGUID());
diodf.dwOfs = index * 4;
diodf.dwType = pobject->GetDWType();
diodf.dwFlags = DIDOI_ASPECTPOSITION;
}
for (index = 0; index < countButtons; index++) {
ButtonDDInputObject* pobject = m_vbuttonObject[index];
DIOBJECTDATAFORMAT& diodf = didf.rgodf[countValues + index];
diodf.pguid = (GUID*)&(pobject->GetGUID());
diodf.dwOfs = countValues * 4 + index;
diodf.dwType = pobject->GetDWType();
diodf.dwFlags = DIDOI_ASPECTPOSITION;
}
DDCall(m_pdid->SetDataFormat(&didf));
delete pdiodf;
//
// Allocate a data receptical
//
m_pbyteData = new BYTE[m_sizeData];
//
// We only need joystick input when we are in the foreground
//
DDCall(m_pdid->SetCooperativeLevel(hwnd, DISCL_EXCLUSIVE | DISCL_FOREGROUND));
//
// Set ranges
//
SetRanges();
}
示例3: VerifyScrollPos
void VerifyScrollPos()
{
if (m_bNeedScrollUpdate) {
m_bNeedScrollUpdate = false;
if (m_bNeedSelectionOnScreen) {
m_bNeedSelectionOnScreen = false;
//
// Figure out where the selection is
//
int nItemSize = GetSignificantSize(*m_ppainter);
int ySelection = m_indexSelection * nItemSize - GetScrollPos();
//
// Make sure the selection is in the window
//
if (ySelection + GetSignificantSize(*m_ppainter) >= GetSignificantSize()) {
ySelection = GetSignificantSize() - GetSignificantSize(*m_ppainter);
}
if (ySelection < 0) {
ySelection = 0;
}
//
// Adjust the scroll bar so that the selection doesn't move
//
if (m_pscroll && m_plist->GetCount() * GetSignificantSize(*m_ppainter) > GetSignificantSize()) {
SetScrollPos(m_indexSelection * GetSignificantSize(*m_ppainter) - ySelection);
} else {
SetScrollPos(0);
}
} else {
//
// find the top item in the old list
//
int nItemSize = GetSignificantSize(*m_ppainter);
int iOldTop = GetScrollPos() / nItemSize;
//
// use the selected item as the basis if it was visible, otherwise use
// the top item
//
int nLinesPerScreen = GetSignificantSize() / nItemSize;
int iOldBasis;
if (
m_iOldSelection >= iOldTop
&& m_iOldSelection < iOldTop + nLinesPerScreen
) {
//
// visible
//
iOldBasis = m_iOldSelection;
} else {
iOldBasis = iOldTop;
}
//
// get the scroll offset from the basis to the top, so we can try
// to keep the basis perfectly stable.
//
int nTopFromBasis = GetScrollPos() - iOldBasis * nItemSize;
//
// find the new basis...
//
int iNewBasis = FindNearestNewIndex(iOldBasis);
//
// set the scroll position relative to the new basis
//
SetScrollPos(iNewBasis * nItemSize + nTopFromBasis);
}
//
// update m_vectItemsOld to contain the new contents
//
int nNewCount = m_plist->GetCount();
m_vectItemsOld.SetCount(nNewCount);
for (int i = 0; i < nNewCount; i++) {
m_vectItemsOld.Set(i, m_plist->GetItem(i));
}
m_iOldSelection = m_indexSelection;
}
}