//************************************************************************ void CNutDropScene::ResetSpriteScore (LPSPRITE lpScore1, LPSPRITE lpScore2) //************************************************************************ { if (!lpScore1 || !lpScore2) return; lpScore1->SetCurrentCell (m_nScoreCells - 1); lpScore2->SetCurrentCell (0); lpScore1->Draw(); lpScore2->Draw(); }
//************************************************************************ void CNutDropScene::CheckObjectCollision (LPSPRITE lpSprite) //************************************************************************ { if (!m_lpPlayerSprite || !m_pAnimator) return; // See if they've picked enough already if (m_nGoodPicks >= m_nMatchesNeeded) return; static BOOL fBusy = FALSE; if (fBusy) return; fBusy = TRUE; RECT rBasket, rBasketX; rBasket = (m_WalkDir == WALKLEFT ? m_rLeftBasket : m_rRightBasket ); m_lpPlayerSprite->Location (&rBasketX); OffsetRect( &rBasket, rBasketX.left, rBasketX.top ); IntersectRect( &rBasket, &rBasket, &rBasketX ); if (m_pAnimator->CheckCollision (m_lpPlayerSprite, lpSprite, &rBasket)) { int idx = GetObjectIndex (lpSprite); if (idx == -1 || m_ObjectList[idx].m_nState == StateGoodPick) { fBusy = FALSE; return; } m_ObjectList[idx].m_nState = StateGoodPick; m_nGoodPicks++; // Play the got one sound if one is defined FNAME szFileName; GetPathName (szFileName, m_szGotOneWave); if (m_nGoodPicks < m_nMatchesNeeded) { if (GetSound() && m_szGotOneWave[0] != '\0') { GetSound()->StopChannel (NORMAL_CHANNEL); GetSound()->StartFile (szFileName, NO/*bLoop*/, NORMAL_CHANNEL/*iChannel*/, FALSE); } } else PlaySound(szFileName, FALSE); // how to play with wait AND wavemix // Hide this object lpSprite->Show (FALSE); // Update the caught score UpdateSpriteScore (m_lpCaughtScore[0], m_lpCaughtScore[1], m_nGoodPicks); // See if they've picked enough to win this level if (m_nGoodPicks >= m_nMatchesNeeded) PlayLevelSuccessWave(); } fBusy = FALSE; }
//************************************************************************ void CNutDropScene::UpdateSpriteScore (LPSPRITE lpScore1, LPSPRITE lpScore2, int iScore) //************************************************************************ { if (!lpScore1 || !lpScore2) return; int iTmp = iScore; if (iTmp > 99) return; if (iTmp < 10) { lpScore2->SetCurrentCell (iTmp); lpScore2->Draw(); } else { lpScore1->SetCurrentCell (iTmp / 10); while (iTmp > 10) iTmp -= 10; if (iTmp == 10) iTmp = 0; lpScore2->SetCurrentCell (iTmp); lpScore1->Draw(); lpScore2->Draw(); } }
//************************************************************************ void CCreditsScene::OnSpriteNotify( LPSPRITE lpSprite, SPRITE_NOTIFY Notify ) //************************************************************************ { if (Notify != SN_MOVEDONE) return; lpSprite->Kill(); if ( !m_pContributors ) return; int i = m_nNextContributor; DWORD dwDelay = m_pContributors[i].m_dwDelayTime; if ( (dwDelay == 1) || (!dwDelay && !m_pAnimator->GetNumSprites()) ) StartNext(); }
//************************************************************************ BOOL CCreditsScene::StartNext() //************************************************************************ { if ( !m_pContributors ) return( NO ); m_dwLastTime = timeGetTime(); int i = m_nNextContributor; if ( ++m_nNextContributor >= m_nContributors ) m_nNextContributor = 0; PDIB pDib; int iType = m_pContributors[i].m_iType; if ( !(pDib = TextToDib(m_pContributors[i].m_szName, m_szFaceName[iType], m_ptSize[iType], m_fItalic[iType], m_Color[iType], GetPalette(), m_BackgrndColor)) ) return(NO/*fStarted*/); POINT ptOrigin; ptOrigin.x = 0; ptOrigin.y = 0; LPSPRITE lpSprite = m_pAnimator->CreateSprite( &ptOrigin ); lpSprite->AddCell( pDib, 0, 0 ); lpSprite->SetSpeed( m_pContributors[i].m_iSpeed ); lpSprite->SetNotifyProc(::OnSpriteNotify, (DWORD)this); int x; if (m_fCenter) { int iWidth, iHeight; lpSprite->GetMaxSize(&iWidth, &iHeight); x = (RectWidth(&m_rGameArea) - iWidth) / 2; x += m_rGameArea.left; } else x = m_pContributors[i].m_ptStart.x; lpSprite->Jump(x, m_pContributors[i].m_ptStart.y); lpSprite->Show(TRUE); if (!m_fCenter) x = m_pContributors[i].m_ptEnd.x; lpSprite->AddCmdMove(x, m_pContributors[i].m_ptEnd.y); return(YES/*fStarted*/); }
//************************************************************************ LPSPRITE CNutDropScene::CreateScoreSprite (int x, int y, int iCell) //************************************************************************ { FNAME szFileName; POINT ptOrigin; ptOrigin.x = 0; ptOrigin.y = 0; LPSPRITE lpSprite = m_pAnimator->CreateSprite (&ptOrigin); if (lpSprite && m_szScoreBmp[0] != '\0') { GetPathName (szFileName, m_szScoreBmp); lpSprite->AddCells (szFileName, m_nScoreCells, NULL); lpSprite->SetCellsPerSec (0); lpSprite->SetCurrentCell (iCell); lpSprite->Jump (x, y); lpSprite->Show (TRUE); } return lpSprite; }