Block::Block(Rules& rules, const sf::Color& color, int health) : Entity(rules) { _highlight = false; _highlightPhase = 0.0f; _drop = false; _health = health; _decay = 1.0f; _rotation = 0.0f; _angularVelocity = 0.0f; _color = color; _blockSprite = ImageManager::Instance().CreateSprite("res/brick.png"); _blockSprite.Resize(BLOCK_WIDTH, BLOCK_HEIGHT); _blockSprite.SetColor(_color); SetBBox(MATH::BBox2(MATH::Vector2(0.0f, 0.0f), MATH::Vector2(BLOCK_WIDTH, BLOCK_HEIGHT))); SetPhysicsModel(PHY_GHOST); SetCollisionModel(PHY_SOLID); SetAcceleration(1.0f); SetVelocity(MATH::Vector2(0.0f, 0.0f)); SetMass(100000.0f); }
Ball::Ball(Rules& rules) : Entity(rules) { rules.numBalls++; _ignited = false; _dying = false; _scoreSound = SoundManager::Instance().GetSound("res/ding.wav", false); _bounceSound = SoundManager::Instance().GetSound("res/bounce.wav", false); _ballSprite = ImageManager::Instance().CreateSprite("res/ball3.png"); _ballSprite.SetColor(sf::Color(232, 243, 255)); _ballSprite.Resize(BALL_SIZE, BALL_SIZE); MATH::Vector2 randomVector(0, -1.0f); randomVector = MATH::Rotate(randomVector, sf::Randomizer::Random(-0.1f, 0.1f)); randomVector = MATH::Normalize(randomVector); SetAcceleration(1.0f); SetVelocity(randomVector * 300.0f); SetMass(1.0f); SetPhysicsModel(PHY_TOUCHING | PHY_SOLID | PHY_BOUNCING); SetCollisionModel(PHY_SOLID); SetBBox(MATH::BBox2(MATH::Vector2(0.0f, 0.0f), MATH::Vector2(BALL_SIZE, BALL_SIZE))); }
BulletParticle::BulletParticle() : Particle("bullet_particle") { SetCollisionModel(true, false, false); m_rebound_sound = "weapon/m16_cartridge"; m_left_time_to_live = 1; start_to_fade = 0; image = ParticleEngine::GetSprite(BULLET_spr); image->Scale(1.0,1.0); SetSize(Point2i(1, 1)); }
void Cluster::Shoot(const Point2i & pos, Double strength, Double angle) { SetCollisionModel(true, true, false ); // a bit hackish... // we do need to collide with objects, but if we allow for this, the clusters // will explode on spawn (because of colliding with each other) StartTimeout(); Camera::GetInstance()->FollowObject(this); ResetConstants(); SetXY( pos ); SetSpeed(strength, angle); }
PolecatFart::PolecatFart() : Particle("polecat_fart_particle") { m_initial_time_to_live = 50; m_left_time_to_live = m_initial_time_to_live; m_time_between_scale = 100; SetCollisionModel(false, false, false); is_active = true; image = ParticleEngine::GetSprite(POLECAT_FART_spr); image->Scale(1.0,1.0); SetSize( Point2i(10, 10) ); }
void ExtraBallItem::Touch(Paddle& paddle, TouchInfo info) { SetPhysicsModel(PHY_GHOST); SetCollisionModel(PHY_GHOST); Die(); entPtr_t ball = entPtr_t(new ENT::Ball(GetRules())); ball->SetPosition(paddle.GetPosition() + MATH::Vector2((paddle.GetBBox().lowerRight.x / 2.0f) - (BALL_SIZE / 2.0f), -(BALL_SIZE + 1.0f))); Entity::LinkToWorld(ball); paddle.AttachEntity(ball); }
Plane::Plane(AirAttackConfig &p_cfg) : PhysicalObj("air_attack_plane"), cfg(p_cfg) { SetCollisionModel(false, false, false); image = GetResourceManager().LoadSprite(weapons_res_profile, "air_attack_plane"); image->EnableCaches(true, 0); SetSize(image->GetSize()); obus_dx = 100; obus_dy = GetY() + GetHeight(); flying_sound.Play("default", "weapon/aircraft_flying"); }
ExtraBallItem::ExtraBallItem(Rules& rules) : Entity(rules) { _itemSprite = ImageManager::Instance().CreateSprite("res/item_extraball.png"); _itemSprite.Resize(ITEM_WIDTH, ITEM_HEIGHT); SetBBox(MATH::BBox2(MATH::Vector2(0.0f, 0.0f), MATH::Vector2(ITEM_WIDTH, ITEM_HEIGHT))); SetAcceleration(1.0f); SetVelocity(MATH::Vector2(0.0f, 1.0f) * 100.0f); SetMass(1.0f); SetPhysicsModel(PHY_TOUCHING | PHY_GHOST); SetCollisionModel(PHY_GHOST); }
ExplosionParticle::ExplosionParticle() : Particle("explosion_particle") { SetCollisionModel(false,false,false); image = ParticleEngine::GetSprite(EXPLOSION_spr); m_initial_time_to_live = image->GetFrameCount(); m_time_left_to_live = m_initial_time_to_live; m_time_between_scale = image->GetCurrentDelay(); image->SetCurrentFrame(0); image->Start(); SetSize( Point2i(1,1) ); }
void ObjMine::FakeExplosion() { MSG_DEBUG("mine", "Fake explosion"); JukeBox::GetInstance()->Play("default", "weapon/mine_fake"); ParticleEngine::AddNow(GetPosition(), 5, particle_SMOKE, true); if ( animation ) { MSG_DEBUG("mine", "Desactive detection.."); animation = false; image->SetCurrentFrame(0); } if (launcher) launcher->SignalProjectileTimeout(); // Mine fall into the ground after a fake explosion SetCollisionModel(true, false, false); }
BodyMemberParticle::BodyMemberParticle(Sprite& spr, const Point2i& position) : Particle("body_member_particle") , angle_rad(0) { SetCollisionModel(true, false, false); m_time_left_to_live = 100; // Bug #17408: make sure there's an available surface for the sprite spr.RefreshSurface(); image = new Sprite(spr.GetSurface()); image->EnableCaches(false, 0); // Some generic particle code requires it to be flipped ASSERT(image->GetWidth() && image->GetHeight()); SetXY(position); SetSize(image->GetSize()); SetOnTop(true); MSG_DEBUG("random.get", "BodyMemberParticle::BodyMemberParticle(...) speed vector length"); Double speed_vector_length = (Double)RandomSync().GetInt(10, 15); MSG_DEBUG("random.get", "BodyMemberParticle::BodyMemberParticle(...) speed vector angle"); Double speed_vector_angle = - RandomSync().GetDouble(0, 3); SetSpeed(speed_vector_length, speed_vector_angle); }
void Block::Touch(ENT::Ball& ball, TouchInfo info) { _health--; if(0 >= _health) { SetCollisionModel(PHY_GHOST); SetVelocity(MATH::Vector2(0.0f, 100.0f)); _angularVelocity = sf::Randomizer::Random(5.0f, 10.0f); _drop = true; GetRules().numBlocks--; // TODO int r = rand() % 50; if(r <= 3) { entPtr_t item = entPtr_t(new ENT::ExtraBallItem(GetRules())); item->SetPosition(GetPosition()); Entity::LinkToWorld(item); } } _highlight = true; _highlightPhase = 0.0f; }
void CluzookaCluster::Shoot(const Point2i & start_pos, Double strength, Double angle, uint recurse_times) { m_recursion_depth = recurse_times; #else void CluzookaCluster::Shoot(const Point2i & start_pos, Double strength, Double angle) { #endif Camera::GetInstance()->FollowObject(this); ResetConstants(); SetCollisionModel(true, true, false ); // a bit hackish... // we do need to collide with objects, but if we allow for this, the clusters // will explode on spawn (because of colliding with each other) SetXY(start_pos); SetSpeed(strength, angle); explode_with_timeout = true; StartTimeout(); m_time_before_spawn = 750; // make time a bit random to unsychronize particles m_time_before_spawn += RandomSync().GetDouble(-300, 100); }