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