0beb81db7e144c69539534db2013f19e8694f4e9
[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
23 /* Bounciness of distros: */
24
25 #define NO_BOUNCE 0
26 #define BOUNCE 1
27
28 struct bouncy_distro_type
29 {
30   base_type base;
31 };
32
33 extern texture_type img_distro[4];
34
35 void bouncy_distro_init(bouncy_distro_type* pbouncy_distro, float x, float y);
36 void bouncy_distro_action(bouncy_distro_type* pbouncy_distro);
37 void bouncy_distro_draw(bouncy_distro_type* pbouncy_distro);
38 void bouncy_distro_collision(bouncy_distro_type* pbouncy_distro, int c_object);
39
40 #define BOUNCY_BRICK_MAX_OFFSET 8
41 #define BOUNCY_BRICK_SPEED 0.9
42
43 struct broken_brick_type
44 {
45   base_type base;
46   timer_type timer;
47 };
48
49 void broken_brick_init(broken_brick_type* pbroken_brick, float x, float y, float xm, float ym);
50 void broken_brick_action(broken_brick_type* pbroken_brick);
51 void broken_brick_draw(broken_brick_type* pbroken_brick);
52
53 struct bouncy_brick_type
54 {
55   float offset;
56   float offset_m;
57   int shape;
58   base_type base;
59 };
60
61 void bouncy_brick_init(bouncy_brick_type* pbouncy_brick, float x, float y);
62 void bouncy_brick_action(bouncy_brick_type* pbouncy_brick);
63 void bouncy_brick_draw(bouncy_brick_type* pbouncy_brick);
64
65 struct floating_score_type
66 {
67   int value;
68   timer_type timer;
69   base_type base;
70 };
71
72 void floating_score_init(floating_score_type* pfloating_score, float x, float y, int s);
73 void floating_score_action(floating_score_type* pfloating_score);
74 void floating_score_draw(floating_score_type* pfloating_score);
75
76 /** Try to grab the coin at the given coordinates */
77 void trygrabdistro(float x, float y, int bounciness);
78
79 /** Try to break the brick at the given coordinates */
80 void trybreakbrick(float x, float y, bool small);
81
82 /** Try to get the content out of a bonus box, thus emptying it */
83 void tryemptybox(float x, float y, int col_side);
84
85 /** Try to bumb a badguy that might we walking above Tux, thus shaking
86     the tile which the badguy is walking on an killing him this way */
87 void trybumpbadguy(float x, float y);
88
89
90 /** The World class holds a level and all the game objects (badguys,
91     bouncy distros, etc) that are needed to run a game. */
92 class World
93 {
94  public:
95   Level* level;
96   std::vector<bouncy_distro_type> bouncy_distros;
97   std::vector<broken_brick_type> broken_bricks;
98   std::vector<bouncy_brick_type> bouncy_bricks;
99   std::vector<BadGuy> bad_guys;
100   std::vector<floating_score_type> floating_scores;
101   std::vector<upgrade_type> upgrades;
102   std::vector<bullet_type> bullets;
103   std::vector<ParticleSystem*> particle_systems;
104
105  public:
106   World();
107   void draw();
108   void action();
109   void arrays_free();
110
111   void add_score(float x, float y, int s);
112   void add_bouncy_distro(float x, float y);
113   void add_broken_brick(float x, float y);
114   void add_broken_brick_piece(float x, float y, float xm, float ym);
115   void add_bouncy_brick(float x, float y);
116   void add_bad_guy(float x, float y, BadGuyKind kind);
117   void add_upgrade(float x, float y, int dir, int kind);
118   void add_bullet(float x, float y, float xm, int dir);
119 };
120
121 extern World world;
122
123 #endif /*SUPERTUX_WORLD_H*/
124