- added support for different types of objects
[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
30 template <class T>
31 struct ObjectData
32 {
33   int x;
34   int y;
35   T type_specific;
36
37   ObjectData(ObjectData* pobject)
38     : x((int)pobject->x), y((int)pobject->y) {};
39   ObjectData(int x_, int y_, T type_specific_) 
40     : x(x_), y(y_), type_specific(type_specific_) {};
41
42   ObjectData()
43     : x(0), y(0), type_specific() {};
44 };
45
46 struct TrampolineData
47 {
48   unsigned int power;
49 };
50
51
52 /* Bounciness of distros: */
53 #define NO_BOUNCE 0
54 #define BOUNCE 1
55
56 class BouncyDistro : public GameObject
57 {
58  public:
59   
60   void init(float x, float y);
61   void action(double frame_ratio);
62   void draw(); 
63   std::string type() { return "BouncyDistro"; };
64 };
65
66 extern Surface* img_distro[4];
67
68 #define BOUNCY_BRICK_MAX_OFFSET 8
69 #define BOUNCY_BRICK_SPEED 0.9
70
71 class Tile;
72
73 class BrokenBrick : public GameObject
74 {
75  public:
76   Timer timer;
77   Tile* tile;
78
79   void init(Tile* tile, float x, float y, float xm, float ym);
80   void action(double frame_ratio);
81   void draw();
82   std::string type() { return "BrokenBrick"; };
83 };
84
85 class BouncyBrick : public GameObject
86 {
87  public:
88   float offset;
89   float offset_m;
90   int shape;
91
92   void init(float x, float y);
93   void action(double frame_ratio);
94   void draw();
95   std::string type() { return "BouncyBrick"; };
96 };
97
98 class FloatingScore : public GameObject
99 {
100  public:
101   int value;
102   Timer timer;
103   
104   void init(float x, float y, int s);
105   void action(double frame_ratio);
106   void draw();
107   std::string type() { return "FloatingScore"; };
108 };
109
110 class Trampoline : public GameObject
111 {
112  public:
113   void init(float x, float y);
114   void action(double frame_ratio);
115   void draw();
116   std::string type() { return "Trampoline"; };
117 };
118
119 void load_trampoline_gfx();
120
121 #endif 
122
123 /* Local Variables: */
124 /* mode:c++ */
125 /* End: */