1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- /**
- * 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 <http://www.gnu.org/licenses/>.
- */
- #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;
- };
|