a first implementation of doors to switch between sectors
[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 "screen/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 "moving_object.h"
33 #include "serializable.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
41 {
42 public:
43   BouncyDistro(const Vector& pos);
44   virtual void action(float elapsed_time);
45   virtual void draw(DrawingContext& context);
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
60 {
61 public:
62   BrokenBrick(Tile* tile, const Vector& pos, const Vector& movement);
63
64   virtual void action(float elapsed_time);
65   virtual void draw(DrawingContext& context);
66
67 private:
68   Timer timer;
69   Tile* tile;
70   Vector position;
71   Vector movement;
72 };
73
74 class BouncyBrick : public GameObject
75 {
76 public:
77   BouncyBrick(const Vector& pos);
78   virtual void action(float elapsed_time);
79   virtual void draw(DrawingContext& context);
80   
81 private:
82   Vector position;
83   float offset;   
84   float offset_m;
85   int shape;      
86 };
87
88 class FloatingScore : public GameObject
89 {
90 public:
91   FloatingScore(const Vector& pos, int s);
92   
93   virtual void action(float elapsed_time);
94   virtual void draw(DrawingContext& context);
95
96 private:
97   Vector position;
98   char str[10];
99   Timer timer;  
100 };
101
102 class Trampoline : public MovingObject, public Serializable
103 {
104 public:
105   Trampoline(LispReader& reader);
106  
107   virtual void write(LispWriter& writer);
108   virtual void action(float frame_ratio);
109   virtual void draw(DrawingContext& context);
110
111   virtual void collision(const MovingObject& other, int);
112   void collision(void *p_c_object, int c_object, CollisionType type);
113
114   Physic physic;
115   enum { M_NORMAL, M_HELD } mode;
116
117  private:
118   float power;
119   unsigned int frame;
120 };
121
122 class FlyingPlatform : public MovingObject, public Serializable
123 {
124 public:
125   FlyingPlatform(LispReader& reader);
126  
127   virtual void write(LispWriter& writer);
128   virtual void action(float frame_ratio);
129   virtual void draw(DrawingContext& context);
130
131   virtual void collision(const MovingObject& other, int);
132   void collision(void *p_c_object, int c_object, CollisionType type);
133
134   float get_vel_x() { return vel_x; }
135   float get_vel_y() { return vel_y; }
136
137   Physic physic;
138   enum { M_NORMAL, M_HELD } mode;
139
140  private:
141   std::vector<int> pos_x;
142   std::vector<int> pos_y;
143   float velocity;
144
145   float vel_x, vel_y;  // calculated based in the velocity
146
147   int point;
148   bool move;
149   unsigned int frame;
150 };
151
152 void load_object_gfx();
153
154 #endif 
155
156 /* Local Variables: */
157 /* mode:c++ */
158 /* End: */