/** * one room arena * Copyright (C) 2016 POSITIVE MENTAL ATTITUDE * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, version 3 of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #pragma once #include #include #include 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; 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 _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; };