3d928be0e53d6844cab492242e8a26ed954a5d52
[supertux.git] / src / object / 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 "video/surface.h"
26 #include "timer.h"
27 #include "scene.h"
28 #include "math/physic.h"
29 #include "special/game_object.h"
30 #include "special/moving_object.h"
31 #include "serializable.h"
32 #include "utils/lispwriter.h"
33
34 /* Bounciness of distros: */
35 #define NO_BOUNCE 0
36 #define BOUNCE 1
37
38 namespace SuperTux {
39 class Sprite;
40 }
41
42 class BouncyCoin : public GameObject
43 {
44 public:
45   BouncyCoin(const Vector& pos);
46   ~BouncyCoin();
47   virtual void action(float elapsed_time);
48   virtual void draw(DrawingContext& context);
49
50 private:
51   Sprite* sprite;
52   Vector position;
53   Timer2 timer;
54 };
55
56 class BrokenBrick : public GameObject
57 {
58 public:
59   BrokenBrick(Sprite* sprite, const Vector& pos, const Vector& movement);
60   ~BrokenBrick();
61
62   virtual void action(float elapsed_time);
63   virtual void draw(DrawingContext& context);
64
65 private:
66   Timer2 timer;
67   Sprite* sprite;
68   Vector position;
69   Vector movement;
70 };
71
72 class FloatingText : public GameObject
73 {
74 public:
75   FloatingText(const Vector& pos, const std::string& text_);
76   FloatingText(const Vector& pos, int s);  // use this for score, for instance
77   
78   virtual void action(float elapsed_time);
79   virtual void draw(DrawingContext& context);
80
81 private:
82   Vector position;
83   std::string text;
84   Timer2 timer;  
85 };
86
87 #if 0
88 extern Sprite *img_trampoline;
89
90 class Trampoline : public MovingObject, public Serializable
91 {
92 public:
93   Trampoline(LispReader& reader);
94   Trampoline(float x, float y);
95  
96   virtual void write(LispWriter& writer);
97   virtual void action(float frame_ratio);
98   virtual void draw(DrawingContext& context);
99
100   virtual void collision(const MovingObject& other, int);
101   void collision(void *p_c_object, int c_object, CollisionType type);
102
103   Physic physic;
104   enum { M_NORMAL, M_HELD } mode;
105
106  private:
107   float power;
108   unsigned int frame;
109 };
110 #endif
111
112 extern Sprite *img_smoke_cloud;
113
114 class SmokeCloud : public GameObject
115 {
116 public:
117   SmokeCloud(const Vector& pos);
118   
119   virtual void action(float elapsed_time);
120   virtual void draw(DrawingContext& context);
121
122 private:
123   Timer2 timer;
124   Vector position;
125 };
126
127 class Particles : public GameObject
128 {
129 public:
130   Particles(const Vector& epicenter, int min_angle, int max_angle,
131             const Vector& initial_velocity, const Vector& acceleration,
132             int number, Color color, int size, float life_time, int drawing_layer);
133   ~Particles();
134   
135   virtual void action(float elapsed_time);
136   virtual void draw(DrawingContext& context);
137
138 private:
139   Vector accel;
140   Timer2 timer;
141   bool live_forever;
142
143   Color color;
144   float size;
145   int drawing_layer;
146
147   struct Particle {
148     Vector pos, vel;
149 //     float angle;
150     };
151   std::vector <Particle*> particles;
152 };
153
154 void load_object_gfx();
155 void free_object_gfx();
156
157 #endif 
158
159 /* Local Variables: */
160 /* mode:c++ */
161 /* End: */