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