d9adbd8d92ed071874cd3c17110a09d9060908b2
[supertux.git] / src / scene.cpp
1 //
2 // C Implementation: scene
3 //
4 // Description: 
5 //
6 //
7 // Author: Tobias Glaesser <tobi.web@gmx.de>, (C) 2004
8 //
9 // Copyright: See COPYING file that comes with this distribution
10 //
11 //
12
13 #include <stdlib.h>
14 #include "scene.h"
15
16 int score;
17 int distros;
18 int level;
19 int next_level;
20 int game_pause;
21 bool quit;
22 int score_multiplier;
23 int endpos;
24 bool counting_distros;
25 int distro_counter;
26 timer_type  super_bkgd_timer;
27 float scroll_x;
28 unsigned int global_frame_counter;
29
30 std::vector<bouncy_distro_type> bouncy_distros;
31 std::vector<broken_brick_type> broken_bricks;
32 std::vector<bouncy_brick_type> bouncy_bricks;
33 std::vector<BadGuy> bad_guys;
34 std::vector<floating_score_type> floating_scores;
35 std::vector<upgrade_type> upgrades;
36 std::vector<bullet_type> bullets;
37 std::vector<ParticleSystem*> particle_systems;
38 Player tux;
39 texture_type img_box_full;
40 texture_type img_box_empty;
41 texture_type img_mints;
42 texture_type img_coffee;
43 texture_type img_super_bkgd;
44 texture_type img_red_glow;
45 timer_type time_left;
46 double frame_ratio;
47
48 void arrays_free(void)
49 {
50   bad_guys.clear();
51   bouncy_distros.clear();
52   broken_bricks.clear();
53   bouncy_bricks.clear();
54   floating_scores.clear();
55   upgrades.clear();
56   bullets.clear();
57   std::vector<ParticleSystem*>::iterator i;
58   for(i = particle_systems.begin(); i != particle_systems.end(); ++i) {
59     delete *i;
60   }
61   particle_systems.clear();
62 }
63
64 void set_defaults(void)
65 {
66   // Set defaults: 
67   scroll_x = 0;
68
69   score_multiplier = 1;
70   timer_init(&super_bkgd_timer, true);
71
72   counting_distros = false;
73   distro_counter = 0;
74
75   endpos = 0;
76
77   /* set current song/music */
78   set_current_music(LEVEL_MUSIC);
79 }
80
81 void add_score(float x, float y, int s)
82 {
83   score += s;
84
85   floating_score_type new_floating_score;
86   floating_score_init(&new_floating_score,x,y,s);
87   floating_scores.push_back(new_floating_score);
88 }
89
90 void add_bouncy_distro(float x, float y)
91 {
92
93   bouncy_distro_type new_bouncy_distro;
94   bouncy_distro_init(&new_bouncy_distro,x,y);
95   bouncy_distros.push_back(new_bouncy_distro);
96 }
97
98 void add_broken_brick(float x, float y)
99 {
100   add_broken_brick_piece(x, y, -1, -4);
101   add_broken_brick_piece(x, y + 16, -1.5, -3);
102
103   add_broken_brick_piece(x + 16, y, 1, -4);
104   add_broken_brick_piece(x + 16, y + 16, 1.5, -3);
105 }
106
107 void add_broken_brick_piece(float x, float y, float xm, float ym)
108 {
109   broken_brick_type new_broken_brick;
110   broken_brick_init(&new_broken_brick,x,y,xm,ym);
111   broken_bricks.push_back(new_broken_brick);
112 }
113
114 void add_bouncy_brick(float x, float y)
115 {
116   bouncy_brick_type new_bouncy_brick;
117   bouncy_brick_init(&new_bouncy_brick,x,y);
118   bouncy_bricks.push_back(new_bouncy_brick);
119 }
120
121 void add_bad_guy(float x, float y, BadGuyKind kind)
122 {
123   bad_guys.push_back(BadGuy());
124   BadGuy& new_bad_guy = bad_guys.back();
125   
126   new_bad_guy.init(x,y,kind);
127 }
128
129 void add_upgrade(float x, float y, int dir, int kind)
130 {
131   upgrade_type new_upgrade;
132   upgrade_init(&new_upgrade,x,y,dir,kind);
133   upgrades.push_back(new_upgrade);
134 }
135
136 void add_bullet(float x, float y, float xm, int dir)
137 {
138   bullet_type new_bullet;
139   bullet_init(&new_bullet,x,y,xm,dir);
140   bullets.push_back(new_bullet);
141   
142   play_sound(sounds[SND_SHOOT], SOUND_CENTER_SPEAKER);
143 }
144
145 // EOF //
146