A couple of improvements for the flying platform.
[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(Camera& viewport, int layer);
46
47 private:
48   Vector position;
49   float ym;
50 };
51
52 extern Surface* img_distro[4];
53
54 #define BOUNCY_BRICK_MAX_OFFSET 8
55 #define BOUNCY_BRICK_SPEED 0.9
56
57 class Tile;
58
59 class BrokenBrick : public GameObject, public Drawable
60 {
61 public:
62   BrokenBrick(DisplayManager& displaymanager, Tile* tile,
63       const Vector& pos, const Vector& movement);
64
65   virtual void action(float elapsed_time);
66   virtual void draw(Camera& viewport, int layer);
67
68 private:
69   Timer timer;
70   Tile* tile;
71   Vector position;
72   Vector movement;
73 };
74
75 class BouncyBrick : public GameObject, public Drawable
76 {
77 public:
78   BouncyBrick(DisplayManager& displaymanager, const Vector& pos);
79   virtual void action(float elapsed_time);
80   virtual void draw(Camera& viewport, int layer);
81   
82 private:
83   Vector position;
84   float offset;   
85   float offset_m;
86   int shape;      
87 };
88
89 class FloatingScore : public GameObject, public Drawable
90 {
91 public:
92   FloatingScore(DisplayManager& displaymanager, const Vector& pos, int s);
93   
94   virtual void action(float elapsed_time);
95   virtual void draw(Camera& viewport, int layer);
96
97 private:
98   Vector position;
99   char str[10];
100   Timer timer;  
101 };
102
103 class Trampoline : public MovingObject, public Drawable, public Serializable
104 {
105 public:
106   Trampoline(DisplayManager& displaymanager, LispReader& reader);
107  
108   virtual void write(LispWriter& writer);
109   virtual void action(float frame_ratio);
110   virtual void draw(Camera& viewport, int layer);
111
112   virtual void collision(const MovingObject& other, int);
113   void collision(void *p_c_object, int c_object, CollisionType type);
114
115   Physic physic;
116   enum { M_NORMAL, M_HELD } mode;
117
118  private:
119   float power;
120   unsigned int frame;
121 };
122
123 class FlyingPlatform : public MovingObject, public Drawable, public Serializable
124 {
125 public:
126   FlyingPlatform(DisplayManager& displaymanager, LispReader& reader);
127  
128   virtual void write(LispWriter& writer);
129   virtual void action(float frame_ratio);
130   virtual void draw(Camera& viewport, int layer);
131
132   virtual void collision(const MovingObject& other, int);
133   void collision(void *p_c_object, int c_object, CollisionType type);
134
135   float get_vel_x() { return vel_x; }
136   float get_vel_y() { return vel_y; }
137
138   Physic physic;
139   enum { M_NORMAL, M_HELD } mode;
140
141  private:
142   std::vector<int> pos_x;
143   std::vector<int> pos_y;
144   float velocity;
145
146   float vel_x, vel_y;  // calculated based in the velocity
147
148   int point;
149   bool move;
150   unsigned int frame;
151 };
152
153 void load_object_gfx();
154
155 #endif 
156
157 /* Local Variables: */
158 /* mode:c++ */
159 /* End: */