1 | // SuperTux |
2 | // Copyright (C) 2006 Matthias Braun <matze@braunis.de> |
3 | // |
4 | // This program is free software: you can redistribute it and/or modify |
5 | // it under the terms of the GNU General Public License as published by |
6 | // the Free Software Foundation, either version 3 of the License, or |
7 | // (at your option) any later version. |
8 | // |
9 | // This program is distributed in the hope that it will be useful, |
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | // GNU General Public License for more details. |
13 | // |
14 | // You should have received a copy of the GNU General Public License |
15 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | |
17 | #ifndef HEADER_SUPERTUX_OBJECT_BULLET_HPP |
18 | #define |
19 | |
20 | #include "sprite/sprite_ptr.hpp" |
21 | #include "supertux/direction.hpp" |
22 | #include "supertux/moving_object.hpp" |
23 | #include "supertux/physic.hpp" |
24 | #include "supertux/player_status.hpp" |
25 | |
26 | class Bullet final : public MovingObject |
27 | { |
28 | public: |
29 | Bullet(const Vector& pos, float xm, Direction dir, BonusType type); |
30 | |
31 | virtual void update(float dt_sec) override; |
32 | virtual void draw(DrawingContext& context) override; |
33 | virtual void collision_solid(const CollisionHit& hit) override; |
34 | virtual HitResponse collision(GameObject& other, const CollisionHit& hit) override; |
35 | virtual bool is_saveable() const override { return false; } |
36 | |
37 | /** Makes bullet bounce off an object (that got hit). To be called |
38 | by the collision handler of that object. Note that the @c hit |
39 | parameter is filled in as perceived by the object, not by the |
40 | bullet. */ |
41 | void ricochet(GameObject& other, const CollisionHit& hit); |
42 | |
43 | BonusType get_type() const { return type; } |
44 | |
45 | private: |
46 | Physic physic; |
47 | int life_count; |
48 | SpritePtr sprite; |
49 | SpritePtr lightsprite; |
50 | BonusType type; |
51 | |
52 | private: |
53 | Bullet(const Bullet&) = delete; |
54 | Bullet& operator=(const Bullet&) = delete; |
55 | }; |
56 | |
57 | #endif |
58 | |
59 | /* EOF */ |
60 | |