supertux
bullet.hpp
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 HEADER_SUPERTUX_OBJECT_BULLET_HPP
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 
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 */
Simple two dimensional vector.
Definition: vector.hpp:24
Definition: bullet.hpp:26
Physics engine.
Definition: physic.hpp:27
virtual void collision_solid(const CollisionHit &hit) override
this function is called when the object collided with something solid
Definition: bullet.cpp:96
virtual HitResponse collision(GameObject &other, const CollisionHit &hit) override
this function is called when the object collided with any other object
Definition: bullet.cpp:117
Base class for all the things that make up Levels&#39; Sectors.
Definition: game_object.hpp:46
void ricochet(GameObject &other, const CollisionHit &hit)
Makes bullet bounce off an object (that got hit).
Definition: bullet.cpp:111
Base class for all dynamic/moving game objects.
Definition: moving_object.hpp:31
virtual void draw(DrawingContext &context) override
The GameObject should draw itself onto the provided DrawingContext if this function is called...
Definition: bullet.cpp:87
virtual void update(float dt_sec) override
This function is called once per frame and allows the object to update it&#39;s state.
Definition: bullet.cpp:60
virtual bool is_saveable() const override
Indicates if the object will be saved.
Definition: bullet.hpp:35
This class provides functions for drawing things on screen.
Definition: drawing_context.hpp:42
This class collects data about a collision.
Definition: collision_hit.hpp:44