- Added images for ducking big Super Tux.
[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 extern Sprite *img_trampoline;
109
110 class Trampoline : public MovingObject, public Serializable
111 {
112 public:
113   Trampoline(LispReader& reader);
114   Trampoline(float x, float y);
115  
116   virtual void write(LispWriter& writer);
117   virtual void action(float frame_ratio);
118   virtual void draw(DrawingContext& context);
119
120   virtual void collision(const MovingObject& other, int);
121   void collision(void *p_c_object, int c_object, CollisionType type);
122
123   Physic physic;
124   enum { M_NORMAL, M_HELD } mode;
125
126  private:
127   float power;
128   unsigned int frame;
129 };
130
131 extern Sprite *img_flying_platform;
132
133 class FlyingPlatform : public MovingObject, public Serializable
134 {
135 public:
136   FlyingPlatform(LispReader& reader);
137   FlyingPlatform(int x, int y);
138  
139   virtual void write(LispWriter& writer);
140   virtual void action(float frame_ratio);
141   virtual void draw(DrawingContext& context);
142
143   virtual void collision(const MovingObject& other, int);
144   void collision(void *p_c_object, int c_object, CollisionType type);
145
146   float get_vel_x() { return vel_x; }
147   float get_vel_y() { return vel_y; }
148
149   Physic physic;
150   enum { M_NORMAL, M_HELD } mode;
151
152  private:
153   std::vector<int> pos_x;
154   std::vector<int> pos_y;
155   float velocity;
156
157   float vel_x, vel_y;  // calculated based in the velocity
158
159   int point;
160   bool move;
161   unsigned int frame;
162 };
163
164 extern Sprite *img_smoke_cloud;
165
166 class SmokeCloud : public GameObject
167 {
168 public:
169   SmokeCloud(const Vector& pos);
170   
171   virtual void action(float elapsed_time);
172   virtual void draw(DrawingContext& context);
173
174 private:
175   Timer timer;
176   Vector position;
177 };
178
179 void load_object_gfx();
180
181 #endif 
182
183 /* Local Variables: */
184 /* mode:c++ */
185 /* End: */