HitResponse Brick::collision(GameObject& other, const CollisionHit& hit_){ Player* player = dynamic_cast<Player*> (&other); if (player) { if (player->does_buttjump) try_break(player); } BadGuy* badguy = dynamic_cast<BadGuy*> (&other); if(badguy) { // hit contains no information for collisions with blocks. // Badguy's bottom has to be below the top of the brick // SHIFT_DELTA is required to slide over one tile gaps. if( badguy->can_break() && ( badguy->get_bbox().get_bottom() > get_bbox().get_top() + SHIFT_DELTA ) ){ try_break(player); } } Portable* portable = dynamic_cast<Portable*> (&other); if(portable) { MovingObject* moving = dynamic_cast<MovingObject*> (&other); if(moving->get_bbox().get_top() > get_bbox().get_bottom() - SHIFT_DELTA) { try_break(player); } } Explosion* explosion = dynamic_cast<Explosion*> (&other); if(explosion && explosion->hurts()) { try_break(player); } return Block::collision(other, hit_); }
llvm::Constant *IRGenModule::getOrCreateOutlinedDestroyFunction( SILType T, const TypeInfo &ti, const OutliningMetadataCollector &collector) { IRGenMangler mangler; auto manglingBits = getTypeAndGenericSignatureForManglingOutlineFunction(T); auto funcName = mangler.mangleOutlinedDestroyFunction(manglingBits.first, manglingBits.second); auto ptrTy = ti.getStorageType()->getPointerTo(); llvm::SmallVector<llvm::Type *, 4> paramTys; paramTys.push_back(ptrTy); collector.addMetadataParameterTypes(paramTys); return getOrCreateHelperFunction(funcName, ptrTy, paramTys, [&](IRGenFunction &IGF) { Explosion params = IGF.collectParameters(); Address addr = ti.getAddressForPointer(params.claimNext()); collector.bindMetadataParameters(IGF, params); ti.destroy(IGF, addr, T, true); IGF.Builder.CreateRet(addr.getAddress()); }, true /*setIsNoInline*/); }
void Game::SpawnExplosion(int x, int y) { Explosion* explosion = new Explosion(); explosion->SetPositionX(x - 10); explosion->SetPositionY(y - 10); AnimatedSprite* exploding = m_pBackBuffer->CreateAnimatedSprite("assets\\explosion.png"); exploding->SetLooping(false); exploding->SetFrameWidth(64); exploding->SetFrameSpeed(0.05); exploding->AddFrame(0); exploding->AddFrame(64); exploding->AddFrame(128); exploding->AddFrame(192); exploding->AddFrame(256); explosion->Initialise(exploding); Explosions.push_back(explosion); }
static void ExplosionActivate(unsigned int aId) { const ExplosionTemplate &explosiontemplate = Database::explosiontemplate.Get(aId); Explosion *explosion = new Explosion(explosiontemplate, aId); Database::explosion.Put(aId, explosion); explosion->Activate(); }
Explosion* Level::createExplosion( Vec2f const& pos , float raidus ) { Explosion* e = new Explosion( pos , raidus ); e->init(); addObjectInternal( e ); return e; }
Object *Explosion::clone(SerializedObject *serializedObject) { Explosion *newObject = new Explosion(this->explosionType, this->geometry->getPosition()); newObject->setValues(serializedObject); return (newObject); }
Explosion* Explosion::create() { Explosion* boom = new Explosion(); boom->init(); return boom; }
void CDestructibleModel::RegisterDestroyedStimulus() { // Register audio and visual stimulus if specified. if( (m_nDestroyAlarmLevel > 0) && (m_fStimRadius > 0.f) ) { LTVector vPos; g_pLTServer->GetObjectPos(m_hObject, &vPos); // Extract who caused an explosion. HOBJECT hDamager = m_hLastDamager; if( IsExplosion( hDamager ) ) { Explosion* pExplosion = (Explosion*)g_pLTServer->HandleToObject(m_hLastDamager); hDamager = pExplosion->GetFiredFrom(); } // If damager is still not a character (possibly because an explosion was triggered), assume player. // Better solution - set the alignment of the damager on the explosion? if( !IsCharacter( hDamager ) ) { CPlayerObj *pPlayer = g_pCharacterMgr->FindPlayer(); if ( pPlayer ) { hDamager = pPlayer->m_hObject; } } g_pAIStimulusMgr->RegisterStimulus( kStim_EnemyDisturbanceSound, m_nDestroyAlarmLevel, hDamager, m_hObject, vPos, m_fStimRadius ); m_eStimID = g_pAIStimulusMgr->RegisterStimulus( kStim_EnemyDisturbanceVisible, m_nDestroyAlarmLevel + 1, hDamager, m_hObject, vPos, m_fStimRadius ); } }
static void emitTypeTraitBuiltin(IRGenFunction &IGF, Explosion &out, Explosion &args, SubstitutionList substitutions, TypeTraitResult (TypeBase::*trait)()) { assert(substitutions.size() == 1 && "type trait should have gotten single type parameter"); args.claimNext(); // Lower away the trait to a tristate 0 = no, 1 = yes, 2 = maybe. unsigned result; switch ((substitutions[0].getReplacement().getPointer()->*trait)()) { case TypeTraitResult::IsNot: result = 0; break; case TypeTraitResult::Is: result = 1; break; case TypeTraitResult::CanBe: result = 2; break; } out.add(llvm::ConstantInt::get(IGF.IGM.Int8Ty, result)); }
void Game::SpawnExplosion(int x, int y) { Sprite* aS = m_pBackBuffer->CreateSprite("assets\\explosion.png"); // create an explosion object Explosion* explosion = new Explosion(); // initialize the texture if (!explosion->Initialise(*aS->GetTexture())) { LogManager::GetInstance().Log("Explosion Init Fail!"); return; } // set the width and speed of the animation int fw = aS->GetWidth() / 5; explosion->SetFrameWidth(fw); // 5 frames in the animation explosion->SetFrameSpeed(0.1f); for (int i = 0; i < 5; i++) { explosion->AddFrame(i * fw); } // set the center points for visual alignment explosion->SetCenter(fw / 2, aS->GetHeight() / 2); // set the x and y explosion->SetX(x - explosion->GetCenterX() / 2); explosion->SetY(y - explosion->GetCenterY() / 2); // add to the explosion container m_explosion.push_back(explosion); }
void Player::PlayerHitByBall(Game_Scene* game, Ball* ball) { if (!_invincible) { //get hit _timeSinceHit = 0.0f; //daze only if not dazed too recently if (_stunLockTimer >= Settings::playerDazeInvincibilityTime) { _stunLockTimer = 0; if (ball->getType() == OilBall::type) { _sprite->setColor(_oilColour); Daze(true); } else if (ball->getType() == BombBall::type || ball->getType() == BombOther::type) { Daze(true); } else if (game->GetBallHitter(ball)->HasDoubleAttack()) { Daze(true); } else { Daze(false); } } if (ball->getType() == BombOther::type) { ((Game_Scene*)(this->getParent()->getParent()))->SeeSaw(this, -4); Explosion* boomImage; boomImage = Explosion::create(); ball->getParent()->addChild(boomImage); boomImage->setPosition(ball->getParent()->convertToWorldSpace(ball->getPosition())); ((Game_Scene*)(ball->getParent()->getParent()))->DestroyAndDropBall(ball); AudioHelper::Play("bombball"); } else if (ball->getType() == BombBall::type) { AudioHelper::Play("selfexplode"); } else if (ball->getType() == OilBall::type) { AudioHelper::PlayRandom("Oilball", 3); } else if (ball->getType() == RocketBall::type) { AudioHelper::Play("missilehit"); } AudioHelper::PlayRandom("Au", 4, (0.5 + rand_0_1() * 1.5)); } }
void MultiPartEntity::Part::onDestroy() { m_parent->onPartDestroyed(*this); Explosion* explosion = new Explosion; sf::Vector2f pos = m_parent->getPosition() + getCenter(); explosion->setPosition(pos); EntityManager::getInstance().addEntity(explosion); }
void ExplosionPool::explode(const Point3d& pos, const Point3d& vel){ if(freeList.empty()){ explosionList.push_back(new Explosion("explostion", pos, vel)); }else { Explosion* e = freeList.front(); freeList.pop_front(); e->set(pos, vel, 7000); explosionList.push_back(e); } }
static void emitCastBuiltin(IRGenFunction &IGF, SILType destType, Explosion &result, Explosion &args, llvm::Instruction::CastOps opcode) { llvm::Value *input = args.claimNext(); assert(args.empty() && "wrong operands to cast operation"); llvm::Type *destTy = IGF.IGM.getStorageType(destType); llvm::Value *output = IGF.Builder.CreateCast(opcode, input, destTy); result.add(output); }
void GameManager::CheckCollide(Collider* collider, Vector<Target*>& targets) { bool isCollisionChecked = false; //현재 충돌중인 타겟이 있는지 체크 -> lastTarget을 유지할 필요가 있는지 체크 for (Target* target : targets) { if (collider->IsBullet()) { Bullet* bullet = static_cast<Bullet*>(collider); if (IsCollision(target, bullet)) { isCollisionChecked = true; if (bullet->m_currentCollidingTarget == target) { continue; } target->ApplyCollisionEffect(collider); bullet->m_currentCollidingTarget = target; if (target->IsMirror()) { break; } } } else { Explosion* explosion = static_cast<Explosion*>(collider); const float explosionRadius = explosion->GetBoundingRadius(); const Vec2 explosionPosition = explosion->getPosition(); const Rect targetBoundingBox = target->GetBoundingArea(); if ( targetBoundingBox.intersectsCircle( explosionPosition, explosionRadius) ) { target->ApplyCollisionEffect(explosion); } } } //for문 끝 if (!isCollisionChecked) { if (collider->IsBullet()) { Bullet* bullet = static_cast<Bullet*>(collider); if (bullet != nullptr) { bullet->m_currentCollidingTarget = nullptr; } } } }
void CDestructibleModel::RegisterDestroyedStimulus() { // Register audio and visual stimulus if specified. if( (m_nDestroyAlarmLevel > 0) && (m_fStimRadius > 0.f) ) { LTVector vPos; g_pLTServer->GetObjectPos(m_hObject, &vPos); // Extract who caused an explosion. HOBJECT hDamager = m_hLastDamager; if( IsExplosion( hDamager ) ) { Explosion* pExplosion = (Explosion*)g_pLTServer->HandleToObject(m_hLastDamager); hDamager = pExplosion->GetFiredFrom(); } // If damager is still not a character (possibly because an explosion was triggered), assume player. // Better solution - set the alignment of the damager on the explosion? if( !IsCharacter( hDamager ) ) { CPlayerObj *pPlayer = g_pCharacterMgr->FindPlayer(); if ( pPlayer ) { hDamager = pPlayer->m_hObject; } } if ( IsCharacter(hDamager) ) { CCharacter* pCharacter = (CCharacter*)g_pLTServer->HandleToObject(hDamager); if ( pCharacter ) { // Register the disturbance sound. StimulusRecordCreateStruct DisturbanceSoundSCS( kStim_DisturbanceSound, pCharacter->GetAlignment(), vPos, hDamager ); DisturbanceSoundSCS.m_hStimulusTarget = m_hObject; DisturbanceSoundSCS.m_flAlarmScalar = (float)m_nDestroyAlarmLevel; DisturbanceSoundSCS.m_flRadiusScalar = m_fStimRadius; g_pAIStimulusMgr->RegisterStimulus( DisturbanceSoundSCS ); // Register the visible disturbance. StimulusRecordCreateStruct DisturbanceVisibleSCS( kStim_DisturbanceVisible, pCharacter->GetAlignment(), vPos, hDamager ); DisturbanceVisibleSCS.m_hStimulusTarget = m_hObject; DisturbanceVisibleSCS.m_flAlarmScalar = (float)(m_nDestroyAlarmLevel + 1); DisturbanceVisibleSCS.m_flRadiusScalar = m_fStimRadius; m_eStimID = g_pAIStimulusMgr->RegisterStimulus( DisturbanceVisibleSCS ); } } } }
Explosion * Application::FetchExplosion() { for (vector<Explosion*>::iterator it = explosionList.begin(); it != explosionList.end(); ++it) { Explosion* e = *it; if (!e->isActive()) { return e; } } return nullptr; }
static void emitCompareBuiltin(IRGenFunction &IGF, Explosion &result, Explosion &args, llvm::CmpInst::Predicate pred) { llvm::Value *lhs = args.claimNext(); llvm::Value *rhs = args.claimNext(); llvm::Value *v; if (lhs->getType()->isFPOrFPVectorTy()) v = IGF.Builder.CreateFCmp(pred, lhs, rhs); else v = IGF.Builder.CreateICmp(pred, lhs, rhs); result.add(v); }
void SkyDive::explode (void) { if (!is_valid ()) return; Explosion *explosion = new Explosion (get_anchor_pos (bbox, ANCHOR_BOTTOM)); explosion->hurts (true); explosion->pushes (false); Sector::current()->add_object (explosion); remove_me (); } /* void explode */
void Ship::destroy() { g_LIFE--; CCPoint p = getPosition(); CCNode* myParent = getParent(); Explosion* exp = new Explosion(); exp->setPosition(p); myParent->addChild(exp); exp->release(); myParent->removeChild(this,true); if (SOUND) { SimpleAudioEngine::sharedEngine()->playEffect(s_shipDestroyEffect); } }
//---------------------------------------------------------------------------- // Explode //---------------------------------------------------------------------------- void Splash::spawnExplosion() { if( !mDataBlock->explosion ) return; Explosion* pExplosion = new Explosion; pExplosion->onNewDataBlock(mDataBlock->explosion, false); MatrixF trans = getTransform(); trans.setPosition( getPosition() ); pExplosion->setTransform( trans ); pExplosion->setInitialState( trans.getPosition(), VectorF(0,0,1), 1); if (!pExplosion->registerObject()) delete pExplosion; }
void Application::DestroyEnemy(Enemy * e) { if (e->GetActive()) { // Spawn explosion Explosion* ex = FetchExplosion(); if (ex) { ex->Init(e->GetX(), e->GetY()); // Reset enemy e->Reset(); } } }
void DepthCharge::Impact() { Explosion *explosion = new Explosion(); explosion->SetTeamId( m_teamId ); explosion->SetPosition( m_longitude, m_latitude ); explosion->m_intensity = 100; explosion->m_underWater = true; for( int i = 0; i < g_app->GetWorld()->m_teams.Size(); ++i ) { Team *team = g_app->GetWorld()->m_teams[i]; explosion->m_visible[team->m_teamId] = true; } int expId = g_app->GetWorld()->m_explosions.PutData( explosion ); explosion->m_objectId = expId; g_soundSystem->TriggerEvent( "Object_carrier", "DepthCharge", Vector3<Fixed>(m_longitude, m_latitude,0) ); for( int i = 0; i < g_app->GetWorld()->m_objects.Size(); ++i ) { if( g_app->GetWorld()->m_objects.ValidIndex(i) ) { WorldObject *wobj = g_app->GetWorld()->m_objects[i]; if( wobj->m_type == WorldObject::TypeSub && wobj->m_teamId != m_teamId ) { Fixed rangeSqd = g_app->GetWorld()->GetDistanceSqd( m_longitude, m_latitude, wobj->m_longitude, wobj->m_latitude); if( rangeSqd <= 5 * 5 ) { if( wobj->m_currentState == 2 ) { m_attackOdds = 0; } Fixed factor = 2 - rangeSqd/(5 * 5); int odds = (m_attackOdds * factor).IntValue(); if( odds > syncrand() % 100 ) { wobj->m_life = 0; wobj->m_lastHitByTeamId = m_teamId; } } } } } }
void ObjectManager::addExplosion(float radius, float impact, float x, float y){ Explosion * e = new Explosion; e->setImpactAmount(impact); Object * temp = new Explosion; objects.push_back(temp); objects.back()->setID( objects.size()-1 ); b2BodyDef bodyDef; bodyDef.userData = temp; bodyDef.type = b2_dynamicBody; //Plaats het object in het midden van de getekende vorm. bodyDef.position.Set( x , y ); temp->setBody(world->CreateBody(&bodyDef) ); temp->setInterfaces(renderer, this , gameStats); temp->initialize(radius, radius); }
void Mob::onDestroy( unsigned flag ) { getLevel()->getColManager().removeBody( mBody ); if ( flag & SDF_CAST_EFFECT ) { Explosion* e = getLevel()->createExplosion( getPos(), 128 ); e->setParam(128,3000,200); for(int i=0; i<4; i++) { DebrisPickup* c = new DebrisPickup( getPos() ); c->init(); getLevel()->addItem( c ); } } BaseClass::onDestroy( flag ); }
void ManagerModel::AddExplosion(Vec2 startPosition, Model::EntityType entity) { Explosion *explosion = DBG_NEW Explosion(); explosion->OnInit(this); explosion->mPos = startPosition; if (entity == ENTITY_ASTEROID) { explosion->mScale /= 1.5; } else if (entity == ENTITY_PLAYER) { explosion->mScale *= 2; } else if (entity == ENTITY_ENEMIEBOSS) { explosion->mScale *= 3; } mEntities.push_back(explosion); for (auto *view : mViews) { view->OnExplosionSpawned((Explosion*)explosion); view->PlayExplosionSoundEffect((Explosion*)explosion); } }
void IRGenFunction::emitFakeExplosion(const TypeInfo &type, Explosion &explosion) { if (!isa<LoadableTypeInfo>(type)) { explosion.add(llvm::UndefValue::get(type.getStorageType()->getPointerTo())); return; } ExplosionSchema schema = cast<LoadableTypeInfo>(type).getSchema(); for (auto &element : schema) { llvm::Type *elementType; if (element.isAggregate()) { elementType = element.getAggregateType()->getPointerTo(); } else { elementType = element.getScalarType(); } explosion.add(llvm::UndefValue::get(elementType)); } }
void CProjectile::AddExplosion(LTVector vPos, LTVector vNormal) { HCLASS hClass = g_pLTServer->GetClass("Explosion"); if (!hClass) return; ObjectCreateStruct theStruct; INIT_OBJECTCREATESTRUCT(theStruct); theStruct.m_Pos = vPos; LTRotation rRot; g_pLTServer->AlignRotation(&rRot, &vNormal, &vNormal); theStruct.m_Rotation = rRot; Explosion* pExplosion = (Explosion*)g_pLTServer->CreateObject(hClass, &theStruct); if (pExplosion) { pExplosion->Setup(m_hFiredFrom, m_nAmmoId); } }
void Landmine::explode() { destroyed = true; Sound::sound->playSoundEffect(SFX_EXPLOSION, emitter); Explosion* explosion = new Explosion((hkTransform*) &(body->getTransform()), owner); explosion->doDamage(); explosion = NULL; SmokeParticle* smoke = new SmokeParticle(); hkVector4 pos; pos.setXYZ(body->getPosition()); smoke->setPosition(&pos); SmokeSystem::system->addSmoke(EXPLOSION_SMOKE, smoke); smoke = NULL; }
/// Emit a checked cast of a metatype. void irgen::emitMetatypeDowncast(IRGenFunction &IGF, llvm::Value *metatype, CanMetatypeType toMetatype, CheckedCastMode mode, Explosion &ex) { // Pick a runtime entry point and target metadata based on what kind of // representation we're casting. llvm::Value *castFn; llvm::Value *toMetadata; switch (toMetatype->getRepresentation()) { case MetatypeRepresentation::Thick: { // Get the Swift metadata for the type we're checking. toMetadata = IGF.emitTypeMetadataRef(toMetatype.getInstanceType()); switch (mode) { case CheckedCastMode::Unconditional: castFn = IGF.IGM.getDynamicCastMetatypeUnconditionalFn(); break; case CheckedCastMode::Conditional: castFn = IGF.IGM.getDynamicCastMetatypeFn(); break; } break; } case MetatypeRepresentation::ObjC: { assert(IGF.IGM.ObjCInterop && "should have objc runtime"); // Get the ObjC metadata for the type we're checking. toMetadata = emitClassHeapMetadataRef(IGF, toMetatype.getInstanceType(), MetadataValueType::ObjCClass); switch (mode) { case CheckedCastMode::Unconditional: castFn = IGF.IGM.getDynamicCastObjCClassMetatypeUnconditionalFn(); break; case CheckedCastMode::Conditional: castFn = IGF.IGM.getDynamicCastObjCClassMetatypeFn(); break; } break; } case MetatypeRepresentation::Thin: llvm_unreachable("not implemented"); } auto cc = IGF.IGM.DefaultCC; if (auto fun = dyn_cast<llvm::Function>(castFn)) cc = fun->getCallingConv(); auto call = IGF.Builder.CreateCall(castFn, {metatype, toMetadata}); call->setCallingConv(cc); call->setDoesNotThrow(); ex.add(call); }