New flying platform object.
[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 "type.h"
26 #include "texture.h"
27 #include "timer.h"
28 #include "scene.h"
29 #include "physic.h"
30 #include "collision.h"
31 #include "game_object.h"
32 #include "drawable.h"
33 #include "moving_object.h"
34 #include "lispwriter.h"
35
36 /* Bounciness of distros: */
37 #define NO_BOUNCE 0
38 #define BOUNCE 1
39
40 class BouncyDistro : public GameObject, public Drawable
41 {
42 public:
43   BouncyDistro(DisplayManager& displaymanager, const Vector& pos);
44   virtual void action(float elapsed_time);
45   virtual void draw(ViewPort& viewport, int layer);
46   virtual std::string type() const
47   { return "BouncyDistro"; };
48
49 private:
50   Vector position;
51   float ym;
52 };
53
54 extern Surface* img_distro[4];
55
56 #define BOUNCY_BRICK_MAX_OFFSET 8
57 #define BOUNCY_BRICK_SPEED 0.9
58
59 class Tile;
60
61 class BrokenBrick : public GameObject, public Drawable
62 {
63 public:
64   BrokenBrick(DisplayManager& displaymanager, Tile* tile,
65       const Vector& pos, const Vector& movement);
66
67   virtual void action(float elapsed_time);
68   virtual void draw(ViewPort& viewport, int layer);
69
70   virtual std::string type() const
71   { return "BrokenBrick"; };
72
73 private:
74   Timer timer;
75   Tile* tile;
76   Vector position;
77   Vector movement;
78 };
79
80 class BouncyBrick : public GameObject, public Drawable
81 {
82 public:
83   BouncyBrick(DisplayManager& displaymanager, const Vector& pos);
84   virtual void action(float elapsed_time);
85   virtual void draw(ViewPort& viewport, int layer);
86   
87   virtual std::string type() const
88   { return "BouncyBrick"; };
89
90 private:
91   Vector position;
92   float offset;   
93   float offset_m;
94   int shape;      
95 };
96
97 class FloatingScore : public GameObject, public Drawable
98 {
99 public:
100   FloatingScore(DisplayManager& displaymanager, const Vector& pos, int s);
101   
102   virtual void action(float elapsed_time);
103   virtual void draw(ViewPort& viewport, int layer);
104   virtual std::string type() const
105   { return "FloatingScore"; };
106
107 private:
108   Vector position;
109   char str[10];
110   Timer timer;  
111 };
112
113 class Trampoline : public MovingObject, public Drawable, public Serializable
114 {
115 public:
116   Trampoline(DisplayManager& displaymanager, LispReader& reader);
117  
118   virtual void write(LispWriter& writer);
119   virtual void action(float frame_ratio);
120   virtual void draw(ViewPort& viewport, int layer);
121   virtual std::string type() const
122   { return "Trampoline"; };
123
124   virtual void collision(const MovingObject& other, int);
125   void collision(void *p_c_object, int c_object, CollisionType type);
126
127   Physic physic;
128   enum { M_NORMAL, M_HELD } mode;
129
130  private:
131   float power;
132   unsigned int frame;
133 };
134
135 class FlyingPlatform : public MovingObject, public Drawable, public Serializable
136 {
137 public:
138   FlyingPlatform(DisplayManager& displaymanager, LispReader& reader);
139  
140   virtual void write(LispWriter& writer);
141   virtual void action(float frame_ratio);
142   virtual void draw(ViewPort& viewport, int layer);
143   virtual std::string type() const
144   { return "Trampoline"; };
145
146   virtual void collision(const MovingObject& other, int);
147   void collision(void *p_c_object, int c_object, CollisionType type);
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   int point;
158   bool move;
159   unsigned int frame;
160 };
161
162 void load_object_gfx();
163
164 #endif 
165
166 /* Local Variables: */
167 /* mode:c++ */
168 /* End: */