renamed all .h to .hpp
[supertux.git] / src / object / block.hpp
1 //  $Id$
2 // 
3 //  SuperTux
4 //  Copyright (C) 2005 Matthias Braun <matze@braunis.de>
5 //
6 //  This program is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU General Public License
8 //  as published by the Free Software Foundation; either version 2
9 //  of the License, or (at your option) any later version.
10 //
11 //  This program is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 //  GNU General Public License for more details.
15 // 
16 //  You should have received a copy of the GNU General Public License
17 //  along with this program; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 //  02111-1307, USA.
20 #ifndef __BLOCK_H__
21 #define __BLOCK_H__
22
23 #include "moving_object.hpp"
24 #include "lisp/lisp.hpp"
25
26 class Sprite;
27 class Player;
28
29 class Block : public MovingObject
30 {
31 public:
32   Block(Sprite* sprite = 0);
33   ~Block();
34
35   virtual HitResponse collision(GameObject& other, const CollisionHit& hit);
36   virtual void update(float elapsed_time);
37   virtual void draw(DrawingContext& context);
38
39 protected:
40   virtual void hit(Player& player) = 0;
41   void start_bounce();
42
43   Sprite* sprite;
44   bool bouncing;
45   float bounce_dir;
46   float bounce_offset;
47   float original_y;
48 };
49
50 class BonusBlock : public Block
51 {
52 public:
53   BonusBlock(const Vector& pos, int data);
54   BonusBlock(const lisp::Lisp& lisp);
55   virtual ~BonusBlock();
56
57   void try_open();
58
59 protected:
60   virtual void hit(Player& player);
61
62 private:
63   enum Contents {
64     CONTENT_COIN,
65     CONTENT_FIREGROW,
66     CONTENT_ICEGROW,
67     CONTENT_STAR,
68     CONTENT_1UP,
69     CONTENT_CUSTOM
70   };
71
72   Contents contents;
73   MovingObject* object;
74 };
75
76 class Brick : public Block
77 {
78 public:
79   Brick(const Vector& pos, int data);
80
81   void try_break(bool playerhit = false);
82
83 protected:
84   virtual void hit(Player& player);
85
86 private:
87   bool breakable;
88   int coin_counter;
89 };
90
91 #endif
92