void TimerUnit::Initialize(int LargeNumberSpriteID, int SmallNumberSpriteID, int CasingSpriteID, int CaptionFontID) { LargeNumberSprite.InitializeSpriteCopy(GetGlobalSpriteData(LargeNumberSpriteID)); SmallNumberSprite.InitializeSpriteCopy(GetGlobalSpriteData(SmallNumberSpriteID)); CasingSprite.InitializeSpriteCopy(GetGlobalSpriteData(CasingSpriteID)); CaptionFont = GetFontBySizeIndex(CaptionFontID); //NOW WE MUST FIGURE OUT WHERE TO PUT EVERYTHING. //FIRST, THE CASING. RECT Client; GetClientRect(TheDisplay.GetHWnd(), &Client); AbsCasingOrigin.x = ((Client.right - Client.left) / 2) - (CasingSprite.GetWidth() / 2) + 100; AbsCasingOrigin.y = CasingSprite.GetHeight() * -1; CasingSprite.SetLoc(AbsCasingOrigin); RelCaptionOrigin.y = CasingSprite.GetHeight(); SetCaption("TIMER"); //TIME HEIGHT AND WIDTH RelTimeOrigin.y = 13; //5 BIG DIGITS AND 3 SMALL ONES int TimeWidth = 5 * LargeNumberSprite.GetWidth() + 3 * SmallNumberSprite.GetWidth(); RelTimeOrigin.x = (CasingSprite.GetWidth() / 2); RelTimeOrigin.x -= (TimeWidth / 2); //ALL WIDTHS AND HEIGHTS ACCOUNTED FOR. Status = 3; }
void CursorPhysicsMachine::Update(int TimeDiff, POINT SystemCursor) { //CALCULATE SYSTEM DELTA. mSystemDelta.x = (mSystemCursor.x - SystemCursor.x); mSystemDelta.y = (mSystemCursor.y - SystemCursor.y); //DEAL W/ NO PHYSICS. if(!mPhysicsActive){ mGameCursor.x = mSystemCursor.x - mSystemDelta.x; mGameCursor.y = mSystemCursor.y - mSystemDelta.y; } else{ //ELSE, PHYSICS BEGINS. FIRST, TRANSLATE THE SYSTEM DELTA INTO ACCEL DELTA. mGameDeltaAccel.x = (double)(mSystemDelta.x * TimeDiff) * mAccel; mGameDeltaAccel.y = (double)(mSystemDelta.y * TimeDiff) * mAccel; //NOW, UPLOAD THEM TO THE SPEED. mGameDeltaSpeed.x -= mGameDeltaAccel.x; mGameDeltaSpeed.y -= mGameDeltaAccel.y; //NOW UPLOAD THE SPEED TO THE POSITION. mGameCursor.x += mGameDeltaSpeed.x; mGameCursor.y += mGameDeltaSpeed.y; //NOW BLEED OFF THE DRAG. if(mGameDeltaSpeed.x < 0){ mGameDeltaSpeed.x += mDrag; if(mGameDeltaSpeed.x > 0) mGameDeltaSpeed.x = 0; } else if(mGameDeltaSpeed.x > 0){ mGameDeltaSpeed.x -= mDrag; if(mGameDeltaSpeed.x < 0) mGameDeltaSpeed.x = 0; } if(mGameDeltaSpeed.y < 0){ mGameDeltaSpeed.y += mDrag; if(mGameDeltaSpeed.y > 0) mGameDeltaSpeed.y = 0; } else if(mGameDeltaSpeed.y > 0){ mGameDeltaSpeed.y -= mDrag; if(mGameDeltaSpeed.y < 0) mGameDeltaSpeed.y = 0; } } //STORE NEW CURSOR POS. if(mPhysicsActive) StopGameCursorAtBounds(); mSystemCursor = GetGameCursorPoint(); POINT mTo = mSystemCursor; ClientToScreen(TheDisplay.GetHWnd(), &mTo); SetCursorPos(mTo.x, mTo.y); }
void DrawBulletsRemaining(Weapon* DrawMe, int timediff) { Sprite* BulletSprite; Sprite* MySprite; Bullet* TheBullet; char* Name = "INVALID BULLETS"; RECT Client; GetClientRect(TheDisplay.GetHWnd(), &Client); TheBullet = GetGlobalBulletData(DrawMe->mBulletID); if(!TheBullet) return; Name = TheBullet->mName; BulletSprite = GetGlobalSpriteData(TheBullet->mFullBulletSpriteID); if(!BulletSprite) return; MySprite = new Sprite; MySprite->InitializeSpriteCopy(BulletSprite); POINT FontOrigin; FontOrigin.x = Client.right - DrawMe->mMaxRounds * BulletSprite->GetWidth(); int StrWidth = GetFontBySizeIndex(WEAPONSELECTOR_BULLET_FONT_ID)->GetStringWidth(Name); if(FontOrigin.x + StrWidth > Client.right) FontOrigin.x -= (FontOrigin.x + StrWidth) - Client.right + 20; FontOrigin.y = Client.bottom - BulletSprite->GetHeight() - GetFontBySizeIndex(WEAPONSELECTOR_BULLET_FONT_ID)->GetCharHeight() - 5; int FullWidth = DrawMe->mCurrentRounds * BulletSprite->GetWidth(); if(FullWidth > Client.right - Client.left) return; GameWeaponSelector.BulletName->SetLoc(FontOrigin); GameWeaponSelector.BulletName->SetWidth(Client.right - Client.left); int FullHeight = BulletSprite->GetHeight(); POINT Loc; Loc.x = Client.right - FullWidth; Loc.y = Client.bottom - FullHeight; for(int i = 0; i < DrawMe->mCurrentRounds; i++) { MySprite->SetLoc(Loc); MySprite->Draw(TheDisplay); Loc.x += BulletSprite->GetWidth(); } GameWeaponSelector.BulletName->Update(timediff); GameWeaponSelector.BulletName->Draw(TheDisplay); delete MySprite; }
void BriefingBox::Init() { mBoxSprite.InitializeSpriteCopy(GetGlobalSpriteData(BRIEFINGBOX_SPRITE_NUMBER)); mBoxSprite.SetDelay(800); RECT Client; GetClientRect(TheDisplay.GetHWnd(), &Client); mCenterToStop = ((Client.right - Client.left) / 2) - (mBoxSprite.GetWidth() / 2); int MaxLines = 10; Font* TheFont = GetFontBySizeIndex(BRIEFINGBOX_TEXT_FONTNUMBER); if(TheFont){ int Height = (mBoxSprite.GetHeight() - BRIEFINGBOX_TEXT_BOTTOM) - BRIEFINGBOX_TEXT_YOFFSET; MaxLines = Height / TheFont->GetCharHeight(); } mCenterToClose = mBoxSprite.GetWidth() * -1; mOrigin.y = ((Client.bottom - Client.top) / 2) - (mBoxSprite.GetHeight() / 2); mOrigin.x = mCenterToClose; mCurrentText.Initialize("TESTING!", mOrigin, 20, mBoxSprite.GetWidth() - (3 * BRIEFINGBOX_TEXT_XOFFSET), BRIEFINGBOX_TEXT_FONTNUMBER, BRIEFINGBOX_CURSOR_SPRITE_NUMBER, 80, -1, BRIEFINGBOX_CURSOR_SOUND_NUMBER, BRIEFINGBOX_CURSOR_ENDLINESOUND_NUMBER, MaxLines); }
void SpawnShellCasing(POINT spawn, Weapon* Weap) { Bullet* TheBullet = GetGlobalBulletData(Weap->mBulletID); if(!TheBullet) return; BounceObject* SC = new BounceObject(*GetGlobalSoundData(TheBullet->mShellCasingBounceSoundID)); RECT Client; GetClientRect(TheDisplay.GetHWnd(), &Client); SC->SetBounds(Client); SC->SetPhysics(true); SC->mGravity = 0.2; SC->mXSpeed = 15.5 + rand()%10; SC->mYSpeed = -16.5 - rand()%10; SC->SetTimeToLive(rand()%200 + 800); SC->GetSprite()->InitializeSpriteCopy(GetGlobalSpriteData(TheBullet->mShellCasingGlobalGraphicsID)); spawn.x -= SC->GetSprite()->GetWidth() / 2; spawn.y -= SC->GetSprite()->GetHeight() / 2; SC->GetSprite()->SetLoc(spawn); SC->GetSprite()->SetFrame(rand()%SC->GetSprite()->GetNumFramesInCurrentState()); SC->GetSprite()->SetDelay(rand()%10 + 5); BounceObjectList.push_front(SC); }