added lava tiles
[supertux.git] / src / gameobjs.h
1 //  $Id$
2 // 
3 //  SuperTux
4 //  Copyright (C) 2000 Bill Kendrick <bill@newbreedsoftware.com>
5 //  Copyright (C) 2004 Tobias Glaesser <tobi.web@gmx.de>
6 //
7 //  This program is free software; you can redistribute it and/or
8 //  modify it under the terms of the GNU General Public License
9 //  as published by the Free Software Foundation; either version 2
10 //  of the License, or (at your option) any later version.
11 //
12 //  This program is distributed in the hope that it will be useful,
13 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
14 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 //  GNU General Public License for more details.
16 // 
17 //  You should have received a copy of the GNU General Public License
18 //  along with this program; if not, write to the Free Software
19 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20 //  02111-1307, USA.
21
22 #ifndef SUPERTUX_GAMEOBJS_H
23 #define SUPERTUX_GAMEOBJS_H
24
25 #include "special/base.h"
26 #include "video/surface.h"
27 #include "special/timer.h"
28 #include "scene.h"
29 #include "math/physic.h"
30 #include "collision.h"
31 #include "special/game_object.h"
32 #include "special/moving_object.h"
33 #include "serializable.h"
34 #include "utils/lispwriter.h"
35
36 /* Bounciness of distros: */
37 #define NO_BOUNCE 0
38 #define BOUNCE 1
39
40 namespace SuperTux {
41 class Sprite;
42 }
43
44 struct TileId;
45
46 class BouncyDistro : public GameObject
47 {
48 public:
49   BouncyDistro(const Vector& pos);
50   virtual void action(float elapsed_time);
51   virtual void draw(DrawingContext& context);
52
53 private:
54   Vector position;
55   float ym;
56 };
57
58 extern Surface* img_distro[4];
59
60 #define BOUNCY_BRICK_MAX_OFFSET 8
61 #define BOUNCY_BRICK_SPEED 0.9
62
63 class Tile;
64
65 class BrokenBrick : public GameObject
66 {
67 public:
68   BrokenBrick(Tile* tile, const Vector& pos, const Vector& movement);
69
70   virtual void action(float elapsed_time);
71   virtual void draw(DrawingContext& context);
72
73 private:
74   Timer timer;
75   Tile* tile;
76   Vector position;
77   Vector movement;
78 };
79
80 class BouncyBrick : public GameObject
81 {
82 public:
83   BouncyBrick(const Vector& pos);
84   virtual void action(float elapsed_time);
85   virtual void draw(DrawingContext& context);
86   
87 private:
88   Vector position;
89   float offset;   
90   float offset_m;
91   TileId& shape;      
92 };
93
94 class FloatingScore : public GameObject
95 {
96 public:
97   FloatingScore(const Vector& pos, int s);
98   
99   virtual void action(float elapsed_time);
100   virtual void draw(DrawingContext& context);
101
102 private:
103   Vector position;
104   char str[10];
105   Timer timer;  
106 };
107
108 #define TRAMPOLINE_FRAMES 4
109 extern Sprite *img_trampoline[TRAMPOLINE_FRAMES];
110
111 class Trampoline : public MovingObject, public Serializable
112 {
113 public:
114   Trampoline(LispReader& reader);
115   Trampoline(float x, float y);
116  
117   virtual void write(LispWriter& writer);
118   virtual void action(float frame_ratio);
119   virtual void draw(DrawingContext& context);
120
121   virtual void collision(const MovingObject& other, int);
122   void collision(void *p_c_object, int c_object, CollisionType type);
123
124   Physic physic;
125   enum { M_NORMAL, M_HELD } mode;
126
127  private:
128   float power;
129   unsigned int frame;
130 };
131
132 extern Sprite *img_flying_platform;
133
134 class FlyingPlatform : public MovingObject, public Serializable
135 {
136 public:
137   FlyingPlatform(LispReader& reader);
138   FlyingPlatform(int x, int y);
139  
140   virtual void write(LispWriter& writer);
141   virtual void action(float frame_ratio);
142   virtual void draw(DrawingContext& context);
143
144   virtual void collision(const MovingObject& other, int);
145   void collision(void *p_c_object, int c_object, CollisionType type);
146
147   float get_vel_x() { return vel_x; }
148   float get_vel_y() { return vel_y; }
149
150   Physic physic;
151   enum { M_NORMAL, M_HELD } mode;
152
153  private:
154   std::vector<int> pos_x;
155   std::vector<int> pos_y;
156   float velocity;
157
158   float vel_x, vel_y;  // calculated based in the velocity
159
160   int point;
161   bool move;
162   unsigned int frame;
163 };
164
165 void load_object_gfx();
166
167 #endif 
168
169 /* Local Variables: */
170 /* mode:c++ */
171 /* End: */