|
|
|
@ -6,6 +6,11 @@
|
|
|
|
|
#include "ball.hpp"
|
|
|
|
|
#include "paddle.hpp"
|
|
|
|
|
|
|
|
|
|
/* =============
|
|
|
|
|
* ===Bonuses===
|
|
|
|
|
* =============
|
|
|
|
|
* */
|
|
|
|
|
|
|
|
|
|
Bonus::Bonus(sf::Vector2f position): m_position(position)
|
|
|
|
|
{
|
|
|
|
|
m_time = 0;
|
|
|
|
@ -55,9 +60,10 @@ void TripleBallBonus::activate(Arkanoid& game)
|
|
|
|
|
|
|
|
|
|
bool isSlowed = false;
|
|
|
|
|
bool toApply = true;
|
|
|
|
|
|
|
|
|
|
Effect* slowing_effect = nullptr;
|
|
|
|
|
for (auto it = game.m_effects.begin(); it != game.m_effects.end();) {
|
|
|
|
|
if ((*it)->effectId == 0) {
|
|
|
|
|
if ((*it)->effectId == _EFFECT_SLOWING_ID) {
|
|
|
|
|
isSlowed = true;
|
|
|
|
|
slowing_effect = *it;
|
|
|
|
|
break;
|
|
|
|
@ -100,8 +106,6 @@ void TripleBallBonus::activate(Arkanoid& game)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TripleBallBonus::~TripleBallBonus() {}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* EnlargePaddleBonus
|
|
|
|
|
* */
|
|
|
|
@ -126,8 +130,6 @@ void EnlargePaddleBonus::activate(Arkanoid& game)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
EnlargePaddleBonus::~EnlargePaddleBonus() {}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* ShrinkPaddleBonus
|
|
|
|
|
* */
|
|
|
|
@ -151,8 +153,6 @@ void ShrinkPaddleBonus::activate(Arkanoid& game)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ShrinkPaddleBonus::~ShrinkPaddleBonus() {}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* SlowingBonus
|
|
|
|
|
* */
|
|
|
|
@ -165,16 +165,18 @@ void SlowingBonus::draw(sf::RenderWindow& window) const
|
|
|
|
|
shape.setPosition(m_position);
|
|
|
|
|
window.draw(shape);
|
|
|
|
|
|
|
|
|
|
/*static sf::RectangleShape rect(sf::Vector2f{radius, radius / 2});
|
|
|
|
|
rect.setFillColor(sf::Color::Red);
|
|
|
|
|
rect.setPosition(m_position - sf::Vector2f{radius /2, radius / 4});
|
|
|
|
|
window.draw(rect);*/
|
|
|
|
|
static sf::CircleShape clock(radius / 2);
|
|
|
|
|
clock.setOutlineColor(sf::Color::Red);
|
|
|
|
|
clock.setOutlineThickness(3);
|
|
|
|
|
clock.setPosition(m_position - sf::Vector2f{radius /2, radius / 2});
|
|
|
|
|
window.draw(clock);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SlowingBonus::activate(Arkanoid& game)
|
|
|
|
|
{
|
|
|
|
|
bool isAlreadySlowed = false;
|
|
|
|
|
for (auto it = game.m_effects.begin(); it != game.m_effects.end();) {
|
|
|
|
|
if ((*it)->effectId == 0) {
|
|
|
|
|
if ((*it)->effectId == _EFFECT_SLOWING_ID) {
|
|
|
|
|
(*it)->mDuration += mDuration;
|
|
|
|
|
isAlreadySlowed = true;
|
|
|
|
|
break;
|
|
|
|
@ -187,10 +189,9 @@ void SlowingBonus::activate(Arkanoid& game)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SlowingBonus::~SlowingBonus() {}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Effects
|
|
|
|
|
/* =============
|
|
|
|
|
* ===Effects===
|
|
|
|
|
* =============
|
|
|
|
|
* */
|
|
|
|
|
|
|
|
|
|
Effect::Effect(char id, double start_time, double duration) : effectId(id), mStartTime(start_time), mDuration(duration) {};
|
|
|
|
@ -201,30 +202,20 @@ bool Effect::isExpired(double time) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SlowingEffect::SlowingEffect(double start_time, double duration) : Effect(0, start_time, duration) {};
|
|
|
|
|
SlowingEffect::SlowingEffect(double start_time, double duration) : Effect(_EFFECT_SLOWING_ID, start_time, duration) {};
|
|
|
|
|
|
|
|
|
|
void SlowingEffect::activate(Arkanoid& game) {
|
|
|
|
|
for (Ball& ball : game.m_balls)
|
|
|
|
|
{
|
|
|
|
|
//if (!(ball.affectedBy & 0b00000001)) {
|
|
|
|
|
//ball.affectedBy |= 0b00000001;
|
|
|
|
|
for (Ball& ball : game.m_balls) {
|
|
|
|
|
ball.velocity = sf::Vector2f{ball.velocity.x * mSlowingFactor, ball.velocity.y * mSlowingFactor};
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void SlowingEffect::activate(Ball& ball) {
|
|
|
|
|
//if (!(ball.affectedBy & 0b00000001)) {
|
|
|
|
|
//ball.affectedBy |= 0b00000001;
|
|
|
|
|
ball.velocity = sf::Vector2f{ball.velocity.x * mSlowingFactor, ball.velocity.y * mSlowingFactor};
|
|
|
|
|
ball.velocity = sf::Vector2f{ball.velocity.x * mSlowingFactor, ball.velocity.y * mSlowingFactor};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SlowingEffect::deactivate(Arkanoid& game) {
|
|
|
|
|
for (Ball& ball : game.m_balls)
|
|
|
|
|
{
|
|
|
|
|
//if (ball.affectedBy & 0b00000001) {
|
|
|
|
|
ball.velocity = sf::Vector2f{ball.velocity.x / mSlowingFactor, ball.velocity.y / mSlowingFactor};
|
|
|
|
|
// ball.affectedBy &= 0b11111110;
|
|
|
|
|
//}
|
|
|
|
|
for (Ball& ball : game.m_balls) {
|
|
|
|
|
ball.velocity = sf::Vector2f{ball.velocity.x / mSlowingFactor, ball.velocity.y / mSlowingFactor};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|