2 // C Implementation: special
7 // Author: Tobias Glaesser <tobi.web@gmx.de>, (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)
30 pbullet->base.width = 4;
31 pbullet->base.height = 4;
32 pbullet->base.updated = SDL_GetTicks();
33 pbullet->base.alive = NO;
36 void bullet_action(bullet_type* pbullet)
39 double frame_ratio = get_frame_ratio(&pbullet->base);
41 if (pbullet->base.alive)
43 pbullet->base.x = pbullet->base.x + pbullet->base.xm * frame_ratio;
44 pbullet->base.y = pbullet->base.y + pbullet->base.ym * frame_ratio;
46 if (issolid(pbullet->base.x, pbullet->base.y))
48 if (issolid(pbullet->base.x, pbullet->base.y - pbullet->base.ym))
49 pbullet->base.alive = NO;
52 if (pbullet->base.ym >= 0)
54 pbullet->base.y = (int)(pbullet->base.y / 32) * 32 - 8;
56 pbullet->base.ym = -pbullet->base.ym;
60 pbullet->base.ym = pbullet->base.ym + GRAVITY;
62 if (pbullet->base.x < scroll_x ||
63 pbullet->base.x > scroll_x + screen->w)
65 pbullet->base.alive = NO;
71 void bullet_draw(bullet_type* pbullet)
73 if (pbullet->base.alive &&
74 pbullet->base.x >= scroll_x - pbullet->base.width &&
75 pbullet->base.x <= scroll_x + screen->w)
77 texture_draw(&img_bullet, pbullet->base.x - scroll_x, pbullet->base.y,
82 void bullet_collision(bullet_type* pbullet, int c_object)
85 if(c_object == CO_BADGUY)
86 pbullet->base.alive = NO;
90 void upgrade_init(upgrade_type *pupgrade)
92 pupgrade->base.width = 32;
93 pupgrade->base.height = 0;
94 pupgrade->base.updated = SDL_GetTicks();
95 pupgrade->base.alive = NO;
98 void upgrade_action(upgrade_type *pupgrade)
100 double frame_ratio = get_frame_ratio(&pupgrade->base);
102 if (pupgrade->base.alive)
104 if (pupgrade->base.height < 32)
108 pupgrade->base.height++;
114 if (pupgrade->kind == UPGRADE_MINTS ||
115 pupgrade->kind == UPGRADE_HERRING)
117 pupgrade->base.x = pupgrade->base.x + pupgrade->base.xm * frame_ratio;
118 pupgrade->base.y = pupgrade->base.y + pupgrade->base.ym * frame_ratio;
120 if (issolid(pupgrade->base.x, pupgrade->base.y + 31) ||
121 issolid(pupgrade->base.x + 31, pupgrade->base.y + 31))
123 if (pupgrade->base.ym > 0)
125 if (pupgrade->kind == UPGRADE_MINTS)
127 pupgrade->base.ym = 0;
129 else if (pupgrade->kind == UPGRADE_HERRING)
131 pupgrade->base.ym = -24;
134 pupgrade->base.y = (int)(pupgrade->base.y / 32) * 32;
138 pupgrade->base.ym = pupgrade->base.ym + GRAVITY;
140 if (issolid(pupgrade->base.x, pupgrade->base.y))
142 pupgrade->base.xm = -pupgrade->base.xm;
147 /* Off the screen? Kill it! */
149 if (pupgrade->base.x < scroll_x)
150 pupgrade->base.alive = NO;
156 void upgrade_draw(upgrade_type* pupgrade)
158 if (pupgrade->base.alive)
160 if (pupgrade->base.height < 32)
164 dest.x = pupgrade->base.x - scroll_x;
165 dest.y = pupgrade->base.y + 32 - pupgrade->base.height;
167 dest.h = pupgrade->base.height;
172 src.h = pupgrade->base.height;
174 if (pupgrade->kind == UPGRADE_MINTS)
175 SDL_BlitSurface(img_mints.sdl_surface, &src, screen, &dest);
176 else if (pupgrade->kind == UPGRADE_COFFEE)
177 SDL_BlitSurface(img_coffee.sdl_surface, &src, screen, &dest);
178 else if (pupgrade->kind == UPGRADE_HERRING)
179 SDL_BlitSurface(img_golden_herring.sdl_surface, &src, screen, &dest);
183 if (pupgrade->kind == UPGRADE_MINTS)
185 texture_draw(&img_mints,
186 pupgrade->base.x - scroll_x, pupgrade->base.y,
189 else if (pupgrade->kind == UPGRADE_COFFEE)
191 texture_draw(&img_coffee,
192 pupgrade->base.x - scroll_x, pupgrade->base.y,
195 else if (pupgrade->kind == UPGRADE_HERRING)
197 texture_draw(&img_golden_herring,
198 pupgrade->base.x - scroll_x, pupgrade->base.y,
205 void upgrade_collision(upgrade_type* pupgrade, void* p_c_object, int c_object)
207 player_type* pplayer = NULL;
212 /* Remove the upgrade: */
214 /* p_c_object is CO_PLAYER, so assign it to pplayer */
215 pplayer = p_c_object;
217 pupgrade->base.alive = NO;
219 /* Affect the player: */
221 if (pupgrade->kind == UPGRADE_MINTS)
223 play_sound(sounds[SND_EXCELLENT], SOUND_CENTER_SPEAKER);
227 else if (pupgrade->kind == UPGRADE_COFFEE)
229 play_sound(sounds[SND_COFFEE], SOUND_CENTER_SPEAKER);
230 pplayer->got_coffee = YES;
233 else if (pupgrade->kind == UPGRADE_HERRING)
235 play_sound(sounds[SND_HERRING], SOUND_CENTER_SPEAKER);
236 timer_start(&tux.invincible_timer,TUX_INVINCIBLE_TIME);
238 /* play the herring song ^^ */
239 if (current_music != HURRYUP_MUSIC)
241 current_music = HERRING_MUSIC;