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))); }
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); }
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); }
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); }
// ----------------------------------------------------------------------- // // // ROUTINE: CTronPlayerObj::EndLightCycle // // PURPOSE: Player gets off a light cycle // // ----------------------------------------------------------------------- // bool CTronPlayerObj::EndLightCycle() { // Go to normal physics model. SetPhysicsModel(PPM_NORMAL); return true; }