d70bc6d3cb9b1dc9154bba2dda0afac342b809df
[supertux.git] / src / object / block.h
1 #ifndef __BLOCK_H__
2 #define __BLOCK_H__
3
4 #include "special/moving_object.h"
5
6 namespace SuperTux {
7   class Sprite;
8 }
9 class Player;
10
11 using namespace SuperTux;
12
13 class Block : public MovingObject
14 {
15 public:
16   Block(const Vector& pos, Sprite* sprite);
17   ~Block();
18
19   virtual HitResponse collision(GameObject& other, const CollisionHit& hit);
20   virtual void action(float elapsed_time);
21   virtual void draw(DrawingContext& context);
22
23 protected:
24   virtual void hit(Player& player) = 0;
25   void start_bounce();
26
27   Sprite* sprite;
28   bool bouncing;
29   float bounce_dir;
30   float bounce_offset;
31   float original_y;
32 };
33
34 class BonusBlock : public Block
35 {
36 public:
37   BonusBlock(const Vector& pos, int data);
38
39   void try_open();
40
41 protected:
42   virtual void hit(Player& player);
43
44 private:
45   int data;
46 };
47
48 class Brick : public Block
49 {
50 public:
51   Brick(const Vector& pos, int data);
52
53   void try_break(bool playerhit = false);
54
55 protected:
56   virtual void hit(Player& player);
57
58 private:
59   bool breakable;
60   int coin_counter;
61 };
62
63 #endif
64