2 // C Implementation: special
7 // Author: Tobias Glaesser <tobi.web@gmx.de> & Bill Kendrick, (C) 2004
9 // Copyright: See COPYING file that comes with this distribution
23 void create_special_bitmasks()
25 bm_bullet = bitmask_create_SDL(img_bullet.sdl_surface);
28 void bullet_init(bullet_type* pbullet, float x, float y, float xm, int dir)
30 pbullet->base.width = 4;
31 pbullet->base.height = 4;
32 pbullet->base.alive = YES;
36 pbullet->base.x = x + 32;
37 pbullet->base.xm = BULLET_XM + xm;
42 pbullet->base.xm = -BULLET_XM + xm;
46 pbullet->base.ym = BULLET_STARTING_YM;
49 void bullet_action(bullet_type* pbullet)
51 if (pbullet->base.alive)
53 pbullet->base.x = pbullet->base.x + pbullet->base.xm * frame_ratio;
54 pbullet->base.y = pbullet->base.y + pbullet->base.ym * frame_ratio;
56 if (issolid(pbullet->base.x, pbullet->base.y))
58 if (issolid(pbullet->base.x, pbullet->base.y - pbullet->base.ym))
59 pbullet->base.alive = NO;
62 if (pbullet->base.ym >= 0)
64 pbullet->base.y = (int)(pbullet->base.y / 32) * 32 - 8;
66 pbullet->base.ym = -pbullet->base.ym;
70 pbullet->base.ym = pbullet->base.ym + GRAVITY;
72 if (pbullet->base.x < scroll_x ||
73 pbullet->base.x > scroll_x + screen->w)
75 pbullet->base.alive = NO;
81 void bullet_draw(bullet_type* pbullet)
83 if (pbullet->base.alive &&
84 pbullet->base.x >= scroll_x - pbullet->base.width &&
85 pbullet->base.x <= scroll_x + screen->w)
87 texture_draw(&img_bullet, pbullet->base.x - scroll_x, pbullet->base.y,
92 void bullet_collision(bullet_type* pbullet, int c_object)
95 if(c_object == CO_BADGUY)
96 pbullet->base.alive = NO;
100 void upgrade_init(upgrade_type *pupgrade, float x, float y, int kind)
102 pupgrade->base.width = 32;
103 pupgrade->base.height = 0;
104 pupgrade->base.alive = YES;
105 pupgrade->kind = kind;
106 pupgrade->base.x = x;
107 pupgrade->base.y = y;
108 pupgrade->base.xm = 2;
109 pupgrade->base.ym = -2;
110 pupgrade->base.height = 0;
113 void upgrade_action(upgrade_type *pupgrade)
116 if (pupgrade->base.alive)
118 if (pupgrade->base.height < 32)
122 pupgrade->base.height = pupgrade->base.height + 0.7 * frame_ratio;
123 if(pupgrade->base.height > 32)
124 pupgrade->base.height = 32;
130 if (pupgrade->kind == UPGRADE_MINTS ||
131 pupgrade->kind == UPGRADE_HERRING)
133 pupgrade->base.x = pupgrade->base.x + pupgrade->base.xm * frame_ratio;
134 pupgrade->base.y = pupgrade->base.y + pupgrade->base.ym * frame_ratio;
136 if (issolid(pupgrade->base.x, pupgrade->base.y + 31) ||
137 issolid(pupgrade->base.x + 31, pupgrade->base.y + 31))
139 if (pupgrade->base.ym > 0)
141 if (pupgrade->kind == UPGRADE_MINTS)
143 pupgrade->base.ym = 0;
145 else if (pupgrade->kind == UPGRADE_HERRING)
147 pupgrade->base.ym = -8;
150 pupgrade->base.y = (int)(pupgrade->base.y / 32) * 32;
154 pupgrade->base.ym = pupgrade->base.ym + GRAVITY;
156 if (issolid(pupgrade->base.x, pupgrade->base.y))
158 pupgrade->base.xm = -pupgrade->base.xm;
163 /* Off the screen? Kill it! */
165 if (pupgrade->base.x < scroll_x - pupgrade->base.width)
166 pupgrade->base.alive = NO;
172 void upgrade_draw(upgrade_type* pupgrade)
174 if (pupgrade->base.alive)
176 if (pupgrade->base.height < 32)
180 dest.x = pupgrade->base.x - scroll_x;
181 dest.y = pupgrade->base.y + 32 - pupgrade->base.height;
183 dest.h = pupgrade->base.height;
188 src.h = pupgrade->base.height;
190 if (pupgrade->kind == UPGRADE_MINTS)
191 SDL_BlitSurface(img_mints.sdl_surface, &src, screen, &dest);
192 else if (pupgrade->kind == UPGRADE_COFFEE)
193 SDL_BlitSurface(img_coffee.sdl_surface, &src, screen, &dest);
194 else if (pupgrade->kind == UPGRADE_HERRING)
195 SDL_BlitSurface(img_golden_herring.sdl_surface, &src, screen, &dest);
199 if (pupgrade->kind == UPGRADE_MINTS)
201 texture_draw(&img_mints,
202 pupgrade->base.x - scroll_x, pupgrade->base.y,
205 else if (pupgrade->kind == UPGRADE_COFFEE)
207 texture_draw(&img_coffee,
208 pupgrade->base.x - scroll_x, pupgrade->base.y,
211 else if (pupgrade->kind == UPGRADE_HERRING)
213 texture_draw(&img_golden_herring,
214 pupgrade->base.x - scroll_x, pupgrade->base.y,
221 void upgrade_collision(upgrade_type* pupgrade, void* p_c_object, int c_object)
223 player_type* pplayer = NULL;
228 /* Remove the upgrade: */
230 /* p_c_object is CO_PLAYER, so assign it to pplayer */
231 pplayer = p_c_object;
233 pupgrade->base.alive = NO;
235 /* Affect the player: */
237 if (pupgrade->kind == UPGRADE_MINTS)
239 play_sound(sounds[SND_EXCELLENT], SOUND_CENTER_SPEAKER);
241 timer_start(&super_bkgd_timer, 350);
243 else if (pupgrade->kind == UPGRADE_COFFEE)
245 play_sound(sounds[SND_COFFEE], SOUND_CENTER_SPEAKER);
246 pplayer->got_coffee = YES;
247 timer_start(&super_bkgd_timer, 250);
249 else if (pupgrade->kind == UPGRADE_HERRING)
251 play_sound(sounds[SND_HERRING], SOUND_CENTER_SPEAKER);
252 timer_start(&pplayer->invincible_timer,TUX_INVINCIBLE_TIME);
253 timer_start(&super_bkgd_timer, 250);
254 /* play the herring song ^^ */
255 if (current_music != HURRYUP_MUSIC)
257 current_music = HERRING_MUSIC;