897873bcc20fc67e5fd6af8d729fc52299645034
[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 int global_frame_counter;
29 std::vector<bouncy_distro_type> bouncy_distros;
30 std::vector<broken_brick_type> broken_bricks;
31 std::vector<bouncy_brick_type> bouncy_bricks;
32 std::vector<BadGuy> bad_guys;
33 std::vector<floating_score_type> floating_scores;
34 std::vector<upgrade_type> upgrades;
35 std::vector<bullet_type> bullets;
36 Player tux;
37 texture_type img_box_full;
38 texture_type img_box_empty;
39 texture_type img_mints;
40 texture_type img_coffee;
41 texture_type img_super_bkgd;
42 texture_type img_red_glow;
43 timer_type time_left;
44 double frame_ratio;
45
46 void arrays_init(void)
47 {
48 }
49
50 void arrays_free(void)
51 {
52   bad_guys.clear();
53   bouncy_distros.clear();
54   broken_bricks.clear();
55   bouncy_bricks.clear();
56   floating_scores.clear();
57   upgrades.clear();
58   bullets.clear();
59 }
60
61 void set_defaults(void)
62 {
63   /* Set defaults: */
64   
65   scroll_x = 0;
66
67   score_multiplier = 1;
68   timer_init(&super_bkgd_timer, true);
69
70   counting_distros = false;
71   distro_counter = 0;
72
73   endpos = 0;
74
75   /* set current song/music */
76   set_current_music(LEVEL_MUSIC);
77 }
78
79 void add_score(float x, float y, int s)
80 {
81   score += s;
82
83   floating_score_type new_floating_score;
84   floating_score_init(&new_floating_score,x,y,s);
85   floating_scores.push_back(new_floating_score);
86 }
87
88 void add_bouncy_distro(float x, float y)
89 {
90
91   bouncy_distro_type new_bouncy_distro;
92   bouncy_distro_init(&new_bouncy_distro,x,y);
93   bouncy_distros.push_back(new_bouncy_distro);
94 }
95
96 void add_broken_brick(float x, float y)
97 {
98   add_broken_brick_piece(x, y, -1, -4);
99   add_broken_brick_piece(x, y + 16, -1.5, -3);
100
101   add_broken_brick_piece(x + 16, y, 1, -4);
102   add_broken_brick_piece(x + 16, y + 16, 1.5, -3);
103 }
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 void add_bouncy_brick(float x, float y)
113 {
114   bouncy_brick_type new_bouncy_brick;
115   bouncy_brick_init(&new_bouncy_brick,x,y);
116   bouncy_bricks.push_back(new_bouncy_brick);
117 }
118
119 void add_bad_guy(float x, float y, BadGuyKind kind)
120 {
121   BadGuy new_bad_guy;
122   new_bad_guy.init(x,y,kind);
123   bad_guys.push_back(new_bad_guy);
124 }
125
126 void add_upgrade(float x, float y, int dir, int kind)
127 {
128   upgrade_type new_upgrade;
129   upgrade_init(&new_upgrade,x,y,dir,kind);
130   upgrades.push_back(new_upgrade);
131 }
132
133 void add_bullet(float x, float y, float xm, int dir)
134 {
135   bullet_type new_bullet;
136   bullet_init(&new_bullet,x,y,xm,dir);
137   bullets.push_back(new_bullet);
138   
139   play_sound(sounds[SND_SHOOT], SOUND_CENTER_SPEAKER);
140 }
141
142 // EOF //
143