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