commited Matzes Win32 patch
[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, distros, level, next_level, game_pause, quit, score_multiplier, endpos, counting_distros, distro_counter;
17 timer_type  super_bkgd_timer;
18 float scroll_x;
19 int frame;
20 std::vector<bouncy_distro_type> bouncy_distros;
21 std::vector<broken_brick_type> broken_bricks;
22 std::vector<bouncy_brick_type> bouncy_bricks;
23 std::vector<bad_guy_type> bad_guys;
24 std::vector<floating_score_type> floating_scores;
25 std::vector<upgrade_type> upgrades;
26 std::vector<bullet_type> bullets;
27 player_type tux;
28 texture_type img_box_full, img_box_empty, img_mints, img_coffee, img_super_bkgd, img_red_glow;
29 timer_type time_left;
30 double frame_ratio;
31
32 /* Initialize all 'dynamic' arrays */
33 void arrays_init(void)
34 {
35 }
36
37 /* Free memory of 'dynamic' arrays */
38 void arrays_free(void)
39 {
40 bad_guys.clear();
41 bouncy_distros.clear();
42 broken_bricks.clear();
43 bouncy_bricks.clear();
44 floating_scores.clear();
45 upgrades.clear();
46 bullets.clear();
47 }
48
49 void set_defaults(void)
50 {
51   /* Set defaults: */
52   
53   scroll_x = 0;
54
55   score_multiplier = 1;
56   timer_init(&super_bkgd_timer, YES);
57
58   counting_distros = NO;
59   distro_counter = 0;
60
61   endpos = 0;
62
63   /* set current song/music */
64   set_current_music(LEVEL_MUSIC);
65 }
66
67 /* Add score: */
68
69 void add_score(float x, float y, int s)
70 {
71  /* Add the score: */
72
73   score += s;
74
75   floating_score_type new_floating_score;
76   floating_score_init(&new_floating_score,x,y,s);
77   floating_scores.push_back(new_floating_score);
78 }
79
80 /* Add a bouncy distro: */
81
82 void add_bouncy_distro(float x, float y)
83 {
84
85   bouncy_distro_type new_bouncy_distro;
86   bouncy_distro_init(&new_bouncy_distro,x,y);
87   bouncy_distros.push_back(new_bouncy_distro);
88 }
89
90
91 /* Add broken brick pieces: */
92
93 void add_broken_brick(float x, float y)
94 {
95   add_broken_brick_piece(x, y, -1, -4);
96   add_broken_brick_piece(x, y + 16, -1.5, -3);
97
98   add_broken_brick_piece(x + 16, y, 1, -4);
99   add_broken_brick_piece(x + 16, y + 16, 1.5, -3);
100 }
101
102
103 /* Add a broken brick piece: */
104
105 void add_broken_brick_piece(float x, float y, float xm, float ym)
106 {
107   broken_brick_type new_broken_brick;
108   broken_brick_init(&new_broken_brick,x,y,xm,ym);
109   broken_bricks.push_back(new_broken_brick);
110 }
111
112
113 /* Add a bouncy brick piece: */
114
115 void add_bouncy_brick(float x, float y)
116 {
117   bouncy_brick_type new_bouncy_brick;
118   bouncy_brick_init(&new_bouncy_brick,x,y);
119   bouncy_bricks.push_back(new_bouncy_brick);
120 }
121
122
123 /* Add a bad guy: */
124
125 void add_bad_guy(float x, float y, int kind)
126 {
127   bad_guy_type new_bad_guy;
128   badguy_init(&new_bad_guy,x,y,kind);
129   bad_guys.push_back(new_bad_guy);
130 }
131
132 /* Add an upgrade: */
133
134 void add_upgrade(float x, float y, int dir, int kind)
135 {
136   upgrade_type new_upgrade;
137   upgrade_init(&new_upgrade,x,y,dir,kind);
138   upgrades.push_back(new_upgrade);
139 }
140
141 /* Add a bullet: */
142
143 void add_bullet(float x, float y, float xm, int dir)
144 {
145   bullet_type new_bullet;
146   bullet_init(&new_bullet,x,y,xm,dir);
147   bullets.push_back(new_bullet);
148   
149   play_sound(sounds[SND_SHOOT], SOUND_CENTER_SPEAKER);
150 }
151