- added object support (untested)
[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_init(void)
49 {
50 }
51
52 void arrays_free(void)
53 {
54 bad_guys.clear();
55 bouncy_distros.clear();
56 broken_bricks.clear();
57 bouncy_bricks.clear();
58 floating_scores.clear();
59 upgrades.clear();
60 bullets.clear();
61 std::vector<ParticleSystem*>::iterator i;
62 for(i = particle_systems.begin(); i != particle_systems.end(); ++i) {
63   delete *i;
64 }
65 particle_systems.clear();
66 }
67
68 void set_defaults(void)
69 {
70   /* Set defaults: */
71   
72   scroll_x = 0;
73
74   score_multiplier = 1;
75   timer_init(&super_bkgd_timer, true);
76
77   counting_distros = false;
78   distro_counter = 0;
79
80   endpos = 0;
81
82   /* set current song/music */
83   set_current_music(LEVEL_MUSIC);
84 }
85
86 void add_score(float x, float y, int s)
87 {
88   score += s;
89
90   floating_score_type new_floating_score;
91   floating_score_init(&new_floating_score,x,y,s);
92   floating_scores.push_back(new_floating_score);
93 }
94
95 void add_bouncy_distro(float x, float y)
96 {
97
98   bouncy_distro_type new_bouncy_distro;
99   bouncy_distro_init(&new_bouncy_distro,x,y);
100   bouncy_distros.push_back(new_bouncy_distro);
101 }
102
103 void add_broken_brick(float x, float y)
104 {
105   add_broken_brick_piece(x, y, -1, -4);
106   add_broken_brick_piece(x, y + 16, -1.5, -3);
107
108   add_broken_brick_piece(x + 16, y, 1, -4);
109   add_broken_brick_piece(x + 16, y + 16, 1.5, -3);
110 }
111
112 void add_broken_brick_piece(float x, float y, float xm, float ym)
113 {
114   broken_brick_type new_broken_brick;
115   broken_brick_init(&new_broken_brick,x,y,xm,ym);
116   broken_bricks.push_back(new_broken_brick);
117 }
118
119 void add_bouncy_brick(float x, float y)
120 {
121   bouncy_brick_type new_bouncy_brick;
122   bouncy_brick_init(&new_bouncy_brick,x,y);
123   bouncy_bricks.push_back(new_bouncy_brick);
124 }
125
126 void add_bad_guy(float x, float y, BadGuyKind kind)
127 {
128   BadGuy new_bad_guy;
129   new_bad_guy.init(x,y,kind);
130   bad_guys.push_back(new_bad_guy);
131 }
132
133 void add_upgrade(float x, float y, int dir, int kind)
134 {
135   upgrade_type new_upgrade;
136   upgrade_init(&new_upgrade,x,y,dir,kind);
137   upgrades.push_back(new_upgrade);
138 }
139
140 void add_bullet(float x, float y, float xm, int dir)
141 {
142   bullet_type new_bullet;
143   bullet_init(&new_bullet,x,y,xm,dir);
144   bullets.push_back(new_bullet);
145   
146   play_sound(sounds[SND_SHOOT], SOUND_CENTER_SPEAKER);
147 }
148
149 // EOF //
150