- converted text_type into a class
[supertux.git] / src / world.h
1 //  $Id$
2 // 
3 //  SuperTux
4 //  Copyright (C) 2004 SuperTux Development Team, see AUTHORS for details
5 //
6 //  This program is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU General Public License
8 //  as published by the Free Software Foundation; either version 2
9 //  of the License, or (at your option) any later version.
10 //
11 //  This program is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 //  GNU General Public License for more details.
15 // 
16 //  You should have received a copy of the GNU General Public License
17 //  along with this program; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19
20 #ifndef SUPERTUX_WORLD_H
21 #define SUPERTUX_WORLD_H
22
23 #include <vector>
24 #include <SDL.h>
25 #include "type.h"
26 #include "scene.h"
27 #include "special.h"
28 #include "badguy.h"
29 #include "particlesystem.h"
30 #include "gameobjs.h"
31
32 class Level;
33
34 /** The World class holds a level and all the game objects (badguys,
35     bouncy distros, etc) that are needed to run a game. */
36 class World
37 {
38  public:
39   Level* level;
40
41   Player tux;
42   
43   std::vector<BouncyDistro> bouncy_distros;
44   std::vector<BrokenBrick>  broken_bricks;
45   std::vector<BouncyBrick>  bouncy_bricks;
46   std::vector<FloatingScore> floating_scores;
47
48   std::vector<BadGuy> bad_guys;
49   std::vector<Upgrade> upgrades;
50   std::vector<Bullet> bullets;
51   std::vector<ParticleSystem*> particle_systems;
52
53   int distro_counter;
54   bool counting_distros;
55
56   static World* current_;
57  public:
58   static World* current() { return current_; }
59   static void set_current(World* w) { current_ = w; }
60
61   World();
62   ~World();
63   
64   Level*  get_level() { return level; }
65   Player* get_tux() { return &tux; }
66
67   void set_defaults();
68
69   void draw();
70   void action(double frame_ratio);
71
72   /** Checks for all possible collisions. And calls the
73       collision_handlers, which the collision_objects provide for this
74       case (or not). */
75   void collision_handler();
76   
77   void arrays_free();
78
79   /** Load data for this level: 
80       Returns -1, if the loading of the level failed. */
81   int  load(const std::string& subset, int level);
82
83   /** Load data for this level: 
84       Returns -1, if the loading of the level failed. */
85   int  load(const std::string& filename);
86
87   void activate_particle_systems();
88   void activate_bad_guys();
89
90   void add_score(float x, float y, int s);
91   void add_bouncy_distro(float x, float y);
92   void add_broken_brick(Tile* tile, float x, float y);
93   void add_broken_brick_piece(Tile* tile, float x, float y, float xm, float ym);
94   void add_bouncy_brick(float x, float y);
95   void add_bad_guy(float x, float y, BadGuyKind kind);
96   void add_upgrade(float x, float y, int dir, int kind);
97   void add_bullet(float x, float y, float xm, int dir);
98
99   /** Try to grab the coin at the given coordinates */
100   void trygrabdistro(float x, float y, int bounciness);
101
102   /** Try to break the brick at the given coordinates */
103   void trybreakbrick(float x, float y, bool small);
104
105   /** Try to get the content out of a bonus box, thus emptying it */
106   void tryemptybox(float x, float y, int col_side);
107
108   /** Try to bumb a badguy that might we walking above Tux, thus shaking
109       the tile which the badguy is walking on an killing him this way */
110   void trybumpbadguy(float x, float y);
111 };
112
113 /** FIMXE: Workaround for the leveleditor mainly */
114 extern World global_world;
115
116 #endif /*SUPERTUX_WORLD_H*/
117
118 /* Local Variables: */
119 /* mode:c++ */
120 /* End: */
121