fix firetux not being able to pickup stuff
[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 #include "display_manager.h"
34
35 class Level;
36 class Background;
37
38 /** The World class holds a level and all the game objects (badguys,
39     bouncy distros, etc) that are needed to run a game. */
40 class World
41 {
42 private:
43   typedef std::list<BadGuy*> BadGuys;
44   BadGuys bad_guys_to_add;
45   typedef std::list<Trampoline*> Trampolines;
46   Trampolines trampolines;
47   Level* level;
48   Player* tux;
49
50   Timer scrolling_timer;
51
52   int distro_counter;
53   bool counting_distros;
54   int currentmusic;
55
56   static World* current_;
57 public:
58   Background* background;
59   BadGuys bad_guys;
60
61   std::vector<Upgrade*> upgrades;
62   std::vector<Bullet*> bullets;
63   std::vector<GameObject*> gameobjects;
64
65   DisplayManager displaymanager;
66
67 public:
68   static World* current() { return current_; }
69   static void set_current(World* w) { current_ = w; }
70
71   World(const std::string& filename);
72   World(const std::string& subset, int level_nr);
73   //World() {};
74   ~World();
75   
76   Level*  get_level() { return level; }
77   Player* get_tux() { return tux; }
78
79   void add_object(GameObject* object);
80
81   void set_defaults();
82
83   void draw();
84   void action(float elapsed_time);
85   void scrolling(float elapsed_time);   // camera scrolling
86
87   void play_music(int musictype);
88   int get_music_type();
89
90   /** Checks for all possible collisions. And calls the
91       collision_handlers, which the collision_objects provide for this
92       case (or not). */
93   void collision_handler();
94
95   void parse_objects(lisp_object_t* cur);
96   
97   void activate_particle_systems();
98
99   void add_score(const Vector& pos, int s);
100   void add_bouncy_distro(const Vector& pos);
101   void add_broken_brick(const Vector& pos, Tile* tile);
102   void add_broken_brick_piece(const Vector& pos,
103       const Vector& movement, Tile* tile);
104   void add_bouncy_brick(const Vector& pos);
105
106   BadGuy* add_bad_guy(float x, float y, BadGuyKind kind);
107
108   void add_upgrade(const Vector& pos, Direction dir, UpgradeKind kind);
109   void add_bullet(const Vector& pos, float xm, Direction dir);
110
111   /** Try to grab the coin at the given coordinates */
112   void trygrabdistro(float x, float y, int bounciness);
113
114   /** Try to break the brick at the given coordinates */
115   bool trybreakbrick(float x, float y, bool small);
116
117   /** Try to get the content out of a bonus box, thus emptying it */
118   void tryemptybox(float x, float y, Direction col_side);
119
120   /** Try to bumb a badguy that might we walking above Tux, thus shaking
121       the tile which the badguy is walking on an killing him this way */
122   void trybumpbadguy(float x, float y);
123
124   /** Apply bonuses active in the player status, used to reactivate
125       bonuses from former levels */
126   void apply_bonuses();
127 };
128
129 /** FIMXE: Workaround for the leveleditor mainly */
130 extern World global_world;
131
132 #endif /*SUPERTUX_WORLD_H*/
133
134 /* Local Variables: */
135 /* mode:c++ */
136 /* End: */
137