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