- moved gameobjects into there own file
[supertux.git] / src / world.h
1 //
2 // Interface: world
3 //
4 // Description: 
5 //
6 //
7 // Author: Tobias Glaesser <tobi.web@gmx.de>, (C) 2003
8 //
9 // Copyright: See COPYING file that comes with this distribution
10 //
11 //
12
13 #ifndef SUPERTUX_WORLD_H
14 #define SUPERTUX_WORLD_H
15
16 #include <vector>
17 #include <SDL.h>
18 #include "type.h"
19 #include "scene.h"
20 #include "special.h"
21 #include "particlesystem.h"
22 #include "gameobjs.h"
23
24 /** Try to grab the coin at the given coordinates */
25 void trygrabdistro(float x, float y, int bounciness);
26
27 /** Try to break the brick at the given coordinates */
28 void trybreakbrick(float x, float y, bool small);
29
30 /** Try to get the content out of a bonus box, thus emptying it */
31 void tryemptybox(float x, float y, int col_side);
32
33 /** Try to bumb a badguy that might we walking above Tux, thus shaking
34     the tile which the badguy is walking on an killing him this way */
35 void trybumpbadguy(float x, float y);
36
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  public:
43   Level* level;
44   
45   std::vector<bouncy_distro_type> bouncy_distros;
46   std::vector<broken_brick_type>  broken_bricks;
47   std::vector<bouncy_brick_type>  bouncy_bricks;
48   std::vector<floating_score_type> floating_scores;
49
50   std::vector<BadGuy> bad_guys;
51   std::vector<upgrade_type> upgrades;
52   std::vector<bullet_type> bullets;
53   std::vector<ParticleSystem*> particle_systems;
54
55   static World* current_;
56  public:
57   static World* current() { return current_; }
58
59   World();
60   ~World();
61   
62   Level* get_level() { return level; }
63
64   void set_defaults();
65
66   void draw();
67   void action();
68   void arrays_free();
69
70   /** Load data for this level: 
71       Returns -1, if the loading of the level failed. */
72   int  load(const char* subset, int level);
73
74   /** Load data for this level: 
75       Returns -1, if the loading of the level failed. */
76   int  load(const std::string& filename);
77
78   void activate_particle_systems();
79   void activate_bad_guys();
80
81   void add_score(float x, float y, int s);
82   void add_bouncy_distro(float x, float y);
83   void add_broken_brick(Tile* tile, float x, float y);
84   void add_broken_brick_piece(Tile* tile, float x, float y, float xm, float ym);
85   void add_bouncy_brick(float x, float y);
86   void add_bad_guy(float x, float y, BadGuyKind kind);
87   void add_upgrade(float x, float y, int dir, int kind);
88   void add_bullet(float x, float y, float xm, int dir);
89 };
90
91 extern World world;
92
93 #endif /*SUPERTUX_WORLD_H*/
94