2 // C Implementation: player/tux
7 // Author: Tobias Glaesser <tobi.web@gmx.de> & Bill Kendrick, (C) 2004
9 // Copyright: See COPYING file that comes with this distribution
20 void player_init(player_type* pplayer)
22 pplayer->base.width = 32;
23 pplayer->base.height = 32;
25 pplayer->size = SMALL;
26 pplayer->got_coffee = NO;
29 pplayer->base.y = 240;
36 pplayer->jumping = NO;
38 pplayer->frame_main = 0;
42 pplayer->input.down = UP;
43 pplayer->input.fire = UP;
44 pplayer->input.left = UP;
45 pplayer->input.old_fire = UP;
46 pplayer->input.right = UP;
47 pplayer->input.up = UP;
49 pplayer->keymap.jump = SDLK_UP;
50 pplayer->keymap.duck = SDLK_DOWN;
51 pplayer->keymap.left = SDLK_LEFT;
52 pplayer->keymap.right = SDLK_RIGHT;
53 pplayer->keymap.fire = SDLK_LCTRL;
55 timer_init(&pplayer->invincible_timer);
56 timer_init(&pplayer->skidding_timer);
57 timer_init(&pplayer->safe_timer);
60 int player_keydown_event(player_type* pplayer, SDLKey key)
62 if(key == pplayer->keymap.right)
64 pplayer->input.right = DOWN;
67 else if( key == pplayer->keymap.left)
69 pplayer->input.left = DOWN;
72 else if(key == pplayer->keymap.jump)
74 pplayer->input.up = DOWN;
77 else if(key == pplayer->keymap.duck)
79 pplayer->input.down = DOWN;
82 else if(key == pplayer->keymap.fire)
84 pplayer->input.fire = DOWN;
91 int player_keyup_event(player_type* pplayer, SDLKey key)
93 if(key == pplayer->keymap.right)
95 pplayer->input.right = UP;
98 else if( key == pplayer->keymap.left)
100 pplayer->input.left = UP;
103 else if(key == pplayer->keymap.jump)
105 pplayer->input.up = UP;
108 else if(key == pplayer->keymap.duck)
110 pplayer->input.down = UP;
113 else if(key == pplayer->keymap.fire)
115 pplayer->input.fire = UP;
122 void player_level_begin(player_type* pplayer)
125 pplayer->base.y = 240;
126 pplayer->base.xm = 0;
127 pplayer->base.ym = 0;
129 pplayer->input.down = UP;
130 pplayer->input.fire = UP;
131 pplayer->input.left = UP;
132 pplayer->input.old_fire = UP;
133 pplayer->input.right = UP;
134 pplayer->input.up = UP;
138 void player_action(player_type* pplayer)
140 /* --- HANDLE TUX! --- */
142 player_input(pplayer);
146 pplayer->base.x= pplayer->base.x+ pplayer->base.xm * frame_ratio;
147 pplayer->base.y = pplayer->base.y + pplayer->base.ym * frame_ratio;
149 player_keep_in_bounds(pplayer);
155 if (issolid(pplayer->base.x, pplayer->base.y + 31) &&
156 !issolid(pplayer->base.x- pplayer->base.xm, pplayer->base.y + 31))
158 while (issolid(pplayer->base.x, pplayer->base.y + 31))
160 if (pplayer->base.xm < 0)
162 else if (pplayer->base.xm > 0)
166 pplayer->base.xm = 0;
169 if (issolid(pplayer->base.x, pplayer->base.y) &&
170 !issolid(pplayer->base.x- pplayer->base.xm, pplayer->base.y))
172 while (issolid(pplayer->base.x, (pplayer->base.y)))
174 if (pplayer->base.xm < 0)
176 else if (pplayer->base.xm > 0)
180 pplayer->base.xm = 0;
183 if (issolid(pplayer->base.x, pplayer->base.y + 31))
185 /* Set down properly: */
188 while (issolid(pplayer->base.x, pplayer->base.y + 31))
192 DEBUG_MSG("FIXME - UNDER certain circumstances I'm hanging in a loop here!");
193 /*the circumstances are:
194 issolid() is true and base.ym == 0
195 use of floating point varibles for base stuff*/
196 if (pplayer->base.ym < 0)
198 else if (pplayer->base.ym > 0)
203 /* Reset score multiplier (for multi-hits): */
205 if (pplayer->base.ym > 0)
206 score_multiplier = 1;
211 pplayer->base.ym = 0;
212 pplayer->jumping = NO;
213 pplayer->input.up = UP;
217 /* Bump into things: */
219 if (issolid(pplayer->base.x, pplayer->base.y) ||
220 (pplayer->size == BIG && !pplayer->duck &&
221 (issolid(pplayer->base.x, pplayer->base.y - 32))))
223 if (!issolid(pplayer->base.x- pplayer->base.xm, pplayer->base.y) &&
224 (pplayer->size == SMALL || pplayer->duck ||
225 !issolid(pplayer->base.x- pplayer->base.xm, pplayer->base.y - 32)))
227 pplayer->base.x = pplayer->base.x- pplayer->base.xm;
228 pplayer->base.xm = 0;
230 else if (!issolid(pplayer->base.x, pplayer->base.y - pplayer->base.ym) &&
231 (pplayer->size == SMALL || pplayer->duck ||
232 !issolid(pplayer->base.x, pplayer->base.y - 32 - pplayer->base.ym)))
234 if (pplayer->base.ym <= 0)
238 if (pplayer->size == BIG)
240 /* Break bricks and empty boxes: */
244 if (isbrick(pplayer->base.x, pplayer->base.y - 32) ||
245 isfullbox(pplayer->base.x, pplayer->base.y - 32))
247 trygrabdistro(pplayer->base.x, pplayer->base.y - 64, BOUNCE);
248 trybumpbadguy(pplayer->base.x, pplayer->base.y - 96);
250 if (isfullbox(pplayer->base.x, pplayer->base.y - 32))
252 bumpbrick(pplayer->base.x, pplayer->base.y - 32);
255 trybreakbrick(pplayer->base.x, pplayer->base.y - 32);
256 tryemptybox(pplayer->base.x, pplayer->base.y - 32);
259 if (isbrick(pplayer->base.x+ 31, pplayer->base.y - 32) ||
260 isfullbox(pplayer->base.x+ 31, pplayer->base.y - 32))
262 trygrabdistro(pplayer->base.x+ 31,
263 pplayer->base.y - 64,
265 trybumpbadguy(pplayer->base.x+ 31,
266 pplayer->base.y - 96);
268 if (isfullbox(pplayer->base.x+ 31, pplayer->base.y - 32))
270 bumpbrick(pplayer->base.x+ 31, pplayer->base.y - 32);
273 trybreakbrick(pplayer->base.x+ 31,
274 pplayer->base.y - 32);
275 tryemptybox(pplayer->base.x+ 31,
276 pplayer->base.y - 32);
281 if (isbrick(pplayer->base.x, pplayer->base.y) ||
282 isfullbox(pplayer->base.x, pplayer->base.y))
284 trygrabdistro(pplayer->base.x, pplayer->base.y - 32,BOUNCE);
285 trybumpbadguy(pplayer->base.x, pplayer->base.y - 64);
286 if (isfullbox(pplayer->base.x, pplayer->base.y))
287 bumpbrick(pplayer->base.x, pplayer->base.y);
288 trybreakbrick(pplayer->base.x, pplayer->base.y);
289 tryemptybox(pplayer->base.x, pplayer->base.y);
292 if (isbrick(pplayer->base.x+ 31, pplayer->base.y) ||
293 isfullbox(pplayer->base.x+ 31, pplayer->base.y))
295 trygrabdistro(pplayer->base.x+ 31,
296 pplayer->base.y - 32,
298 trybumpbadguy(pplayer->base.x+ 31,
299 pplayer->base.y - 64);
300 if (isfullbox(pplayer->base.x+ 31, pplayer->base.y))
301 bumpbrick(pplayer->base.x+ 31, pplayer->base.y);
302 trybreakbrick(pplayer->base.x+ 31, pplayer->base.y);
303 tryemptybox(pplayer->base.x+ 31, pplayer->base.y);
309 /* It's a brick and we're small, make the brick
310 bounce, and grab any distros above it: */
312 if (isbrick(pplayer->base.x, pplayer->base.y) ||
313 isfullbox(pplayer->base.x, pplayer->base.y))
315 trygrabdistro(pplayer->base.x, pplayer->base.y - 32,BOUNCE);
316 trybumpbadguy(pplayer->base.x, pplayer->base.y - 64);
317 bumpbrick(pplayer->base.x, pplayer->base.y);
318 tryemptybox(pplayer->base.x, pplayer->base.y);
321 if (isbrick(pplayer->base.x+ 31, pplayer->base.y) ||
322 isfullbox(pplayer->base.x+ 31, pplayer->base.y))
324 trygrabdistro(pplayer->base.x+ 31, pplayer->base.y - 32,BOUNCE);
325 trybumpbadguy(pplayer->base.x+ 31, pplayer->base.y - 64);
326 bumpbrick(pplayer->base.x+ 31, pplayer->base.y);
327 tryemptybox(pplayer->base.x+ 31, pplayer->base.y);
331 /* Get a distro from a brick? */
333 if (shape(pplayer->base.x, pplayer->base.y) == 'x' ||
334 shape(pplayer->base.x, pplayer->base.y) == 'y')
336 add_bouncy_distro(((pplayer->base.x+ 1)
338 (int)(pplayer->base.y / 32) * 32);
340 if (counting_distros == NO)
342 counting_distros = YES;
343 distro_counter = 100;
346 if (distro_counter <= 0)
347 level_change(¤t_level,pplayer->base.x,pplayer->base.y, 'a');
349 play_sound(sounds[SND_DISTRO], SOUND_CENTER_SPEAKER);
350 score = score + SCORE_DISTRO;
353 else if (shape(pplayer->base.x+ 31, pplayer->base.y) == 'x' ||
354 shape(pplayer->base.x+ 31, pplayer->base.y) == 'y')
356 add_bouncy_distro(((pplayer->base.x+ 1 + 31)
358 (int)(pplayer->base.y / 32) * 32);
360 if (counting_distros == NO)
362 counting_distros = YES;
363 distro_counter = 100;
366 if (distro_counter <= 0)
367 level_change(¤t_level,pplayer->base.x+ 31, pplayer->base.y, 'a');
369 play_sound(sounds[SND_DISTRO], SOUND_CENTER_SPEAKER);
370 score = score + SCORE_DISTRO;
378 pplayer->base.y = (int)(pplayer->base.y / 32) * 32 + 30;
384 pplayer->base.y = (int)(pplayer->base.y / 32) * 32 - 32;
387 pplayer->base.ym = 0;
388 pplayer->jumping = NO;
389 /*pplayer->jump_counter = MAX_JUMP_COUNT;*/
390 /*timer_init(&pplayer->jump_timer);*/
391 timer_start(&pplayer->jump_timer,MAX_JUMP_TIME);
398 player_grabdistros(pplayer);
401 /* Slow down horizontally: */
405 if (pplayer->input.right == UP && pplayer->input.left == UP)
407 if (isice(pplayer->base.x, pplayer->base.y + 32) ||
408 !issolid(pplayer->base.x, pplayer->base.y + 32))
410 /* Slowly on ice or in air: */
412 if (pplayer->base.xm > 0)
414 else if (pplayer->base.xm < 0)
419 /* Quickly, otherwise: */
421 pplayer->base.xm = pplayer->base.xm / 2;
426 /* Drop vertically: */
428 if (!issolid(pplayer->base.x, pplayer->base.y + 32))
430 pplayer->base.ym = pplayer->base.ym + GRAVITY;
432 if (pplayer->base.ym > MAX_YM)
433 pplayer->base.ym = MAX_YM;
439 timer_check(&pplayer->safe_timer);
442 /* ---- DONE HANDLING TUX! --- */
444 /* Handle invincibility timer: */
447 if (current_music == HERRING_MUSIC && !timer_check(&pplayer->invincible_timer))
450 no, we are no more invincible
451 or we were not in invincible mode
452 but are we in hurry ?
456 if (timer_get_left(&time_left) < TIME_WARNING)
458 /* yes, we are in hurry
459 stop the herring_song, prepare to play the correct
462 current_music = HURRYUP_MUSIC;
466 current_music = LEVEL_MUSIC;
469 /* stop the old music if it's being played */
474 /* Handle skidding: */
476 timer_check(&pplayer->skidding_timer);
480 if (pplayer->base.x>= endpos && endpos != 0)
487 void player_handle_horizontal_input(player_type *pplayer, int dir)
489 if (pplayer->jumping == NO)
491 if ((dir ? (pplayer->base.xm < -SKID_XM) : (pplayer->base.xm > SKID_XM)) && !timer_started(&pplayer->skidding_timer) &&
492 pplayer->dir == !dir)
494 timer_start(&pplayer->skidding_timer, SKID_TIME);
496 play_sound(sounds[SND_SKID], SOUND_CENTER_SPEAKER);
502 if ((dir ? (pplayer->base.xm < 0) : (pplayer->base.xm > 0)) && !isice(pplayer->base.x, pplayer->base.y + 32) &&
503 !timer_started(&pplayer->skidding_timer))
505 pplayer->base.xm = 0;
510 if (pplayer->dir == dir)
512 /* Facing the direction we're jumping? Go full-speed: */
514 if (pplayer->input.fire == UP)
516 pplayer->base.xm = pplayer->base.xm + ( dir ? WALK_SPEED : -WALK_SPEED) * frame_ratio;
520 if (pplayer->base.xm > MAX_WALK_XM)
521 pplayer->base.xm = MAX_WALK_XM;
525 if (pplayer->base.xm < -MAX_WALK_XM)
526 pplayer->base.xm = -MAX_WALK_XM;
529 else if ( pplayer->input.fire == DOWN)
531 pplayer->base.xm = pplayer->base.xm + ( dir ? RUN_SPEED : -RUN_SPEED) * frame_ratio;
535 if (pplayer->base.xm > MAX_RUN_XM)
536 pplayer->base.xm = MAX_RUN_XM;
540 if (pplayer->base.xm < -MAX_RUN_XM)
541 pplayer->base.xm = -MAX_RUN_XM;
546 /* Not facing the direction we're jumping?
549 pplayer->base.xm = pplayer->base.xm + ( dir ? (WALK_SPEED / 2) : -(WALK_SPEED / 2)) * frame_ratio;
553 if (pplayer->base.xm > MAX_WALK_XM / 2)
554 pplayer->base.xm = MAX_WALK_XM / 2;
558 if (pplayer->base.xm < -MAX_WALK_XM / 2)
559 pplayer->base.xm = -MAX_WALK_XM / 2;
567 void player_handle_vertical_input(player_type *pplayer)
569 if(!timer_started(&pplayer->jump_timer))
571 timer_start(&pplayer->jump_timer,MAX_JUMP_TIME);
576 if (!issolid(pplayer->base.x, pplayer->base.y + 32) ||
577 pplayer->base.ym != 0)
579 /* If they're not on the ground, or are currently moving
580 vertically, don't jump! */
582 pplayer->jumping = NO;
583 timer_stop(&pplayer->jump_timer);
587 /* Make sure we're not standing back up into a solid! */
589 if (pplayer->size == SMALL || pplayer->duck == NO ||
590 !issolid(pplayer->base.x, pplayer->base.y))
592 pplayer->jumping = YES;
594 if (pplayer->size == SMALL)
595 play_sound(sounds[SND_JUMP], SOUND_CENTER_SPEAKER);
597 play_sound(sounds[SND_BIGJUMP], SOUND_CENTER_SPEAKER);
602 /* Keep jumping for a while: */
604 if (timer_check(&pplayer->jump_timer))
606 pplayer->base.ym = pplayer->base.ym - JUMP_SPEED * frame_ratio;
607 if (pplayer->base.ym < -YM_FOR_JUMP)
608 pplayer->base.ym = -YM_FOR_JUMP;
612 void player_input(player_type *pplayer)
614 /* Handle key and joystick state: */
617 if (pplayer->input.right == DOWN && pplayer->input.left == UP)
619 player_handle_horizontal_input(pplayer,RIGHT);
621 else if (pplayer->input.left == DOWN && pplayer->input.right == UP)
623 player_handle_horizontal_input(pplayer,LEFT);
628 if ( pplayer->input.up == DOWN)
630 player_handle_vertical_input(pplayer);
633 timer_stop(&pplayer->jump_timer);
637 if (pplayer->input.fire == DOWN && pplayer->input.old_fire == UP && pplayer->got_coffee)
639 add_bullet(pplayer->base.x, pplayer->base.y, pplayer->base.xm, pplayer->dir);
645 if (pplayer->input.down == DOWN)
647 if (pplayer->size == BIG)
652 if (pplayer->size == BIG && pplayer->duck == YES)
654 /* Make sure we're not standing back up into a solid! */
656 if (!issolid(pplayer->base.x, pplayer->base.y - 32))
665 if (pplayer->input.right == UP && pplayer->input.left == UP)
667 pplayer->frame_main = 1;
672 if ((pplayer->input.fire == DOWN && (frame % 2) == 0) ||
674 pplayer->frame_main = (pplayer->frame_main + 1) % 4;
676 pplayer->frame = pplayer->frame_main;
678 if (pplayer->frame == 3)
684 void player_grabdistros(player_type *pplayer)
689 trygrabdistro(pplayer->base.x, pplayer->base.y, NO_BOUNCE);
690 trygrabdistro(pplayer->base.x+ 31, pplayer->base.y, NO_BOUNCE);
692 if (pplayer->size == BIG && !pplayer->duck)
694 trygrabdistro(pplayer->base.x, pplayer->base.y - 32, NO_BOUNCE);
695 trygrabdistro(pplayer->base.x+ 31, pplayer->base.y - 32, NO_BOUNCE);
700 /* Enough distros for a One-up? */
702 if (distros >= DISTROS_LIFEUP)
704 distros = distros - DISTROS_LIFEUP;
705 if(pplayer->lives < MAX_LIVES)
707 /*We want to hear the sound even, if MAX_LIVES is reached*/
708 play_sound(sounds[SND_LIFEUP], SOUND_CENTER_SPEAKER);
712 void player_draw(player_type* pplayer)
714 if (!timer_started(&pplayer->safe_timer) || (frame % 2) == 0)
716 if (pplayer->size == SMALL)
718 if (timer_started(&pplayer->invincible_timer))
722 if (pplayer->dir == RIGHT)
724 texture_draw(&cape_right[frame % 2],
725 pplayer->base.x- scroll_x, pplayer->base.y,
730 texture_draw(&cape_left[frame % 2],
731 pplayer->base.x- scroll_x, pplayer->base.y,
737 if (!pplayer->got_coffee)
739 if (pplayer->dir == RIGHT)
741 texture_draw(&tux_right[pplayer->frame], pplayer->base.x- scroll_x, pplayer->base.y, NO_UPDATE);
745 texture_draw(&tux_left[pplayer->frame], pplayer->base.x- scroll_x, pplayer->base.y, NO_UPDATE);
750 /* Tux got coffee! */
752 if (pplayer->dir == RIGHT)
754 texture_draw(&firetux_right[pplayer->frame], pplayer->base.x- scroll_x, pplayer->base.y, NO_UPDATE);
758 texture_draw(&firetux_left[pplayer->frame], pplayer->base.x- scroll_x, pplayer->base.y, NO_UPDATE);
764 if (timer_started(&pplayer->invincible_timer))
768 if (pplayer->dir == RIGHT)
770 texture_draw(&bigcape_right[frame % 2],
771 pplayer->base.x- scroll_x - 8 - 16, pplayer->base.y - 32,
776 texture_draw(&bigcape_left[frame % 2],
777 pplayer->base.x-scroll_x - 8, pplayer->base.y - 32,
782 if (!pplayer->got_coffee)
786 if (!timer_started(&pplayer->skidding_timer))
788 if (!pplayer->jumping || pplayer->base.ym > 0)
790 if (pplayer->dir == RIGHT)
792 texture_draw(&bigtux_right[pplayer->frame],
793 pplayer->base.x- scroll_x - 8, pplayer->base.y - 32,
798 texture_draw(&bigtux_left[pplayer->frame],
799 pplayer->base.x- scroll_x - 8, pplayer->base.y - 32,
805 if (pplayer->dir == RIGHT)
807 texture_draw(&bigtux_right_jump,
808 pplayer->base.x- scroll_x - 8, pplayer->base.y - 32,
813 texture_draw(&bigtux_left_jump,
814 pplayer->base.x- scroll_x - 8, pplayer->base.y - 32,
821 if (pplayer->dir == RIGHT)
823 texture_draw(&skidtux_right,
824 pplayer->base.x- scroll_x - 8, pplayer->base.y - 32,
829 texture_draw(&skidtux_left,
830 pplayer->base.x- scroll_x - 8, pplayer->base.y - 32,
837 if (pplayer->dir == RIGHT)
839 texture_draw(&ducktux_right, pplayer->base.x- scroll_x - 8, pplayer->base.y - 16,
844 texture_draw(&ducktux_left, pplayer->base.x- scroll_x - 8, pplayer->base.y - 16,
851 /* Tux has coffee! */
855 if (!timer_started(&pplayer->skidding_timer))
857 if (!pplayer->jumping || pplayer->base.ym > 0)
859 if (pplayer->dir == RIGHT)
861 texture_draw(&bigfiretux_right[pplayer->frame],
862 pplayer->base.x- scroll_x - 8, pplayer->base.y - 32,
867 texture_draw(&bigfiretux_left[pplayer->frame],
868 pplayer->base.x- scroll_x - 8, pplayer->base.y - 32,
874 if (pplayer->dir == RIGHT)
876 texture_draw(&bigfiretux_right_jump,
877 pplayer->base.x- scroll_x - 8, pplayer->base.y - 32,
882 texture_draw(&bigfiretux_left_jump,
883 pplayer->base.x- scroll_x - 8, pplayer->base.y - 32,
890 if (pplayer->dir == RIGHT)
892 texture_draw(&skidfiretux_right,
893 pplayer->base.x- scroll_x - 8, pplayer->base.y - 32,
898 texture_draw(&skidfiretux_left,
899 pplayer->base.x- scroll_x - 8, pplayer->base.y - 32,
906 if (pplayer->dir == RIGHT)
908 texture_draw(&duckfiretux_right, pplayer->base.x- scroll_x - 8, pplayer->base.y - 16,
913 texture_draw(&duckfiretux_left, pplayer->base.x- scroll_x - 8, pplayer->base.y - 16,
922 void player_collision(player_type* pplayer, void* p_c_object, int c_object)
924 bad_guy_type* pbad_c = NULL;
930 /* Hurt the player if he just touched it: */
932 if (!pbad_c->dying && !pplayer->dying &&
933 !timer_started(&pplayer->safe_timer) &&
934 pbad_c->mode != HELD)
936 if (pbad_c->mode == FLAT && pplayer->input.fire != DOWN)
941 play_sound(sounds[SND_KICK], SOUND_CENTER_SPEAKER);
943 if (pplayer->base.x<= pbad_c->base.x)
946 pbad_c->base.x = pbad_c->base.x + 16;
951 pbad_c->base.x = pbad_c->base.x - 16;
954 timer_start(&pbad_c->timer,5000);
956 else if (pbad_c->mode == FLAT && pplayer->input.fire == DOWN)
961 else if (pbad_c->mode == KICK)
963 if (pplayer->base.y < pbad_c->base.y - 16 &&
964 timer_started(&pbad_c->timer))
966 /* Step on (stop being kicked) */
969 play_sound(sounds[SND_STOMP], SOUND_CENTER_SPEAKER);
970 timer_start(&pbad_c->timer, 10000);
974 /* Hurt if you get hit by kicked laptop: */
976 if (timer_started(&pbad_c->timer))
978 if (!timer_started(&pplayer->invincible_timer))
980 player_kill(pplayer,SHRINK);
984 pbad_c->dying = FALLING;
985 pbad_c->base.ym = -8;
986 play_sound(sounds[SND_FALL], SOUND_CENTER_SPEAKER);
993 if (!timer_started(&pplayer->invincible_timer ))
995 player_kill(pplayer,SHRINK);
999 pbad_c->dying = FALLING;
1000 pbad_c->base.ym = -8;
1001 play_sound(sounds[SND_FALL], SOUND_CENTER_SPEAKER);
1013 void player_kill(player_type* pplayer, int mode)
1015 pplayer->base.ym = -5;
1017 play_sound(sounds[SND_HURT], SOUND_CENTER_SPEAKER);
1019 if (pplayer->dir == RIGHT)
1020 pplayer->base.xm = -8;
1021 else if (pplayer->dir == LEFT)
1022 pplayer->base.xm = 8;
1024 if (mode == SHRINK && pplayer->size == BIG)
1026 if (pplayer->got_coffee)
1027 pplayer->got_coffee = NO;
1029 pplayer->size = SMALL;
1031 timer_start(&pplayer->safe_timer,TUX_SAFE_TIME);
1039 void player_dying(player_type *pplayer)
1041 pplayer->base.ym = pplayer->base.ym + GRAVITY;
1046 player_remove_powerups(pplayer);
1047 pplayer->dying = NO;
1049 player_level_begin(pplayer);
1053 /* Remove Tux's power ups */
1054 void player_remove_powerups(player_type* pplayer)
1056 pplayer->got_coffee = NO;
1057 pplayer->size = SMALL;
1060 void player_keep_in_bounds(player_type* pplayer)
1062 /* Keep tux in bounds: */
1063 if (pplayer->base.x< 0)
1065 else if(pplayer->base.x< scroll_x)
1066 pplayer->base.x= scroll_x;
1067 else if (pplayer->base.x< 160 + scroll_x && scroll_x > 0 && debug_mode == YES)
1069 scroll_x = pplayer->base.x- 160;
1070 /*pplayer->base.x+= 160;*/
1076 else if (pplayer->base.x> screen->w / 2 + scroll_x && scroll_x < ((current_level.width * 32) - screen->w))
1078 /* Scroll the screen in past center: */
1080 scroll_x = pplayer->base.x- screen->w / 2;
1081 /*pplayer->base.x= 320 + scroll_x;*/
1083 if (scroll_x > ((current_level.width * 32) - screen->w))
1084 scroll_x = ((current_level.width * 32) - screen->w);
1086 else if (pplayer->base.x> 608 + scroll_x)
1088 /* ... unless there's no more to scroll! */
1090 /*pplayer->base.x= 608 + scroll_x;*/
1093 /* Keep in-bounds, vertically: */
1095 if (pplayer->base.y < 0)
1096 pplayer->base.y = 0;
1097 else if (pplayer->base.y > screen->h)
1099 player_kill(&tux,KILL);