2023-01-04 14:37:54 +03:00
|
|
|
#pragma once
|
2023-01-04 14:56:03 +03:00
|
|
|
#include <SFML/Window.hpp>
|
|
|
|
#include <SFML/Graphics.hpp>
|
|
|
|
class Paddle;
|
|
|
|
class Ball;
|
2023-01-04 14:37:54 +03:00
|
|
|
class Arkanoid;
|
|
|
|
|
2023-01-04 13:46:41 +03:00
|
|
|
class Bonus
|
|
|
|
{
|
2023-01-06 00:44:44 +03:00
|
|
|
protected:
|
2023-01-04 13:46:41 +03:00
|
|
|
inline static const float speed = 120;
|
|
|
|
inline static const float radius = 15;
|
|
|
|
|
|
|
|
sf::Vector2f m_position;
|
|
|
|
float m_time;
|
|
|
|
|
|
|
|
public:
|
|
|
|
Bonus(sf::Vector2f position);
|
|
|
|
void update(float dt);
|
2023-01-06 00:44:44 +03:00
|
|
|
virtual void draw(sf::RenderWindow& window) const {};
|
|
|
|
virtual void activate(Arkanoid& game){};
|
|
|
|
virtual ~Bonus(){};
|
2023-01-04 13:46:41 +03:00
|
|
|
|
|
|
|
bool isColiding(const Paddle& paddle) const;
|
|
|
|
// Класс Arkanoid должен быть дружественным, так как он может менять внутреннее объекта-бонуса
|
|
|
|
friend class Arkanoid;
|
|
|
|
};
|
|
|
|
|
2023-01-06 00:44:44 +03:00
|
|
|
class TripleBallBonus : public Bonus {
|
|
|
|
public:
|
|
|
|
TripleBallBonus(sf::Vector2f position): Bonus(position) {};
|
|
|
|
void draw(sf::RenderWindow& window) const;
|
|
|
|
void activate(Arkanoid& game);
|
|
|
|
~TripleBallBonus();
|
|
|
|
};
|
|
|
|
|
|
|
|
class EnlargePaddleBonus : public Bonus {
|
|
|
|
public:
|
|
|
|
EnlargePaddleBonus(sf::Vector2f position): Bonus(position) {};
|
|
|
|
void draw(sf::RenderWindow& window) const;
|
|
|
|
void activate(Arkanoid& game);
|
|
|
|
~EnlargePaddleBonus();
|
|
|
|
};
|
|
|
|
|
|
|
|
class ShrinkPaddleBonus : public Bonus {
|
|
|
|
public:
|
|
|
|
ShrinkPaddleBonus(sf::Vector2f position): Bonus(position) {};
|
|
|
|
void draw(sf::RenderWindow& window) const;
|
|
|
|
void activate(Arkanoid& game);
|
|
|
|
~ShrinkPaddleBonus();
|
|
|
|
};
|
|
|
|
|
|
|
|
class SlowingBonus : public Bonus {
|
|
|
|
private:
|
|
|
|
double mDuration = 10;
|
|
|
|
public:
|
|
|
|
SlowingBonus(sf::Vector2f position): Bonus(position) {};
|
|
|
|
void draw(sf::RenderWindow& window) const;
|
|
|
|
void activate(Arkanoid& game);
|
|
|
|
~SlowingBonus();
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Effects
|
|
|
|
* */
|
|
|
|
|
|
|
|
class Effect {
|
|
|
|
private:
|
|
|
|
double mStartTime;
|
|
|
|
double mDuration;
|
|
|
|
public:
|
|
|
|
Effect(double start_time, double duration);
|
|
|
|
virtual void activate(Arkanoid& game) {};
|
|
|
|
virtual void deactivate(Arkanoid& game) {};
|
|
|
|
bool isExpired(double time);
|
|
|
|
};
|
|
|
|
|
|
|
|
class SlowingEffect : public Effect {
|
|
|
|
private:
|
|
|
|
double mSlowingFactor = 0.1;
|
|
|
|
public:
|
|
|
|
SlowingEffect(double start_time, double duration);
|
|
|
|
void activate(Arkanoid& game);
|
|
|
|
void deactivate(Arkanoid& game);
|
|
|
|
};
|