2 // C Implementation: player/tux
7 // Author: Tobias Glaesser <tobi.web@gmx.de>, (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->base.updated = SDL_GetTicks();
26 pplayer->size = SMALL;
27 pplayer->got_coffee = NO;
30 pplayer->base.y = 240;
37 pplayer->jumping = NO;
39 pplayer->frame_main = 0;
43 pplayer->input.down = UP;
44 pplayer->input.fire = UP;
45 pplayer->input.left = UP;
46 pplayer->input.old_fire = UP;
47 pplayer->input.right = UP;
48 pplayer->input.up = UP;
50 pplayer->keymap.jump = SDLK_UP;
51 pplayer->keymap.duck = SDLK_DOWN;
52 pplayer->keymap.left = SDLK_LEFT;
53 pplayer->keymap.right = SDLK_RIGHT;
54 pplayer->keymap.fire = SDLK_LCTRL;
56 timer_init(&pplayer->invincible_timer);
57 timer_init(&pplayer->skidding_timer);
58 timer_init(&pplayer->safe_timer);
61 int player_keydown_event(player_type* pplayer, SDLKey key)
63 if(key == pplayer->keymap.right)
65 pplayer->input.right = DOWN;
68 else if( key == pplayer->keymap.left)
70 pplayer->input.left = DOWN;
73 else if(key == pplayer->keymap.jump)
75 pplayer->input.up = DOWN;
78 else if(key == pplayer->keymap.duck)
80 pplayer->input.down = DOWN;
83 else if(key == pplayer->keymap.fire)
85 pplayer->input.fire = DOWN;
92 int player_keyup_event(player_type* pplayer, SDLKey key)
94 if(key == pplayer->keymap.right)
96 pplayer->input.right = UP;
99 else if( key == pplayer->keymap.left)
101 pplayer->input.left = UP;
104 else if(key == pplayer->keymap.jump)
106 pplayer->input.up = UP;
109 else if(key == pplayer->keymap.duck)
111 pplayer->input.down = UP;
114 else if(key == pplayer->keymap.fire)
116 pplayer->input.fire = UP;
123 void player_level_begin(player_type* pplayer)
126 pplayer->base.y = 240;
127 pplayer->base.xm = 0;
128 pplayer->base.ym = 0;
130 pplayer->input.down = UP;
131 pplayer->input.fire = UP;
132 pplayer->input.left = UP;
133 pplayer->input.old_fire = UP;
134 pplayer->input.right = UP;
135 pplayer->input.up = UP;
139 void player_action(player_type* pplayer)
142 double frame_ratio = get_frame_ratio(&pplayer->base);
144 /* --- HANDLE TUX! --- */
146 player_input(pplayer);
150 pplayer->base.x= pplayer->base.x+ pplayer->base.xm * frame_ratio;
151 pplayer->base.y = pplayer->base.y + pplayer->base.ym * frame_ratio;
153 player_keep_in_bounds(pplayer);
159 if (issolid(pplayer->base.x, pplayer->base.y + 31) &&
160 !issolid(pplayer->base.x- pplayer->base.xm, pplayer->base.y + 31))
162 while (issolid(pplayer->base.x, pplayer->base.y + 31))
164 if (pplayer->base.xm < 0)
166 else if (pplayer->base.xm > 0)
170 pplayer->base.xm = 0;
173 if (issolid(pplayer->base.x, pplayer->base.y) &&
174 !issolid(pplayer->base.x- pplayer->base.xm, pplayer->base.y))
176 while (issolid(pplayer->base.x, (pplayer->base.y)))
178 if (pplayer->base.xm < 0)
180 else if (pplayer->base.xm > 0)
184 pplayer->base.xm = 0;
187 if (issolid(pplayer->base.x, pplayer->base.y + 31))
189 /* Set down properly: */
192 while (issolid(pplayer->base.x, pplayer->base.y + 31))
196 DEBUG_MSG("FIXME - UNDER certain circumstances I'm hanging in a loop here!");
198 if (pplayer->base.ym < 0)
200 else if (pplayer->base.ym > 0)
205 /* Reset score multiplier (for multi-hits): */
207 if (pplayer->base.ym > 0)
208 score_multiplier = 1;
213 pplayer->base.ym = 0;
214 pplayer->jumping = NO;
218 /* Bump into things: */
220 if (issolid(pplayer->base.x, pplayer->base.y) ||
221 (pplayer->size == BIG && !pplayer->duck &&
222 (issolid(pplayer->base.x, pplayer->base.y - 32))))
224 if (!issolid(pplayer->base.x- pplayer->base.xm, pplayer->base.y) &&
225 (pplayer->size == SMALL || pplayer->duck ||
226 !issolid(pplayer->base.x- pplayer->base.xm, pplayer->base.y - 32)))
228 pplayer->base.x = pplayer->base.x- pplayer->base.xm;
229 pplayer->base.xm = 0;
231 else if (!issolid(pplayer->base.x, pplayer->base.y - pplayer->base.ym) &&
232 (pplayer->size == SMALL || pplayer->duck ||
233 !issolid(pplayer->base.x, pplayer->base.y - 32 - pplayer->base.ym)))
235 if (pplayer->base.ym <= 0)
239 if (pplayer->size == BIG)
241 /* Break bricks and empty boxes: */
245 if (isbrick(pplayer->base.x, pplayer->base.y - 32) ||
246 isfullbox(pplayer->base.x, pplayer->base.y - 32))
248 trygrabdistro(pplayer->base.x, pplayer->base.y - 64, BOUNCE);
249 trybumpbadguy(pplayer->base.x, pplayer->base.y - 96);
251 if (isfullbox(pplayer->base.x, pplayer->base.y - 32))
253 bumpbrick(pplayer->base.x, pplayer->base.y - 32);
256 trybreakbrick(pplayer->base.x, pplayer->base.y - 32);
257 tryemptybox(pplayer->base.x, pplayer->base.y - 32);
260 if (isbrick(pplayer->base.x+ 31, pplayer->base.y - 32) ||
261 isfullbox(pplayer->base.x+ 31, pplayer->base.y - 32))
263 trygrabdistro(pplayer->base.x+ 31,
264 pplayer->base.y - 64,
266 trybumpbadguy(pplayer->base.x+ 31,
267 pplayer->base.y - 96);
269 if (isfullbox(pplayer->base.x+ 31, pplayer->base.y - 32))
271 bumpbrick(pplayer->base.x+ 31, pplayer->base.y - 32);
274 trybreakbrick(pplayer->base.x+ 31,
275 pplayer->base.y - 32);
276 tryemptybox(pplayer->base.x+ 31,
277 pplayer->base.y - 32);
282 if (isbrick(pplayer->base.x, pplayer->base.y) ||
283 isfullbox(pplayer->base.x, pplayer->base.y))
285 trygrabdistro(pplayer->base.x, pplayer->base.y - 32,BOUNCE);
286 trybumpbadguy(pplayer->base.x, pplayer->base.y - 64);
287 if (isfullbox(pplayer->base.x, pplayer->base.y))
288 bumpbrick(pplayer->base.x, pplayer->base.y);
289 trybreakbrick(pplayer->base.x, pplayer->base.y);
290 tryemptybox(pplayer->base.x, pplayer->base.y);
293 if (isbrick(pplayer->base.x+ 31, pplayer->base.y) ||
294 isfullbox(pplayer->base.x+ 31, pplayer->base.y))
296 trygrabdistro(pplayer->base.x+ 31,
297 pplayer->base.y - 32,
299 trybumpbadguy(pplayer->base.x+ 31,
300 pplayer->base.y - 64);
301 if (isfullbox(pplayer->base.x+ 31, pplayer->base.y))
302 bumpbrick(pplayer->base.x+ 31, pplayer->base.y);
303 trybreakbrick(pplayer->base.x+ 31, pplayer->base.y);
304 tryemptybox(pplayer->base.x+ 31, pplayer->base.y);
310 /* It's a brick and we're small, make the brick
311 bounce, and grab any distros above it: */
313 if (isbrick(pplayer->base.x, pplayer->base.y) ||
314 isfullbox(pplayer->base.x, pplayer->base.y))
316 trygrabdistro(pplayer->base.x, pplayer->base.y - 32,BOUNCE);
317 trybumpbadguy(pplayer->base.x, pplayer->base.y - 64);
318 bumpbrick(pplayer->base.x, pplayer->base.y);
319 tryemptybox(pplayer->base.x, pplayer->base.y);
322 if (isbrick(pplayer->base.x+ 31, pplayer->base.y) ||
323 isfullbox(pplayer->base.x+ 31, pplayer->base.y))
325 trygrabdistro(pplayer->base.x+ 31, pplayer->base.y - 32,BOUNCE);
326 trybumpbadguy(pplayer->base.x+ 31, pplayer->base.y - 64);
327 bumpbrick(pplayer->base.x+ 31, pplayer->base.y);
328 tryemptybox(pplayer->base.x+ 31, pplayer->base.y);
332 /* Get a distro from a brick? */
334 if (shape(pplayer->base.x, pplayer->base.y) == 'x' ||
335 shape(pplayer->base.x, pplayer->base.y) == 'y')
337 add_bouncy_distro(((pplayer->base.x+ 1)
339 (int)(pplayer->base.y / 32) * 32);
341 if (counting_distros == NO)
343 counting_distros = YES;
344 distro_counter = 100;
347 if (distro_counter <= 0)
348 level_change(¤t_level,pplayer->base.x,pplayer->base.y, 'a');
350 play_sound(sounds[SND_DISTRO], SOUND_CENTER_SPEAKER);
351 score = score + SCORE_DISTRO;
354 else if (shape(pplayer->base.x+ 31, pplayer->base.y) == 'x' ||
355 shape(pplayer->base.x+ 31, pplayer->base.y) == 'y')
357 add_bouncy_distro(((pplayer->base.x+ 1 + 31)
359 (int)(pplayer->base.y / 32) * 32);
361 if (counting_distros == NO)
363 counting_distros = YES;
364 distro_counter = 100;
367 if (distro_counter <= 0)
368 level_change(¤t_level,pplayer->base.x+ 31, pplayer->base.y, 'a');
370 play_sound(sounds[SND_DISTRO], SOUND_CENTER_SPEAKER);
371 score = score + SCORE_DISTRO;
379 pplayer->base.y = (int)(pplayer->base.y / 32) * 32 + 30;
385 pplayer->base.y = (int)(pplayer->base.y / 32) * 32 - 32;
388 pplayer->base.ym = 0;
389 pplayer->jumping = NO;
390 /*pplayer->jump_counter = MAX_JUMP_COUNT;*/
391 /*timer_init(&pplayer->jump_timer);*/
392 timer_start(&pplayer->jump_timer,MAX_JUMP_TIME);
399 player_grabdistros(pplayer);
402 /* Slow down horizontally: */
406 if (pplayer->input.right == UP && pplayer->input.left == UP)
408 if (isice(pplayer->base.x, pplayer->base.y + 32) ||
409 !issolid(pplayer->base.x, pplayer->base.y + 32))
411 /* Slowly on ice or in air: */
413 if (pplayer->base.xm > 0)
415 else if (pplayer->base.xm < 0)
420 /* Quickly, otherwise: */
422 pplayer->base.xm = pplayer->base.xm / 2;
427 /* Drop vertically: */
429 if (!issolid(pplayer->base.x, pplayer->base.y + 32))
431 pplayer->base.ym = pplayer->base.ym + GRAVITY;
433 if (pplayer->base.ym > MAX_YM)
434 pplayer->base.ym = MAX_YM;
440 timer_check(&pplayer->safe_timer);
443 /* ---- DONE HANDLING TUX! --- */
445 /* Handle invincibility timer: */
448 if (timer_check(&pplayer->invincible_timer))
450 if (current_music == HERRING_MUSIC)
452 if (current_level.time_left <= TIME_WARNING)
454 /* stop the herring_song, prepare to play the correct
457 current_music = HURRYUP_MUSIC;
461 current_music = LEVEL_MUSIC;
463 /* stop the old music if it's being played */
469 /* Handle skidding: */
471 timer_check(&pplayer->skidding_timer);
475 if (pplayer->base.x>= endpos && endpos != 0)
482 void player_input(player_type *pplayer)
484 /* Handle key and joystick state: */
487 if (pplayer->input.right == DOWN && pplayer->input.left == UP)
489 if (pplayer->jumping == NO)
491 if (pplayer->base.xm < -SKID_XM && !timer_started(&pplayer->skidding_timer) &&
492 pplayer->dir == LEFT)
494 timer_start(&pplayer->skidding_timer, SKID_TIME);
496 play_sound(sounds[SND_SKID], SOUND_CENTER_SPEAKER);
499 pplayer->dir = RIGHT;
502 if (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 == RIGHT)
512 /* Facing the direction we're jumping? Go full-speed: */
514 if (pplayer->input.fire == UP)
516 pplayer->base.xm = pplayer->base.xm + WALK_SPEED;
518 if (pplayer->base.xm > MAX_WALK_XM)
519 pplayer->base.xm = MAX_WALK_XM;
521 else if ( pplayer->input.fire == DOWN)
523 pplayer->base.xm = pplayer->base.xm + RUN_SPEED;
525 if (pplayer->base.xm > MAX_RUN_XM)
526 pplayer->base.xm = MAX_RUN_XM;
531 /* Not facing the direction we're jumping?
534 pplayer->base.xm = pplayer->base.xm + WALK_SPEED / 2;
536 if (pplayer->base.xm > MAX_WALK_XM / 2)
537 pplayer->base.xm = MAX_WALK_XM / 2;
541 else if (pplayer->input.left == DOWN && pplayer->input.right == UP)
543 if (pplayer->jumping == NO)
545 if (pplayer->base.xm > SKID_XM && !timer_started(&pplayer->skidding_timer) &&
546 pplayer->dir == RIGHT)
548 timer_start(&pplayer->skidding_timer,SKID_TIME);
549 play_sound(sounds[SND_SKID], SOUND_CENTER_SPEAKER);
554 if (pplayer->base.xm > 0 && !isice(pplayer->base.x, pplayer->base.y + 32) &&
555 !timer_started(&pplayer->skidding_timer))
557 pplayer->base.xm = 0;
562 if (pplayer->dir == LEFT)
564 /* Facing the direction we're jumping? Go full-speed: */
566 if (pplayer->input.fire == UP)
568 pplayer->base.xm = pplayer->base.xm - WALK_SPEED;
570 if (pplayer->base.xm < -MAX_WALK_XM)
571 pplayer->base.xm = -MAX_WALK_XM;
573 else if (pplayer->input.fire == DOWN)
575 pplayer->base.xm = pplayer->base.xm - RUN_SPEED;
577 if (pplayer->base.xm < -MAX_RUN_XM)
578 pplayer->base.xm = -MAX_RUN_XM;
583 /* Not facing the direction we're jumping?
586 pplayer->base.xm = pplayer->base.xm - WALK_SPEED / 2;
588 if (pplayer->base.xm < -MAX_WALK_XM / 2)
589 pplayer->base.xm = -MAX_WALK_XM / 2;
596 if ( pplayer->input.up == DOWN)
598 if(!timer_started(&pplayer->jump_timer))
600 timer_start(&pplayer->jump_timer,MAX_JUMP_TIME);
605 if (!issolid(pplayer->base.x, pplayer->base.y + 32) ||
606 pplayer->base.ym != 0)
608 /* If they're not on the ground, or are currently moving
609 vertically, don't jump! */
611 pplayer->jumping = NO;
612 timer_stop(&pplayer->jump_timer);
616 /* Make sure we're not standing back up into a solid! */
618 if (pplayer->size == SMALL || pplayer->duck == NO ||
619 !issolid(pplayer->base.x, pplayer->base.y))
621 pplayer->jumping = YES;
623 if (pplayer->size == SMALL)
624 play_sound(sounds[SND_JUMP], SOUND_CENTER_SPEAKER);
626 play_sound(sounds[SND_BIGJUMP], SOUND_CENTER_SPEAKER);
631 /* Keep jumping for a while: */
633 if (timer_check(&pplayer->jump_timer))
635 pplayer->base.ym = pplayer->base.ym - JUMP_SPEED;
639 timer_stop(&pplayer->jump_timer);
644 if (pplayer->input.fire == DOWN && pplayer->input.old_fire == UP && pplayer->got_coffee)
646 add_bullet(pplayer->base.x, pplayer->base.y, pplayer->base.xm, pplayer->dir);
652 if (pplayer->input.down == DOWN)
654 if (pplayer->size == BIG)
659 if (pplayer->size == BIG && pplayer->duck == YES)
661 /* Make sure we're not standing back up into a solid! */
663 if (!issolid(pplayer->base.x, pplayer->base.y - 32))
672 if (pplayer->input.right == UP && pplayer->input.left == UP)
674 pplayer->frame_main = 1;
679 if ((pplayer->input.fire == DOWN && (frame % 2) == 0) ||
681 pplayer->frame_main = (pplayer->frame_main + 1) % 4;
683 pplayer->frame = pplayer->frame_main;
685 if (pplayer->frame == 3)
691 void player_grabdistros(player_type *pplayer)
696 trygrabdistro(pplayer->base.x, pplayer->base.y, NO_BOUNCE);
697 trygrabdistro(pplayer->base.x+ 31, pplayer->base.y, NO_BOUNCE);
699 if (pplayer->size == BIG && !pplayer->duck)
701 trygrabdistro(pplayer->base.x, pplayer->base.y - 32, NO_BOUNCE);
702 trygrabdistro(pplayer->base.x+ 31, pplayer->base.y - 32, NO_BOUNCE);
707 /* Enough distros for a One-up? */
709 if (distros >= DISTROS_LIFEUP)
711 distros = distros - DISTROS_LIFEUP;
712 if(pplayer->lives < MAX_LIVES)
714 /*We want to hear the sound even, if MAX_LIVES is reached*/
715 play_sound(sounds[SND_LIFEUP], SOUND_CENTER_SPEAKER);
719 void player_draw(player_type* pplayer)
722 if (!timer_started(&pplayer->safe_timer) || (frame % 2) == 0)
724 if (pplayer->size == SMALL)
726 if (timer_started(&pplayer->invincible_timer))
730 if (pplayer->dir == RIGHT)
732 texture_draw(&cape_right[frame % 2],
733 pplayer->base.x- scroll_x, pplayer->base.y,
738 texture_draw(&cape_left[frame % 2],
739 pplayer->base.x- scroll_x, pplayer->base.y,
745 if (!pplayer->got_coffee)
747 if (pplayer->dir == RIGHT)
749 texture_draw(&tux_right[pplayer->frame], pplayer->base.x- scroll_x, pplayer->base.y, NO_UPDATE);
753 texture_draw(&tux_left[pplayer->frame], pplayer->base.x- scroll_x, pplayer->base.y, NO_UPDATE);
758 /* Tux got coffee! */
760 if (pplayer->dir == RIGHT)
762 texture_draw(&firetux_right[pplayer->frame], pplayer->base.x- scroll_x, pplayer->base.y, NO_UPDATE);
766 texture_draw(&firetux_left[pplayer->frame], pplayer->base.x- scroll_x, pplayer->base.y, NO_UPDATE);
772 if (timer_started(&pplayer->invincible_timer))
776 if (pplayer->dir == RIGHT)
778 texture_draw(&bigcape_right[frame % 2],
779 pplayer->base.x- scroll_x - 8 - 16, pplayer->base.y - 32,
784 texture_draw(&bigcape_left[frame % 2],
785 pplayer->base.x-scroll_x - 8, pplayer->base.y - 32,
790 if (!pplayer->got_coffee)
794 if (!timer_started(&pplayer->skidding_timer))
796 if (!pplayer->jumping || pplayer->base.ym > 0)
798 if (pplayer->dir == RIGHT)
800 texture_draw(&bigtux_right[pplayer->frame],
801 pplayer->base.x- scroll_x - 8, pplayer->base.y - 32,
806 texture_draw(&bigtux_left[pplayer->frame],
807 pplayer->base.x- scroll_x - 8, pplayer->base.y - 32,
813 if (pplayer->dir == RIGHT)
815 texture_draw(&bigtux_right_jump,
816 pplayer->base.x- scroll_x - 8, pplayer->base.y - 32,
821 texture_draw(&bigtux_left_jump,
822 pplayer->base.x- scroll_x - 8, pplayer->base.y - 32,
829 if (pplayer->dir == RIGHT)
831 texture_draw(&skidtux_right,
832 pplayer->base.x- scroll_x - 8, pplayer->base.y - 32,
837 texture_draw(&skidtux_left,
838 pplayer->base.x- scroll_x - 8, pplayer->base.y - 32,
845 if (pplayer->dir == RIGHT)
847 texture_draw(&ducktux_right, pplayer->base.x- scroll_x - 8, pplayer->base.y - 16,
852 texture_draw(&ducktux_left, pplayer->base.x- scroll_x - 8, pplayer->base.y - 16,
859 /* Tux has coffee! */
863 if (!timer_started(&pplayer->skidding_timer))
865 if (!pplayer->jumping || pplayer->base.ym > 0)
867 if (pplayer->dir == RIGHT)
869 texture_draw(&bigfiretux_right[pplayer->frame],
870 pplayer->base.x- scroll_x - 8, pplayer->base.y - 32,
875 texture_draw(&bigfiretux_left[pplayer->frame],
876 pplayer->base.x- scroll_x - 8, pplayer->base.y - 32,
882 if (pplayer->dir == RIGHT)
884 texture_draw(&bigfiretux_right_jump,
885 pplayer->base.x- scroll_x - 8, pplayer->base.y - 32,
890 texture_draw(&bigfiretux_left_jump,
891 pplayer->base.x- scroll_x - 8, pplayer->base.y - 32,
898 if (pplayer->dir == RIGHT)
900 texture_draw(&skidfiretux_right,
901 pplayer->base.x- scroll_x - 8, pplayer->base.y - 32,
906 texture_draw(&skidfiretux_left,
907 pplayer->base.x- scroll_x - 8, pplayer->base.y - 32,
914 if (pplayer->dir == RIGHT)
916 texture_draw(&duckfiretux_right, pplayer->base.x- scroll_x - 8, pplayer->base.y - 16,
921 texture_draw(&duckfiretux_left, pplayer->base.x- scroll_x - 8, pplayer->base.y - 16,
931 void player_collision(player_type* pplayer, void* p_c_object, int c_object)
933 bad_guy_type* pbad_c = NULL;
939 /* Hurt the player if he just touched it: */
941 if (!pbad_c->dying && !pplayer->dying &&
942 !timer_started(&pplayer->safe_timer) &&
943 pbad_c->mode != HELD)
945 if (pbad_c->mode == FLAT && pplayer->input.fire != DOWN)
950 play_sound(sounds[SND_KICK], SOUND_CENTER_SPEAKER);
952 if (pplayer->base.x<= pbad_c->base.x)
955 pbad_c->base.x = pbad_c->base.x + 16;
960 pbad_c->base.x = pbad_c->base.x - 16;
963 timer_start(&pbad_c->timer,5000);
965 else if (pbad_c->mode == FLAT && pplayer->input.fire == DOWN)
970 else if (pbad_c->mode == KICK)
972 if (pplayer->base.y < pbad_c->base.y - 16 &&
973 timer_started(&pbad_c->timer))
975 /* Step on (stop being kicked) */
978 play_sound(sounds[SND_STOMP], SOUND_CENTER_SPEAKER);
979 timer_start(&pbad_c->timer, 10000);
983 /* Hurt if you get hit by kicked laptop: */
985 if (timer_started(&pbad_c->timer))
987 if (!timer_started(&pplayer->invincible_timer))
989 player_kill(pplayer,SHRINK);
993 pbad_c->dying = FALLING;
994 pbad_c->base.ym = -8;
995 play_sound(sounds[SND_FALL], SOUND_CENTER_SPEAKER);
1002 if (!timer_started(&pplayer->invincible_timer ))
1004 player_kill(pplayer,SHRINK);
1008 pbad_c->dying = FALLING;
1009 pbad_c->base.ym = -8;
1010 play_sound(sounds[SND_FALL], SOUND_CENTER_SPEAKER);
1022 void player_kill(player_type* pplayer, int mode)
1024 pplayer->base.ym = -5;
1026 play_sound(sounds[SND_HURT], SOUND_CENTER_SPEAKER);
1028 if (pplayer->dir == RIGHT)
1029 pplayer->base.xm = -8;
1030 else if (tux.dir == LEFT)
1031 pplayer->base.xm = 8;
1033 if (mode == SHRINK && pplayer->size == BIG)
1035 if (pplayer->got_coffee)
1036 pplayer->got_coffee = NO;
1038 pplayer->size = SMALL;
1040 timer_start(&pplayer->safe_timer,TUX_SAFE_TIME);
1048 void player_dying(player_type *pplayer)
1050 pplayer->base.ym = pplayer->base.ym + GRAVITY;
1055 player_remove_powerups(pplayer);
1056 pplayer->dying = NO;
1058 player_level_begin(pplayer);
1062 /* Remove Tux's power ups */
1063 void player_remove_powerups(player_type* pplayer)
1065 pplayer->got_coffee = NO;
1066 pplayer->size = SMALL;
1069 void player_keep_in_bounds(player_type* pplayer)
1071 /* Keep tux in bounds: */
1072 if (pplayer->base.x< 0)
1074 else if(pplayer->base.x< scroll_x)
1075 pplayer->base.x= scroll_x;
1076 else if (pplayer->base.x< 160 + scroll_x && scroll_x > 0 && debug_mode == YES)
1078 scroll_x = pplayer->base.x- 160;
1079 /*pplayer->base.x+= 160;*/
1085 else if (pplayer->base.x> screen->w / 2 + scroll_x && scroll_x < ((current_level.width * 32) - screen->w))
1087 /* Scroll the screen in past center: */
1089 scroll_x = pplayer->base.x- screen->w / 2;
1090 /*pplayer->base.x= 320 + scroll_x;*/
1092 if (scroll_x > ((current_level.width * 32) - screen->w))
1093 scroll_x = ((current_level.width * 32) - screen->w);
1095 else if (pplayer->base.x> 608 + scroll_x)
1097 /* ... unless there's no more to scroll! */
1099 /*pplayer->base.x= 608 + scroll_x;*/
1102 /* Keep in-bounds, vertically: */
1104 if (pplayer->base.y < 0)
1105 pplayer->base.y = 0;
1106 else if (pplayer->base.y > screen->h)
1108 player_kill(&tux,KILL);