File: Ship.hpp

package info (click to toggle)
marsshooter 0.7.6-10
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 80,812 kB
  • sloc: cpp: 20,216; xml: 29; makefile: 8
file content (119 lines) | stat: -rw-r--r-- 3,377 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/* Ship.hpp

Copyright (c) 2010 - 2011 by Felix Lauer and Simon Schneegans

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, either version 3 of the License, or (at your option)
any later version.

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/>. */

# ifndef SHIP_HPP_INCLUDED
# define SHIP_HPP_INCLUDED

# include "SpaceObjects/MobileSpaceObject.hpp"
# include "Weapons/Weapon.hpp"
# include "Specials/Special.hpp"
# include "DecoObjects/Ice.hpp"

# define ITEM_CANNON_CONTROL 0

class Player;
class PowerUp;

class Ship: public MobileSpaceObject {
    public:
        Ship(Vector2f const& location, float rotation, Player* owner);

        void update();
        void draw() const;
        void drawWeapon() const;

        void onCollision(SpaceObject* with, Vector2f const& location,
                         Vector2f const& direction, Vector2f const& velocity);

        void onShockWave(Player* damageSource, float intensity);

        void setDamageSource(Player* evilOne);
        void drainLife(Player* source, float amount, Vector2f const& direction, float waitForOtherDamage = 0.001f);

        void heal(Player* source, int amount);
        void refuel(Player* source, int amount);

        float   getLife()  const;
        float   getFuel()  const;
        Player* getOwner() const;

        float   rotation() const;

        bool    collidable() const;
        bool    attackable() const;

        std::vector<PowerUp*> const& getCollectedPowerUps() const;

        friend class Controller;
        friend class BotController;
        friend class KeyController;
        friend class CannonControl;
        friend class PowerUp;
        friend class PUHealth;
        friend class PUFuel;
        friend class ShipName;
        friend class ShipHighlight;
        friend class Tutorial;
        friend class Blast;
        friend class Freezer;
        friend class FireWall;
        friend class Shocker;
        friend class Heal;
        friend class Special;
        friend class Weapon;
        template <typename Object> friend class Ice;
        friend class Team;

    private:

        void explode();
        void respawn();

        Player* owner_;

        float rotation_;
        float rotateSpeed_;
        int up_, left_, right_;
        bool docked_;
        bool weaponChange_;
        bool specialChange_;

        bool visible_;
        float ghostTimer_;
        float frozen_;
        float respawnTimer_;
        float damageSourceResetTimer_;

        Vector2f respawnLocation_;
        float respawnRotation_;

        Weapon* currentWeapon_;
        Special* currentSpecial_;

        float life_, maxLife_;
        float fuel_, maxFuel_;

        std::vector<PowerUp*> collectedPowerUps_;

        int fragStars_;
        float damageByLocalPlayer_;
        float damageCheckTimer_;
        Vector2f damageDirection_;
        int collisionCount_;
};

# endif // SHIP_HPP_INCLUDED