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