123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- #pragma once
- #include <vector>
- #include <SFML/Graphics.hpp>
- #include <SFML/Audio.hpp>
- using namespace sf;
- class Map;
- class Bullet;
- class ActualPlayer;
- class AiPlayer;
- class PowerupManager;
- class Player: public ConvexShape
- {
- public:
- Player(Map* map);
- ~Player();
- void setColor(Color color);
-
- void logic(float delta);
- void spawnBullet(bool altFire);
- void drawBullets(RenderTarget& target) const;
- void hasten();
- void addNuke();
- int nukes() const;
- void growStronger();
- void rateOfFire();
-
- void kill(bool increaseScore);
- bool isDead() const;
-
- static ActualPlayer* actualPlayer;
- static std::vector<AiPlayer*>* aiPlayer;
- static unsigned totalScore;
- protected:
- Vector2f movementHelper(float delta, bool key1, bool key2, float& velocity, float angle, float speed, float damping);
- int _nukes;
- float _speed;
- int _strength;
- float _rateOfFire;
- Sound _laser;
- SoundBuffer _laserLaser;
- Sound _kill;
- SoundBuffer _killKill;
- Sound _powerup;
- SoundBuffer _powerupPowerup;
- private:
- Map* _map;
- Color _color;
- std::vector<Bullet*> _bullets;
- bool _dead;
- };
- class ActualPlayer: public Player
- {
- public:
- ActualPlayer(Map* map): Player(map) {_nukes = 1;};
- void input(float delta, Map* map, const Vector2f mouse);
- };
- class AiPlayer: public Player
- {
- public:
- AiPlayer(Map* map): Player(map), _velocity(0), _targetRotation(0), _targetRotationDeviation(0), _powerupManager(nullptr) {};
- void input(float delta, Map* map, ActualPlayer* player);
- void registerPowerups(PowerupManager* mgr);
- private:
- void updateAi(Map* map, ActualPlayer* player);
- Clock _clock;
- Clock _clock2;
- float _velocity;
- float _targetRotation;
- float _targetRotationDeviation;
- Vector2f _targetPos;
- PowerupManager* _powerupManager;
- };
|