2 // C Implementation: scene
7 // Author: Tobias Glaesser <tobi.web@gmx.de>, (C) 2004
9 // Copyright: See COPYING file that comes with this distribution
16 int score, distros, level, next_level, game_pause, quit, score_multiplier, endpos, counting_distros, distro_counter;
17 timer_type super_bkgd_timer;
20 bouncy_distro_type *bouncy_distros;
21 broken_brick_type *broken_bricks;
22 bouncy_brick_type *bouncy_bricks;
23 bad_guy_type *bad_guys;
24 floating_score_type *floating_scores;
25 upgrade_type *upgrades;
28 int num_bouncy_distros;
29 int num_broken_bricks;
30 int num_bouncy_bricks;
31 int num_floating_scores;
35 texture_type img_box_full, img_box_empty, img_mints, img_coffee, img_super_bkgd, img_red_glow;
39 /* Initialize all 'dynamic' arrays */
40 void arrays_init(void)
43 num_bouncy_distros = 0;
44 num_broken_bricks = 0;
45 num_bouncy_bricks = 0;
46 num_floating_scores = 0;
50 bouncy_distros = NULL;
53 floating_scores = NULL;
58 /* Free memory of 'dynamic' arrays */
59 void arrays_free(void)
65 free(floating_scores);
70 void set_defaults(void)
77 timer_init(&super_bkgd_timer, YES);
79 counting_distros = NO;
84 /* set current song/music */
85 current_music = LEVEL_MUSIC;
90 void add_score(float x, float y, int s)
100 /* Add a floating score thing to the game: */
104 for (i = 0; i < num_floating_scores && found == -1; i++)
106 if (!floating_scores[i].base.alive)
112 ++num_floating_scores;
113 floating_scores = (floating_score_type*) realloc(floating_scores,num_floating_scores*sizeof(floating_score_type));
114 floating_score_init(&floating_scores[num_floating_scores-1],x,y,s);
120 floating_score_init(&floating_scores[found],x,y,s);
124 /* Add a bouncy distro: */
126 void add_bouncy_distro(float x, float y)
130 printf("X _--- %f Y-- isdojf %f\n",x,y);
136 for (i = 0; i < num_bouncy_distros && found == -1; i++)
138 if (!bouncy_distros[i].base.alive)
144 ++num_bouncy_distros;
145 bouncy_distros = (bouncy_distro_type*) realloc(bouncy_distros,num_bouncy_distros*sizeof(bouncy_distro_type));
146 found = num_bouncy_distros - 1;
151 bouncy_distro_init(&bouncy_distros[found],x,y);
156 /* Add broken brick pieces: */
158 void add_broken_brick(float x, float y)
160 add_broken_brick_piece(x, y, -1, -4);
161 add_broken_brick_piece(x, y + 16, -1.5, -3);
163 add_broken_brick_piece(x + 16, y, 1, -4);
164 add_broken_brick_piece(x + 16, y + 16, 1.5, -3);
168 /* Add a broken brick piece: */
170 void add_broken_brick_piece(float x, float y, float xm, float ym)
176 for (i = 0; i < num_broken_bricks && found == -1; i++)
178 if (!broken_bricks[i].base.alive)
185 broken_bricks = (broken_brick_type*) realloc(broken_bricks,num_broken_bricks*sizeof(broken_brick_type));
186 found = num_broken_bricks - 1;
191 broken_brick_init(&broken_bricks[found], x, y, xm, ym);
196 /* Add a bouncy brick piece: */
198 void add_bouncy_brick(float x, float y)
204 for (i = 0; i < num_bouncy_bricks && found == -1; i++)
206 if (!bouncy_bricks[i].base.alive)
213 bouncy_bricks = (bouncy_brick_type*) realloc(bouncy_bricks,num_bouncy_bricks*sizeof(bouncy_brick_type));
214 found = num_bouncy_bricks - 1;
219 bouncy_brick_init(&bouncy_bricks[found],x,y);
226 void add_bad_guy(float x, float y, int kind)
232 for (i = 0; i < num_bad_guys && found == -1; i++)
234 if (!bad_guys[i].base.alive)
241 bad_guys = (bad_guy_type*) realloc(bad_guys,num_bad_guys*sizeof(bad_guy_type));
242 found = num_bad_guys - 1;
247 badguy_init(&bad_guys[found], x, y, kind);
251 /* Add an upgrade: */
253 void add_upgrade(float x, float y, int kind)
259 for (i = 0; i < num_upgrades && found == -1; i++)
261 if (!upgrades[i].base.alive)
268 upgrades = (upgrade_type*) realloc(upgrades,num_upgrades*sizeof(upgrade_type));
269 found = num_upgrades - 1;
274 upgrade_init(&upgrades[found], x, y, kind);
280 void add_bullet(float x, float y, float xm, int dir)
286 for (i = 0; i < num_bullets && found == -1; i++)
288 if (!bullets[i].base.alive)
295 bullets = (bullet_type*) realloc(bullets,num_bullets*sizeof(bullet_type));
296 found = num_bullets - 1;
301 bullet_init(&bullets[found], x, y, xm, dir);
303 play_sound(sounds[SND_SHOOT], SOUND_CENTER_SPEAKER);