bool Game::SpriteCollision(Sprite* pSpriteHitter, Sprite* pSpriteHittee){ GameEngine *pGameEngine = GameEngine::GetEngine(); // See if the chicken was hit if (pSpriteHittee == _pChickenSprite) { // Move the chicken back to the start _pChickenSprite->SetPosition(4, 175); // See if the game is over if (--_iNumLives > 0) SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION , "Henway", "Ouch!", pGameEngine->GetWindow()); else { // Display game over message char szText[64]; sprintf(szText, "Game Over! You scored %d points.", _iScore); SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION , "Henway", szText, pGameEngine->GetWindow()); _bGameOver = true; } return false; } return true; }
//----------------------------------------------------------------- // Functions //----------------------------------------------------------------- void Game::MoveChicken(int iXDistance, int iYDistance) { GameEngine *pGameEngine = GameEngine::GetEngine(); // Move the chicken to its new position _pChickenSprite->OffsetPosition(iXDistance, iYDistance); // See if the chicken made it across if (_pChickenSprite->GetPosition().x > 400) { // Move the chicken back to the start and add to the score _pChickenSprite->SetPosition(4, 175); _iScore += 150; SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION , "Henway", "You made it!", pGameEngine->GetWindow()); } }