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); } }
// 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(); }
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; } }