예제 #1
0
bool CollisionDetector::isLandingSuccessful() {
    GameObjectManager *gameObjManager = GameObjectManager::instance();
    Spaceship *spaceship = gameObjManager->getSpaceship();
    TerrainGenerator* terrainGenerator = TerrainGenerator::instance();
    TerrainSegment* segment = terrainGenerator->getTerrainSegmentBasedOnX(spaceship->getXPosition());
    
    if (typeid(LandingPad) != typeid(*segment)) {
        return false;
    } else {
        return landingSucceeds(spaceship);
    }
}
예제 #2
0
bool CollisionDetector::spaceshipCrashWillHappen() {
    GameObjectManager *gameObjManager = GameObjectManager::instance();
    Spaceship *spaceship = gameObjManager->getSpaceship();
    TerrainGenerator* terrainGenerator = TerrainGenerator::instance();
    TerrainSegment* segment = terrainGenerator->getTerrainSegmentBasedOnX(spaceship->getXPosition());
    
    if (typeid(LandingPad) == typeid(*segment)) {
        bool softLanding = spaceship->getYSpeed() > landingSpeedLimit;
        bool withinLandingPad = segment->isSpaceshipWithinSegment(spaceship);
        return softLanding && withinLandingPad;
    } else {
        return collisionHappens(spaceship);
    }
    
}