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))
193 DEBUG_MSG("FIXME - UNDER certain circumstances I'm hanging in a loop here!");
194 /*the circumstances are:
195 issolid() is true and base.ym == 0
196 use of floating point varibles for base stuff*/
199 if (pplayer->base.ym < 0)
201 else if (pplayer->base.ym > 0)
206 /* Reset score multiplier (for multi-hits): */
208 if (pplayer->base.ym > 0)
209 score_multiplier = 1;
214 pplayer->base.ym = 0;
215 pplayer->jumping = NO;
216 pplayer->input.up = UP;
220 /* Bump into things: */
222 if (issolid(pplayer->base.x, pplayer->base.y) ||
223 (pplayer->size == BIG && !pplayer->duck &&
224 (issolid(pplayer->base.x, pplayer->base.y - 32))))
226 if (!issolid(pplayer->base.x- pplayer->base.xm, pplayer->base.y) &&
227 (pplayer->size == SMALL || pplayer->duck ||
228 !issolid(pplayer->base.x- pplayer->base.xm, pplayer->base.y - 32)))
230 pplayer->base.x = pplayer->base.x- pplayer->base.xm;
231 pplayer->base.xm = 0;
233 else if (!issolid(pplayer->base.x, pplayer->base.y - pplayer->base.ym) &&
234 (pplayer->size == SMALL || pplayer->duck ||
235 !issolid(pplayer->base.x, pplayer->base.y - 32 - pplayer->base.ym)))
237 if (pplayer->base.ym <= 0)
241 if (pplayer->size == BIG)
243 /* Break bricks and empty boxes: */
247 if (isbrick(pplayer->base.x, pplayer->base.y - 32) ||
248 isfullbox(pplayer->base.x, pplayer->base.y - 32))
250 trygrabdistro(pplayer->base.x, pplayer->base.y - 64, BOUNCE);
251 trybumpbadguy(pplayer->base.x, pplayer->base.y - 96);
253 if (isfullbox(pplayer->base.x, pplayer->base.y - 32))
255 bumpbrick(pplayer->base.x, pplayer->base.y - 32);
258 trybreakbrick(pplayer->base.x, pplayer->base.y - 32);
259 tryemptybox(pplayer->base.x, pplayer->base.y - 32);
262 if (isbrick(pplayer->base.x+ 31, pplayer->base.y - 32) ||
263 isfullbox(pplayer->base.x+ 31, pplayer->base.y - 32))
265 trygrabdistro(pplayer->base.x+ 31,
266 pplayer->base.y - 64,
268 trybumpbadguy(pplayer->base.x+ 31,
269 pplayer->base.y - 96);
271 if (isfullbox(pplayer->base.x+ 31, pplayer->base.y - 32))
273 bumpbrick(pplayer->base.x+ 31, pplayer->base.y - 32);
276 trybreakbrick(pplayer->base.x+ 31,
277 pplayer->base.y - 32);
278 tryemptybox(pplayer->base.x+ 31,
279 pplayer->base.y - 32);
284 if (isbrick(pplayer->base.x, pplayer->base.y) ||
285 isfullbox(pplayer->base.x, pplayer->base.y))
287 trygrabdistro(pplayer->base.x, pplayer->base.y - 32,BOUNCE);
288 trybumpbadguy(pplayer->base.x, pplayer->base.y - 64);
289 if (isfullbox(pplayer->base.x, pplayer->base.y))
290 bumpbrick(pplayer->base.x, pplayer->base.y);
291 trybreakbrick(pplayer->base.x, pplayer->base.y);
292 tryemptybox(pplayer->base.x, pplayer->base.y);
295 if (isbrick(pplayer->base.x+ 31, pplayer->base.y) ||
296 isfullbox(pplayer->base.x+ 31, pplayer->base.y))
298 trygrabdistro(pplayer->base.x+ 31,
299 pplayer->base.y - 32,
301 trybumpbadguy(pplayer->base.x+ 31,
302 pplayer->base.y - 64);
303 if (isfullbox(pplayer->base.x+ 31, pplayer->base.y))
304 bumpbrick(pplayer->base.x+ 31, pplayer->base.y);
305 trybreakbrick(pplayer->base.x+ 31, pplayer->base.y);
306 tryemptybox(pplayer->base.x+ 31, pplayer->base.y);
312 /* It's a brick and we're small, make the brick
313 bounce, and grab any distros above it: */
315 if (isbrick(pplayer->base.x, pplayer->base.y) ||
316 isfullbox(pplayer->base.x, pplayer->base.y))
318 trygrabdistro(pplayer->base.x, pplayer->base.y - 32,BOUNCE);
319 trybumpbadguy(pplayer->base.x, pplayer->base.y - 64);
320 bumpbrick(pplayer->base.x, pplayer->base.y);
321 tryemptybox(pplayer->base.x, pplayer->base.y);
324 if (isbrick(pplayer->base.x+ 31, pplayer->base.y) ||
325 isfullbox(pplayer->base.x+ 31, pplayer->base.y))
327 trygrabdistro(pplayer->base.x+ 31, pplayer->base.y - 32,BOUNCE);
328 trybumpbadguy(pplayer->base.x+ 31, pplayer->base.y - 64);
329 bumpbrick(pplayer->base.x+ 31, pplayer->base.y);
330 tryemptybox(pplayer->base.x+ 31, pplayer->base.y);
334 /* Get a distro from a brick? */
336 if (shape(pplayer->base.x, pplayer->base.y) == 'x' ||
337 shape(pplayer->base.x, pplayer->base.y) == 'y')
339 add_bouncy_distro(((pplayer->base.x+ 1)
341 (int)(pplayer->base.y / 32) * 32);
343 if (counting_distros == NO)
345 counting_distros = YES;
346 distro_counter = 100;
349 if (distro_counter <= 0)
350 level_change(¤t_level,pplayer->base.x,pplayer->base.y, 'a');
352 play_sound(sounds[SND_DISTRO], SOUND_CENTER_SPEAKER);
353 score = score + SCORE_DISTRO;
356 else if (shape(pplayer->base.x+ 31, pplayer->base.y) == 'x' ||
357 shape(pplayer->base.x+ 31, pplayer->base.y) == 'y')
359 add_bouncy_distro(((pplayer->base.x+ 1 + 31)
361 (int)(pplayer->base.y / 32) * 32);
363 if (counting_distros == NO)
365 counting_distros = YES;
366 distro_counter = 100;
369 if (distro_counter <= 0)
370 level_change(¤t_level,pplayer->base.x+ 31, pplayer->base.y, 'a');
372 play_sound(sounds[SND_DISTRO], SOUND_CENTER_SPEAKER);
373 score = score + SCORE_DISTRO;
381 pplayer->base.y = (int)(pplayer->base.y / 32) * 32 + 30;
387 pplayer->base.y = (int)(pplayer->base.y / 32) * 32 - 32;
390 pplayer->base.ym = 0;
391 pplayer->jumping = NO;
392 /*pplayer->jump_counter = MAX_JUMP_COUNT;*/
393 /*timer_init(&pplayer->jump_timer);*/
394 timer_start(&pplayer->jump_timer,MAX_JUMP_TIME);
401 player_grabdistros(pplayer);
404 /* Slow down horizontally: */
408 if (pplayer->input.right == UP && pplayer->input.left == UP)
410 if (isice(pplayer->base.x, pplayer->base.y + 32) ||
411 !issolid(pplayer->base.x, pplayer->base.y + 32))
413 /* Slowly on ice or in air: */
415 if (pplayer->base.xm > 0)
417 else if (pplayer->base.xm < 0)
422 /* Quickly, otherwise: */
424 pplayer->base.xm = pplayer->base.xm / 2;
429 /* Drop vertically: */
431 if (!issolid(pplayer->base.x, pplayer->base.y + 32))
433 pplayer->base.ym = pplayer->base.ym + GRAVITY;
435 if (pplayer->base.ym > MAX_YM)
436 pplayer->base.ym = MAX_YM;
442 timer_check(&pplayer->safe_timer);
445 /* ---- DONE HANDLING TUX! --- */
447 /* Handle invincibility timer: */
450 if (current_music == HERRING_MUSIC && !timer_check(&pplayer->invincible_timer))
453 no, we are no more invincible
454 or we were not in invincible mode
455 but are we in hurry ?
459 if (timer_get_left(&time_left) < TIME_WARNING)
461 /* yes, we are in hurry
462 stop the herring_song, prepare to play the correct
465 current_music = HURRYUP_MUSIC;
469 current_music = LEVEL_MUSIC;
472 /* stop the old music if it's being played */
477 /* Handle skidding: */
479 timer_check(&pplayer->skidding_timer);
483 if (pplayer->base.x - scroll_x >= endpos && endpos != 0)
490 void player_handle_horizontal_input(player_type *pplayer, int dir)
492 if (pplayer->jumping == NO)
494 if ((dir ? (pplayer->base.xm < -SKID_XM) : (pplayer->base.xm > SKID_XM)) && !timer_started(&pplayer->skidding_timer) &&
495 pplayer->dir == !dir)
497 timer_start(&pplayer->skidding_timer, SKID_TIME);
499 play_sound(sounds[SND_SKID], SOUND_CENTER_SPEAKER);
505 if ((dir ? (pplayer->base.xm < 0) : (pplayer->base.xm > 0)) && !isice(pplayer->base.x, pplayer->base.y + 32) &&
506 !timer_started(&pplayer->skidding_timer))
508 pplayer->base.xm = 0;
513 if (pplayer->dir == dir)
515 /* Facing the direction we're jumping? Go full-speed: */
517 if (pplayer->input.fire == UP)
519 pplayer->base.xm = pplayer->base.xm + ( dir ? WALK_SPEED : -WALK_SPEED) * frame_ratio;
523 if (pplayer->base.xm > MAX_WALK_XM)
524 pplayer->base.xm = MAX_WALK_XM;
528 if (pplayer->base.xm < -MAX_WALK_XM)
529 pplayer->base.xm = -MAX_WALK_XM;
532 else if ( pplayer->input.fire == DOWN)
534 pplayer->base.xm = pplayer->base.xm + ( dir ? RUN_SPEED : -RUN_SPEED) * frame_ratio;
538 if (pplayer->base.xm > MAX_RUN_XM)
539 pplayer->base.xm = MAX_RUN_XM;
543 if (pplayer->base.xm < -MAX_RUN_XM)
544 pplayer->base.xm = -MAX_RUN_XM;
549 /* Not facing the direction we're jumping?
552 pplayer->base.xm = pplayer->base.xm + ( dir ? (WALK_SPEED / 2) : -(WALK_SPEED / 2)) * frame_ratio;
556 if (pplayer->base.xm > MAX_WALK_XM / 2)
557 pplayer->base.xm = MAX_WALK_XM / 2;
561 if (pplayer->base.xm < -MAX_WALK_XM / 2)
562 pplayer->base.xm = -MAX_WALK_XM / 2;
570 void player_handle_vertical_input(player_type *pplayer)
572 if(!timer_started(&pplayer->jump_timer))
574 timer_start(&pplayer->jump_timer,MAX_JUMP_TIME);
579 if (!issolid(pplayer->base.x, pplayer->base.y + 32) ||
580 pplayer->base.ym != 0)
582 /* If they're not on the ground, or are currently moving
583 vertically, don't jump! */
585 pplayer->jumping = NO;
586 timer_stop(&pplayer->jump_timer);
590 /* Make sure we're not standing back up into a solid! */
592 if (pplayer->size == SMALL || pplayer->duck == NO ||
593 !issolid(pplayer->base.x, pplayer->base.y))
595 pplayer->jumping = YES;
597 if (pplayer->size == SMALL)
598 play_sound(sounds[SND_JUMP], SOUND_CENTER_SPEAKER);
600 play_sound(sounds[SND_BIGJUMP], SOUND_CENTER_SPEAKER);
605 /* Keep jumping for a while: */
607 if (timer_check(&pplayer->jump_timer))
609 pplayer->base.ym = pplayer->base.ym - JUMP_SPEED * frame_ratio;
610 if (pplayer->base.ym < -YM_FOR_JUMP)
611 pplayer->base.ym = -YM_FOR_JUMP;
615 void player_input(player_type *pplayer)
617 /* Handle key and joystick state: */
620 if (pplayer->input.right == DOWN && pplayer->input.left == UP)
622 player_handle_horizontal_input(pplayer,RIGHT);
624 else if (pplayer->input.left == DOWN && pplayer->input.right == UP)
626 player_handle_horizontal_input(pplayer,LEFT);
631 if ( pplayer->input.up == DOWN)
633 player_handle_vertical_input(pplayer);
636 timer_stop(&pplayer->jump_timer);
640 if (pplayer->input.fire == DOWN && pplayer->input.old_fire == UP && pplayer->got_coffee)
642 add_bullet(pplayer->base.x, pplayer->base.y, pplayer->base.xm, pplayer->dir);
648 if (pplayer->input.down == DOWN)
650 if (pplayer->size == BIG)
655 if (pplayer->size == BIG && pplayer->duck == YES)
657 /* Make sure we're not standing back up into a solid! */
659 if (!issolid(pplayer->base.x, pplayer->base.y - 32))
668 if (pplayer->input.right == UP && pplayer->input.left == UP)
670 pplayer->frame_main = 1;
675 if ((pplayer->input.fire == DOWN && (frame % 2) == 0) ||
677 pplayer->frame_main = (pplayer->frame_main + 1) % 4;
679 pplayer->frame = pplayer->frame_main;
681 if (pplayer->frame == 3)
687 void player_grabdistros(player_type *pplayer)
692 trygrabdistro(pplayer->base.x, pplayer->base.y, NO_BOUNCE);
693 trygrabdistro(pplayer->base.x+ 31, pplayer->base.y, NO_BOUNCE);
695 if (pplayer->size == BIG && !pplayer->duck)
697 trygrabdistro(pplayer->base.x, pplayer->base.y - 32, NO_BOUNCE);
698 trygrabdistro(pplayer->base.x+ 31, pplayer->base.y - 32, NO_BOUNCE);
703 /* Enough distros for a One-up? */
705 if (distros >= DISTROS_LIFEUP)
707 distros = distros - DISTROS_LIFEUP;
708 if(pplayer->lives < MAX_LIVES)
710 /*We want to hear the sound even, if MAX_LIVES is reached*/
711 play_sound(sounds[SND_LIFEUP], SOUND_CENTER_SPEAKER);
715 void player_draw(player_type* pplayer)
717 if (!timer_started(&pplayer->safe_timer) || (frame % 2) == 0)
719 if (pplayer->size == SMALL)
721 if (timer_started(&pplayer->invincible_timer))
725 if (pplayer->dir == RIGHT)
727 texture_draw(&cape_right[frame % 2],
728 pplayer->base.x- scroll_x, pplayer->base.y,
733 texture_draw(&cape_left[frame % 2],
734 pplayer->base.x- scroll_x, pplayer->base.y,
740 if (!pplayer->got_coffee)
742 if (pplayer->dir == RIGHT)
744 texture_draw(&tux_right[pplayer->frame], pplayer->base.x- scroll_x, pplayer->base.y, NO_UPDATE);
748 texture_draw(&tux_left[pplayer->frame], pplayer->base.x- scroll_x, pplayer->base.y, NO_UPDATE);
753 /* Tux got coffee! */
755 if (pplayer->dir == RIGHT)
757 texture_draw(&firetux_right[pplayer->frame], pplayer->base.x- scroll_x, pplayer->base.y, NO_UPDATE);
761 texture_draw(&firetux_left[pplayer->frame], pplayer->base.x- scroll_x, pplayer->base.y, NO_UPDATE);
767 if (timer_started(&pplayer->invincible_timer))
771 if (pplayer->dir == RIGHT)
773 texture_draw(&bigcape_right[frame % 2],
774 pplayer->base.x- scroll_x - 8 - 16, pplayer->base.y - 32,
779 texture_draw(&bigcape_left[frame % 2],
780 pplayer->base.x-scroll_x - 8, pplayer->base.y - 32,
785 if (!pplayer->got_coffee)
789 if (!timer_started(&pplayer->skidding_timer))
791 if (!pplayer->jumping || pplayer->base.ym > 0)
793 if (pplayer->dir == RIGHT)
795 texture_draw(&bigtux_right[pplayer->frame],
796 pplayer->base.x- scroll_x - 8, pplayer->base.y - 32,
801 texture_draw(&bigtux_left[pplayer->frame],
802 pplayer->base.x- scroll_x - 8, pplayer->base.y - 32,
808 if (pplayer->dir == RIGHT)
810 texture_draw(&bigtux_right_jump,
811 pplayer->base.x- scroll_x - 8, pplayer->base.y - 32,
816 texture_draw(&bigtux_left_jump,
817 pplayer->base.x- scroll_x - 8, pplayer->base.y - 32,
824 if (pplayer->dir == RIGHT)
826 texture_draw(&skidtux_right,
827 pplayer->base.x- scroll_x - 8, pplayer->base.y - 32,
832 texture_draw(&skidtux_left,
833 pplayer->base.x- scroll_x - 8, pplayer->base.y - 32,
840 if (pplayer->dir == RIGHT)
842 texture_draw(&ducktux_right, pplayer->base.x- scroll_x - 8, pplayer->base.y - 16,
847 texture_draw(&ducktux_left, pplayer->base.x- scroll_x - 8, pplayer->base.y - 16,
854 /* Tux has coffee! */
858 if (!timer_started(&pplayer->skidding_timer))
860 if (!pplayer->jumping || pplayer->base.ym > 0)
862 if (pplayer->dir == RIGHT)
864 texture_draw(&bigfiretux_right[pplayer->frame],
865 pplayer->base.x- scroll_x - 8, pplayer->base.y - 32,
870 texture_draw(&bigfiretux_left[pplayer->frame],
871 pplayer->base.x- scroll_x - 8, pplayer->base.y - 32,
877 if (pplayer->dir == RIGHT)
879 texture_draw(&bigfiretux_right_jump,
880 pplayer->base.x- scroll_x - 8, pplayer->base.y - 32,
885 texture_draw(&bigfiretux_left_jump,
886 pplayer->base.x- scroll_x - 8, pplayer->base.y - 32,
893 if (pplayer->dir == RIGHT)
895 texture_draw(&skidfiretux_right,
896 pplayer->base.x- scroll_x - 8, pplayer->base.y - 32,
901 texture_draw(&skidfiretux_left,
902 pplayer->base.x- scroll_x - 8, pplayer->base.y - 32,
909 if (pplayer->dir == RIGHT)
911 texture_draw(&duckfiretux_right, pplayer->base.x- scroll_x - 8, pplayer->base.y - 16,
916 texture_draw(&duckfiretux_left, pplayer->base.x- scroll_x - 8, pplayer->base.y - 16,
925 void player_collision(player_type* pplayer, void* p_c_object, int c_object)
927 bad_guy_type* pbad_c = NULL;
933 /* Hurt the player if he just touched it: */
935 if (!pbad_c->dying && !pplayer->dying &&
936 !timer_started(&pplayer->safe_timer) &&
937 pbad_c->mode != HELD)
939 if (pbad_c->mode == FLAT && pplayer->input.fire != DOWN)
944 play_sound(sounds[SND_KICK], SOUND_CENTER_SPEAKER);
946 if (pplayer->base.x<= pbad_c->base.x)
949 pbad_c->base.x = pbad_c->base.x + 16;
954 pbad_c->base.x = pbad_c->base.x - 16;
957 timer_start(&pbad_c->timer,5000);
959 else if (pbad_c->mode == FLAT && pplayer->input.fire == DOWN)
964 else if (pbad_c->mode == KICK)
966 if (pplayer->base.y < pbad_c->base.y - 16 &&
967 timer_started(&pbad_c->timer))
969 /* Step on (stop being kicked) */
972 play_sound(sounds[SND_STOMP], SOUND_CENTER_SPEAKER);
973 timer_start(&pbad_c->timer, 10000);
977 /* Hurt if you get hit by kicked laptop: */
979 if (timer_started(&pbad_c->timer))
981 if (!timer_started(&pplayer->invincible_timer))
983 player_kill(pplayer,SHRINK);
987 pbad_c->dying = FALLING;
988 pbad_c->base.ym = -8;
989 play_sound(sounds[SND_FALL], SOUND_CENTER_SPEAKER);
996 if (!timer_started(&pplayer->invincible_timer ))
998 player_kill(pplayer,SHRINK);
1002 pbad_c->dying = FALLING;
1003 pbad_c->base.ym = -8;
1004 play_sound(sounds[SND_FALL], SOUND_CENTER_SPEAKER);
1016 void player_kill(player_type* pplayer, int mode)
1018 pplayer->base.ym = -5;
1020 play_sound(sounds[SND_HURT], SOUND_CENTER_SPEAKER);
1022 if (pplayer->dir == RIGHT)
1023 pplayer->base.xm = -8;
1024 else if (pplayer->dir == LEFT)
1025 pplayer->base.xm = 8;
1027 if (mode == SHRINK && pplayer->size == BIG)
1029 if (pplayer->got_coffee)
1030 pplayer->got_coffee = NO;
1032 pplayer->size = SMALL;
1034 timer_start(&pplayer->safe_timer,TUX_SAFE_TIME);
1042 void player_dying(player_type *pplayer)
1044 pplayer->base.ym = pplayer->base.ym + GRAVITY;
1049 player_remove_powerups(pplayer);
1050 pplayer->dying = NO;
1052 player_level_begin(pplayer);
1056 /* Remove Tux's power ups */
1057 void player_remove_powerups(player_type* pplayer)
1059 pplayer->got_coffee = NO;
1060 pplayer->size = SMALL;
1063 void player_keep_in_bounds(player_type* pplayer)
1065 /* Keep tux in bounds: */
1066 if (pplayer->base.x< 0)
1068 else if(pplayer->base.x< scroll_x)
1069 pplayer->base.x= scroll_x;
1070 else if (pplayer->base.x< 160 + scroll_x && scroll_x > 0 && debug_mode == YES)
1072 scroll_x = pplayer->base.x- 160;
1073 /*pplayer->base.x+= 160;*/
1079 else if (pplayer->base.x> screen->w / 2 + scroll_x && scroll_x < ((current_level.width * 32) - screen->w))
1081 /* Scroll the screen in past center: */
1083 scroll_x = pplayer->base.x- screen->w / 2;
1084 /*pplayer->base.x= 320 + scroll_x;*/
1086 if (scroll_x > ((current_level.width * 32) - screen->w))
1087 scroll_x = ((current_level.width * 32) - screen->w);
1089 else if (pplayer->base.x> 608 + scroll_x)
1091 /* ... unless there's no more to scroll! */
1093 /*pplayer->base.x= 608 + scroll_x;*/
1096 /* Keep in-bounds, vertically: */
1098 if (pplayer->base.y < 0)
1099 pplayer->base.y = 0;
1100 else if (pplayer->base.y > screen->h)
1102 player_kill(&tux,KILL);