6cbac9838bc6dccb7e769a9f6ee8ef3be4b78322
[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 #ifndef SUPERTUX_GAMEOBJS_H
22 #define SUPERTUX_GAMEOBJS_H
23
24 #include "video/surface.h"
25 #include "timer.h"
26 #include "math/physic.h"
27 #include "game_object.h"
28 #include "moving_object.h"
29 #include "serializable.h"
30
31 /* Bounciness of distros: */
32 #define NO_BOUNCE 0
33 #define BOUNCE 1
34
35 class Sprite;
36
37 class BouncyCoin : public GameObject
38 {
39 public:
40   BouncyCoin(const Vector& pos);
41   ~BouncyCoin();
42   virtual void action(float elapsed_time);
43   virtual void draw(DrawingContext& context);
44
45 private:
46   Sprite* sprite;
47   Vector position;
48   Timer2 timer;
49 };
50
51 class BrokenBrick : public GameObject
52 {
53 public:
54   BrokenBrick(Sprite* sprite, const Vector& pos, const Vector& movement);
55   ~BrokenBrick();
56
57   virtual void action(float elapsed_time);
58   virtual void draw(DrawingContext& context);
59
60 private:
61   Timer2 timer;
62   Sprite* sprite;
63   Vector position;
64   Vector movement;
65 };
66
67 class FloatingText : public GameObject
68 {
69 public:
70   FloatingText(const Vector& pos, const std::string& text_);
71   FloatingText(const Vector& pos, int s);  // use this for score, for instance
72   
73   virtual void action(float elapsed_time);
74   virtual void draw(DrawingContext& context);
75
76 private:
77   Vector position;
78   std::string text;
79   Timer2 timer;  
80 };
81
82 extern Sprite *img_smoke_cloud;
83
84 class SmokeCloud : public GameObject
85 {
86 public:
87   SmokeCloud(const Vector& pos);
88   
89   virtual void action(float elapsed_time);
90   virtual void draw(DrawingContext& context);
91
92 private:
93   Timer2 timer;
94   Vector position;
95 };
96
97 class Particles : public GameObject
98 {
99 public:
100   Particles(const Vector& epicenter, int min_angle, int max_angle,
101             const Vector& initial_velocity, const Vector& acceleration,
102             int number, Color color, int size, float life_time, int drawing_layer);
103   ~Particles();
104   
105   virtual void action(float elapsed_time);
106   virtual void draw(DrawingContext& context);
107
108 private:
109   Vector accel;
110   Timer2 timer;
111   bool live_forever;
112
113   Color color;
114   float size;
115   int drawing_layer;
116
117   struct Particle {
118     Vector pos, vel;
119 //     float angle;
120     };
121   std::vector <Particle*> particles;
122 };
123
124 void load_object_gfx();
125 void free_object_gfx();
126
127 #endif 
128
129 /* Local Variables: */
130 /* mode:c++ */
131 /* End: */