7 bill@newbreedsoftware.com
8 http://www.newbreedsoftware.com/supertux/
10 April 11, 2000 - December 9, 2003
19 #include <SDL_image.h>
23 #include <sys/types.h>
33 #include "high_scores.h"
57 char * soundfilenames[NUM_SOUNDS] = {
58 DATA_PREFIX "/sounds/jump.wav",
59 DATA_PREFIX "/sounds/bigjump.wav",
60 DATA_PREFIX "/sounds/skid.wav",
61 DATA_PREFIX "/sounds/distro.wav",
62 DATA_PREFIX "/sounds/herring.wav",
63 DATA_PREFIX "/sounds/brick.wav",
64 DATA_PREFIX "/sounds/hurt.wav",
65 DATA_PREFIX "/sounds/squish.wav",
66 DATA_PREFIX "/sounds/fall.wav",
67 DATA_PREFIX "/sounds/ricochet.wav",
68 DATA_PREFIX "/sounds/bump-upgrade.wav",
69 DATA_PREFIX "/sounds/upgrade.wav",
70 DATA_PREFIX "/sounds/excellent.wav",
71 DATA_PREFIX "/sounds/coffee.wav",
72 DATA_PREFIX "/sounds/shoot.wav",
73 DATA_PREFIX "/sounds/lifeup.wav"
77 /* Local variables: */
79 int score, highscore, distros, level, lives, scroll_x, next_level,
80 tux_dir, tux_size, tux_duck, tux_x, tux_xm, tux_y, tux_ym,
81 tux_dying, tux_safe, jumping, jump_counter, frame, score_multiplier,
82 tux_frame_main, tux_frame, tux_got_coffee, tux_skidding,
83 super_bkgd_time, time_left, tux_invincible_time, endpos,
84 counting_distros, distro_counter;
85 int bkgd_red, bkgd_green, bkgd_blue, level_width;
86 int left, right, up, down, fire, old_fire;
87 SDL_Surface * img_brick[2], * img_solid[4], * img_distro[4],
88 * img_waves[3], * img_water, * img_pole, * img_poletop, * img_flag[2];
89 SDL_Surface * img_bkgd[2][4];
90 SDL_Surface * img_golden_herring;
91 SDL_Surface * img_bsod_left[4], * img_bsod_right[4],
92 * img_laptop_left[3], * img_laptop_right[3],
93 * img_money_left[2], * img_money_right[2];
94 SDL_Surface * img_bsod_squished_left, * img_bsod_squished_right,
95 * img_bsod_falling_left, * img_bsod_falling_right,
96 * img_laptop_flat_left, * img_laptop_flat_right,
97 * img_laptop_falling_left, * img_laptop_falling_right;
98 SDL_Surface * img_box_full, * img_box_empty, * img_mints, * img_coffee,
99 * img_super_bkgd, * img_bullet, * img_red_glow;
100 SDL_Surface * img_cloud[2][4];
101 SDL_Surface * tux_right[3], * tux_left[3],
102 * bigtux_right[3], * bigtux_left[3],
103 * bigtux_right_jump, * bigtux_left_jump,
104 * cape_right[2], * cape_left[2],
105 * bigcape_right[2], * bigcape_left[2],
106 * ducktux_right, * ducktux_left,
107 * skidtux_right, * skidtux_left;
108 unsigned char * tiles[15];
109 bouncy_distro_type bouncy_distros[NUM_BOUNCY_DISTROS];
110 broken_brick_type broken_bricks[NUM_BROKEN_BRICKS];
111 bouncy_brick_type bouncy_bricks[NUM_BOUNCY_BRICKS];
112 bad_guy_type bad_guys[NUM_BAD_GUYS];
113 floating_score_type floating_scores[NUM_FLOATING_SCORES];
114 upgrade_type upgrades[NUM_UPGRADES];
115 bullet_type bullets[NUM_BULLETS];
120 /* Local function prototypes: */
123 void loadlevel(void);
124 void loadlevelgfx(void);
125 void loadlevelsong(void);
126 void unloadlevelgfx(void);
127 void unloadlevelsong(void);
128 void loadshared(void);
129 void unloadshared(void);
130 void drawshape(int x, int y, unsigned char c);
131 unsigned char shape(int x, int y, int sx);
132 int issolid(int x, int y, int sx);
133 int isbrick(int x, int y, int sx);
134 int isice(int x, int y, int sx);
135 int isfullbox(int x, int y, int sx);
136 void change(int x, int y, int sx, unsigned char c);
137 void trybreakbrick(int x, int y, int sx);
138 void bumpbrick(int x, int y, int sx);
139 void tryemptybox(int x, int y, int sx);
140 void trygrabdistro(int x, int y, int sx, int bounciness);
141 void add_bouncy_distro(int x, int y);
142 void add_broken_brick(int x, int y);
143 void add_broken_brick_piece(int x, int y, int xm, int ym);
144 void add_bouncy_brick(int x, int y);
145 void add_bad_guy(int x, int y, int kind);
146 void add_score(int x, int y, int s);
147 void trybumpbadguy(int x, int y, int sx);
148 void add_upgrade(int x, int y, int kind);
149 void killtux(int mode);
150 void add_bullet(int x, int y, int dir, int xm);
151 void drawendscreen(void);
152 void drawresultscreen(void);
155 /* --- GAME LOOP! --- */
159 int done, quit, x, y, i, j;
163 Uint32 last_time, now_time;
169 clearscreen(0, 0, 0);
180 highscore = load_hs();
183 /* --- MAIN GAME LOOP!!! --- */
193 last_time = SDL_GetTicks();
201 while (SDL_PollEvent(&event))
203 if (event.type == SDL_QUIT)
205 /* Quit event - quit: */
209 else if (event.type == SDL_KEYDOWN)
213 key = event.key.keysym.sym;
215 if (key == SDLK_ESCAPE)
217 /* Escape: Quit the game and return to main menu: */
221 else if (key == SDLK_RIGHT)
225 else if (key == SDLK_LEFT)
229 else if (key == SDLK_UP)
233 else if (key == SDLK_DOWN)
237 else if (key == SDLK_LCTRL)
242 else if (event.type == SDL_KEYUP)
246 key = event.key.keysym.sym;
248 if (key == SDLK_RIGHT)
252 else if (key == SDLK_LEFT)
256 else if (key == SDLK_UP)
260 else if (key == SDLK_DOWN)
264 else if (key == SDLK_LCTRL)
268 else if (key == SDLK_TAB)
270 tux_size = !tux_size;
272 else if (key == SDLK_END)
276 else if (key == SDLK_SPACE)
282 else if (event.type == SDL_JOYAXISMOTION)
284 if (event.jaxis.axis == JOY_X)
286 if (event.jaxis.value < -256)
291 if (event.jaxis.value > 256)
296 else if (event.jaxis.axis == JOY_Y)
298 if (event.jaxis.value > 256)
304 else if (event.type == SDL_JOYBUTTONDOWN)
306 if (event.jbutton.button == JOY_A)
308 else if (event.jbutton.button == JOY_B)
311 else if (event.type == SDL_JOYBUTTONUP)
313 if (event.jbutton.button == JOY_A)
315 else if (event.jbutton.button == JOY_B)
322 /* --- HANDLE TUX! --- */
324 /* Handle key and joystick state: */
326 if (!(tux_dying || next_level))
328 if (right == DOWN && left == UP)
332 if (tux_xm < -SKID_XM && !tux_skidding &&
335 tux_skidding = SKID_TIME;
337 playsound(sounds[SND_SKID]);
343 if (tux_xm < 0 && !isice(tux_x, tux_y + 32, scroll_x) &&
351 if (tux_dir == RIGHT)
353 /* Facing the direction we're jumping? Go full-speed: */
357 tux_xm = tux_xm + WALK_SPEED;
359 if (tux_xm > MAX_WALK_XM)
360 tux_xm = MAX_WALK_XM;
362 else if (fire == DOWN)
364 tux_xm = tux_xm + RUN_SPEED;
366 if (tux_xm > MAX_RUN_XM)
372 /* Not facing the direction we're jumping?
375 tux_xm = tux_xm + WALK_SPEED / 2;
377 if (tux_xm > MAX_WALK_XM / 2)
378 tux_xm = MAX_WALK_XM / 2;
382 else if (left == DOWN && right == UP)
386 if (tux_xm > SKID_XM && !tux_skidding &&
389 tux_skidding = SKID_TIME;
390 playsound(sounds[SND_SKID]);
395 if (tux_xm > 0 && !isice(tux_x, tux_y + 32, scroll_x) &&
405 /* Facing the direction we're jumping? Go full-speed: */
409 tux_xm = tux_xm - WALK_SPEED;
411 if (tux_xm < -MAX_WALK_XM)
412 tux_xm = -MAX_WALK_XM;
414 else if (fire == DOWN)
416 tux_xm = tux_xm - RUN_SPEED;
418 if (tux_xm < -MAX_RUN_XM)
419 tux_xm = -MAX_RUN_XM;
424 /* Not facing the direction we're jumping?
427 tux_xm = tux_xm - WALK_SPEED / 2;
429 if (tux_xm < -MAX_WALK_XM / 2)
430 tux_xm = -MAX_WALK_XM / 2;
438 if (tux_x >= endpos && endpos != 0)
440 /* FIXME: No need to kill Tux to end the level! ;^) */
449 if (jump_counter == 0)
453 if (!issolid(tux_x, tux_y + 32, scroll_x) ||
456 /* If they're not on the ground, or are currently moving
457 vertically, don't jump! */
459 jump_counter = MAX_JUMP_COUNT;
463 /* Make sure we're not standing back up into a solid! */
465 if (tux_size == SMALL || tux_duck == NO ||
466 !issolid(tux_x, tux_y, scroll_x))
470 if (tux_size == SMALL)
471 playsound(sounds[SND_JUMP]);
473 playsound(sounds[SND_BIGJUMP]);
479 /* Keep jumping for a while: */
481 if (jump_counter < MAX_JUMP_COUNT)
483 tux_ym = tux_ym - JUMP_SPEED;
493 if (fire == DOWN && old_fire == UP && tux_got_coffee)
495 add_bullet(tux_x + scroll_x, tux_y, tux_dir, tux_xm);
508 if (tux_size == BIG && tux_duck == YES)
510 /* Make sure we're not standing back up into a solid! */
512 if (!issolid(tux_x, tux_y - 32, scroll_x))
518 } /* (tux_dying || next_level) */
521 /* Tux either died, or reached the end of a level! */
526 if (Mix_PlayingMusic())
533 /* End of a level! */
541 tux_ym = tux_ym + GRAVITY;
549 /* No more lives!? */
555 if (score > highscore)
562 /* Either way, (re-)load the (next) level... */
572 tux_x = tux_x + tux_xm;
573 tux_y = tux_y + tux_ym;
576 /* Keep tux in bounds: */
580 else if (tux_x > 320 && scroll_x < ((level_width * 32) - 640))
582 /* Scroll the screen in past center: */
584 scroll_x = scroll_x + (tux_x - 320);
587 if (scroll_x > ((level_width * 32) - 640))
588 scroll_x = ((level_width * 32) - 640);
590 else if (tux_x > 608)
592 /* ... unless there's no more to scroll! */
602 if (issolid(tux_x, tux_y + 31, scroll_x) &&
603 !issolid(tux_x - tux_xm, tux_y + 31, scroll_x))
605 while (issolid(tux_x, tux_y + 31, scroll_x))
616 if (issolid(tux_x, tux_y, scroll_x) &&
617 !issolid(tux_x - tux_xm, tux_y, scroll_x))
619 while (issolid(tux_x, tux_y, scroll_x))
630 if (issolid(tux_x, tux_y + 31, scroll_x))
632 /* Set down properly: */
634 while (issolid(tux_x, tux_y + 31, scroll_x))
643 /* Reset score multiplier (for mutli-hits): */
646 score_multiplier = 1;
656 /* Bump into things: */
658 if (issolid(tux_x, tux_y, scroll_x) ||
659 (tux_size == BIG && !tux_duck &&
660 (issolid(tux_x, tux_y - 32, scroll_x))))
662 if (!issolid(tux_x - tux_xm, tux_y, scroll_x) &&
663 (tux_size == SMALL || tux_duck ||
664 !issolid(tux_x - tux_xm, tux_y - 32, scroll_x)))
666 tux_x = tux_x - tux_xm;
669 else if (!issolid(tux_x, tux_y - tux_ym, scroll_x) &&
670 (tux_size == SMALL || tux_duck ||
671 !issolid(tux_x, tux_y - 32 - tux_ym, scroll_x)))
679 /* Break bricks and empty boxes: */
683 if (isbrick(tux_x, tux_y - 32, scroll_x) ||
684 isfullbox(tux_x, tux_y - 32, scroll_x))
686 trygrabdistro(tux_x, tux_y - 64, scroll_x,
688 trybumpbadguy(tux_x, tux_y - 96, scroll_x);
690 if (isfullbox(tux_x, tux_y - 32,
693 bumpbrick(tux_x, tux_y - 32,
697 trybreakbrick(tux_x, tux_y - 32, scroll_x);
698 tryemptybox(tux_x, tux_y - 32, scroll_x);
701 if (isbrick(tux_x + 31, tux_y - 32, scroll_x) ||
702 isfullbox(tux_x + 31, tux_y - 32, scroll_x))
704 trygrabdistro(tux_x + 31,
708 trybumpbadguy(tux_x + 31,
712 if (isfullbox(tux_x + 31, tux_y - 32,
715 bumpbrick(tux_x + 31, tux_y - 32,
719 trybreakbrick(tux_x + 31,
722 tryemptybox(tux_x + 31,
729 if (isbrick(tux_x, tux_y, scroll_x) ||
730 isfullbox(tux_x, tux_y, scroll_x))
732 trygrabdistro(tux_x, tux_y - 32, scroll_x,
734 trybumpbadguy(tux_x, tux_y - 64, scroll_x);
735 if (isfullbox(tux_x, tux_y, scroll_x))
736 bumpbrick(tux_x, tux_y, scroll_x);
737 trybreakbrick(tux_x, tux_y, scroll_x);
738 tryemptybox(tux_x, tux_y, scroll_x);
741 if (isbrick(tux_x + 31, tux_y, scroll_x) ||
742 isfullbox(tux_x + 31, tux_y, scroll_x))
744 trygrabdistro(tux_x + 31,
748 trybumpbadguy(tux_x + 31,
751 if (isfullbox(tux_x + 31, tux_y, scroll_x))
752 bumpbrick(tux_x + 31, tux_y, scroll_x);
753 trybreakbrick(tux_x + 31, tux_y, scroll_x);
754 tryemptybox(tux_x + 31, tux_y, scroll_x);
760 /* It's a brick and we're small, make the brick
761 bounce, and grab any distros above it: */
763 if (isbrick(tux_x, tux_y, scroll_x) ||
764 isfullbox(tux_x, tux_y, scroll_x))
766 trygrabdistro(tux_x, tux_y - 32, scroll_x,
768 trybumpbadguy(tux_x, tux_y - 64, scroll_x);
769 bumpbrick(tux_x, tux_y, scroll_x);
770 tryemptybox(tux_x, tux_y, scroll_x);
773 if (isbrick(tux_x + 31, tux_y, scroll_x) ||
774 isfullbox(tux_x + 31, tux_y, scroll_x))
776 trygrabdistro(tux_x + 31, tux_y - 32, scroll_x,
778 trybumpbadguy(tux_x + 31, tux_y - 64, scroll_x);
779 bumpbrick(tux_x + 31, tux_y, scroll_x);
780 tryemptybox(tux_x + 31, tux_y, scroll_x);
784 /* Get a distro from a brick? */
786 if (shape(tux_x, tux_y, scroll_x) == 'x' ||
787 shape(tux_x, tux_y, scroll_x) == 'y')
789 add_bouncy_distro(((tux_x + scroll_x + 1)
793 if (counting_distros == NO)
795 counting_distros = YES;
796 distro_counter = 100;
799 if (distro_counter <= 0)
800 change(tux_x, tux_y, scroll_x, 'a');
802 playsound(sounds[SND_DISTRO]);
803 score = score + SCORE_DISTRO;
806 else if (shape(tux_x + 31, tux_y, scroll_x) == 'x' ||
807 shape(tux_x + 31, tux_y, scroll_x) == 'y')
809 add_bouncy_distro(((tux_x + scroll_x + 1 + 31)
813 if (counting_distros == NO)
815 counting_distros = YES;
816 distro_counter = 100;
819 if (distro_counter <= 0)
820 change(tux_x + 31, tux_y, scroll_x, 'a');
822 playsound(sounds[SND_DISTRO]);
823 score = score + SCORE_DISTRO;
831 tux_y = (tux_y / 32) * 32 + 30;
837 tux_y = (tux_y / 32) * 32 - 32;
842 jump_counter = MAX_JUMP_COUNT;
852 trygrabdistro(tux_x, tux_y, scroll_x, NO_BOUNCE);
853 trygrabdistro(tux_x + 31, tux_y, scroll_x, NO_BOUNCE);
855 if (tux_size == BIG && !tux_duck)
857 trygrabdistro(tux_x, tux_y - 32, scroll_x, NO_BOUNCE);
858 trygrabdistro(tux_x + 31, tux_y - 32, scroll_x, NO_BOUNCE);
863 /* Enough distros for a One-up? */
865 if (distros >= DISTROS_LIFEUP)
867 distros = distros - DISTROS_LIFEUP;
868 if(lives < MAX_LIVES)
870 playsound(sounds[SND_LIFEUP]); /*We want to hear the sound even, if MAX_LIVES is reached*/
874 /* Keep in-bounds, vertically: */
878 else if (tux_y > 480)
884 /* Slow down horizontally: */
888 if (right == UP && left == UP)
890 if (isice(tux_x, tux_y + 32, scroll_x) ||
891 !issolid(tux_x, tux_y + 32, scroll_x))
893 /* Slowly on ice or in air: */
902 /* Quickly, otherwise: */
909 /* Drop vertically: */
911 if (!issolid(tux_x, tux_y + 32, scroll_x))
913 tux_ym = tux_ym + GRAVITY;
925 /* ---- DONE HANDLING TUX! --- */
928 /* Handle bouncy distros: */
930 for (i = 0; i < NUM_BOUNCY_DISTROS; i++)
932 if (bouncy_distros[i].alive)
934 bouncy_distros[i].y = bouncy_distros[i].y + bouncy_distros[i].ym;
936 bouncy_distros[i].ym++;
938 if (bouncy_distros[i].ym >= 0)
939 bouncy_distros[i].alive = NO;
944 /* Handle broken bricks: */
946 for (i = 0; i < NUM_BROKEN_BRICKS; i++)
948 if (broken_bricks[i].alive)
950 broken_bricks[i].x = broken_bricks[i].x + broken_bricks[i].xm;
951 broken_bricks[i].y = broken_bricks[i].y + broken_bricks[i].ym;
953 broken_bricks[i].ym++;
955 if (broken_bricks[i].ym >= 0)
956 broken_bricks[i].alive = NO;
961 /* Handle distro counting: */
963 if (counting_distros == YES)
967 if (distro_counter <= 0)
968 counting_distros = -1;
972 /* Handle bouncy bricks: */
974 for (i = 0; i < NUM_BOUNCY_BRICKS; i++)
976 if (bouncy_bricks[i].alive)
978 bouncy_bricks[i].offset = (bouncy_bricks[i].offset +
979 bouncy_bricks[i].offset_m);
983 if (bouncy_bricks[i].offset < -BOUNCY_BRICK_MAX_OFFSET)
984 bouncy_bricks[i].offset_m = BOUNCY_BRICK_SPEED;
989 if (bouncy_bricks[i].offset == 0)
990 bouncy_bricks[i].alive = NO;
995 /* Handle floating scores: */
997 for (i = 0; i < NUM_FLOATING_SCORES; i++)
999 if (floating_scores[i].alive)
1001 floating_scores[i].y = floating_scores[i].y - 2;
1002 floating_scores[i].timer--;
1004 if (floating_scores[i].timer <= 0)
1005 floating_scores[i].alive = NO;
1010 /* Handle bullets: */
1012 for (i = 0; i < NUM_BULLETS; i++)
1014 if (bullets[i].alive)
1016 bullets[i].x = bullets[i].x + bullets[i].xm;
1017 bullets[i].y = bullets[i].y + bullets[i].ym;
1019 if (issolid(bullets[i].x, bullets[i].y, 0))
1021 if (issolid(bullets[i].x, bullets[i].y - bullets[i].ym, 0))
1022 bullets[i].alive = NO;
1025 if (bullets[i].ym >= 0)
1027 bullets[i].y = (bullets[i].y / 32) * 32 - 8;
1029 bullets[i].ym = -bullets[i].ym;
1033 bullets[i].ym = bullets[i].ym + GRAVITY;
1035 if (bullets[i].x < scroll_x ||
1036 bullets[i].x > scroll_x + 640)
1038 bullets[i].alive = NO;
1043 if (bullets[i].alive)
1045 for (j = 0; j < NUM_BAD_GUYS; j++)
1047 if (bad_guys[j].alive && !bad_guys[j].dying)
1049 if (bullets[i].x >= bad_guys[j].x - 4 &&
1050 bullets[i].x <= bad_guys[j].x + 32 + 4 &&
1051 bullets[i].y >= bad_guys[j].y - 4 &&
1052 bullets[i].y <= bad_guys[j].y + 32 + 4)
1054 /* Kill the bad guy! */
1056 bullets[i].alive = 0;
1057 bad_guys[j].dying = FALLING;
1058 bad_guys[j].ym = -8;
1061 /* Gain some points: */
1063 if (bad_guys[j].kind == BAD_BSOD)
1065 add_score(bad_guys[j].x - scroll_x, bad_guys[j].y,
1066 50 * score_multiplier);
1068 else if (bad_guys[j].kind == BAD_LAPTOP)
1070 add_score(bad_guys[j].x - scroll_x, bad_guys[j].y,
1071 25 * score_multiplier);
1075 /* Play death sound: */
1076 playsound(sounds[SND_FALL]);
1084 /* Handle background timer: */
1086 if (super_bkgd_time)
1090 /* Handle invincibility timer: */
1092 if (tux_invincible_time)
1093 tux_invincible_time--;
1096 /* Handle upgrades: */
1098 for (i = 0; i < NUM_UPGRADES; i++)
1100 if (upgrades[i].alive)
1102 if (upgrades[i].height < 32)
1106 upgrades[i].height++;
1112 if (upgrades[i].kind == UPGRADE_MINTS ||
1113 upgrades[i].kind == UPGRADE_HERRING)
1115 upgrades[i].x = upgrades[i].x + upgrades[i].xm;
1116 upgrades[i].y = upgrades[i].y + upgrades[i].ym;
1118 if (issolid(upgrades[i].x, upgrades[i].y + 31, 0) ||
1119 issolid(upgrades[i].x + 31, upgrades[i].y + 31, 0))
1121 if (upgrades[i].ym > 0)
1123 if (upgrades[i].kind == UPGRADE_MINTS)
1127 else if (upgrades[i].kind == UPGRADE_HERRING)
1129 upgrades[i].ym = -24;
1132 upgrades[i].y = (upgrades[i].y / 32) * 32;
1136 upgrades[i].ym = upgrades[i].ym + GRAVITY;
1138 if (issolid(upgrades[i].x, upgrades[i].y, 0))
1140 upgrades[i].xm = -upgrades[i].xm;
1145 /* Off the screen? Kill it! */
1147 if (upgrades[i].x < scroll_x)
1148 upgrades[i].alive = NO;
1151 /* Did the player grab it? */
1153 if (tux_x + scroll_x >= upgrades[i].x - 32 &&
1154 tux_x + scroll_x <= upgrades[i].x + 32 &&
1155 tux_y >= upgrades[i].y - 32 &&
1156 tux_y <= upgrades[i].y + 32)
1158 /* Remove the upgrade: */
1160 upgrades[i].alive = NO;
1163 /* Affect the player: */
1165 if (upgrades[i].kind == UPGRADE_MINTS)
1167 playsound(sounds[SND_EXCELLENT]);
1169 super_bkgd_time = 8;
1171 else if (upgrades[i].kind == UPGRADE_COFFEE)
1173 playsound(sounds[SND_COFFEE]);
1174 tux_got_coffee = YES;
1175 super_bkgd_time = 4;
1177 else if (upgrades[i].kind == UPGRADE_HERRING)
1179 playsound(sounds[SND_HERRING]);
1180 tux_invincible_time = 200;
1181 super_bkgd_time = 4;
1189 /* Handle bad guys: */
1191 for (i = 0; i < NUM_BAD_GUYS; i++)
1193 if (bad_guys[i].alive)
1195 if (bad_guys[i].seen)
1197 if (bad_guys[i].kind == BAD_BSOD)
1199 /* --- BLUE SCREEN OF DEATH MONSTER: --- */
1201 /* Move left/right: */
1203 if (bad_guys[i].dying == NO ||
1204 bad_guys[i].dying == FALLING)
1206 if (bad_guys[i].dir == RIGHT)
1207 bad_guys[i].x = bad_guys[i].x + 4;
1208 else if (bad_guys[i].dir == LEFT)
1209 bad_guys[i].x = bad_guys[i].x - 4;
1213 /* Move vertically: */
1215 bad_guys[i].y = bad_guys[i].y + bad_guys[i].ym;
1218 /* Bump into things horizontally: */
1220 if (!bad_guys[i].dying)
1222 if (issolid(bad_guys[i].x, bad_guys[i].y, 0))
1223 bad_guys[i].dir = !bad_guys[i].dir;
1227 /* Bump into other bad guys: */
1229 for (j = 0; j < NUM_BAD_GUYS; j++)
1231 if (j != i && bad_guys[j].alive &&
1232 !bad_guys[j].dying && !bad_guys[i].dying &&
1233 bad_guys[i].x >= bad_guys[j].x - 32 &&
1234 bad_guys[i].x <= bad_guys[j].x + 32 &&
1235 bad_guys[i].y >= bad_guys[j].y - 32 &&
1236 bad_guys[i].y <= bad_guys[j].y + 32)
1238 bad_guys[i].dir = !bad_guys[i].dir;
1243 /* Fall if we get off the ground: */
1245 if (bad_guys[i].dying != FALLING)
1247 if (!issolid(bad_guys[i].x, bad_guys[i].y + 32, 0) &&
1248 bad_guys[i].ym < MAX_YM)
1250 bad_guys[i].ym = bad_guys[i].ym + GRAVITY;
1256 if (bad_guys[i].ym > 0)
1258 bad_guys[i].y = (bad_guys[i].y / 32) * 32;
1264 bad_guys[i].ym = bad_guys[i].ym + GRAVITY;
1266 if (bad_guys[i].y > 480)
1267 bad_guys[i].alive = NO;
1269 else if (bad_guys[i].kind == BAD_LAPTOP)
1271 /* --- LAPTOP MONSTER: --- */
1273 /* Move left/right: */
1275 if (bad_guys[i].mode != FLAT && bad_guys[i].mode != KICK)
1277 if (bad_guys[i].dying == NO ||
1278 bad_guys[i].dying == FALLING)
1280 if (bad_guys[i].dir == RIGHT)
1281 bad_guys[i].x = bad_guys[i].x + 4;
1282 else if (bad_guys[i].dir == LEFT)
1283 bad_guys[i].x = bad_guys[i].x - 4;
1286 else if (bad_guys[i].mode == KICK)
1288 if (bad_guys[i].dir == RIGHT)
1289 bad_guys[i].x = bad_guys[i].x + 16;
1290 else if (bad_guys[i].dir == LEFT)
1291 bad_guys[i].x = bad_guys[i].x - 16;
1295 /* Move vertically: */
1297 bad_guys[i].y = bad_guys[i].y + bad_guys[i].ym;
1300 /* Bump into things horizontally: */
1302 if (!bad_guys[i].dying)
1304 if (issolid(bad_guys[i].x, bad_guys[i].y, 0))
1306 bad_guys[i].dir = !bad_guys[i].dir;
1308 if (bad_guys[i].mode == KICK)
1309 playsound(sounds[SND_RICOCHET]);
1314 /* Bump into other bad guys: */
1316 for (j = 0; j < NUM_BAD_GUYS; j++)
1318 if (j != i && bad_guys[j].alive &&
1319 !bad_guys[j].dying && !bad_guys[i].dying &&
1320 bad_guys[i].x >= bad_guys[j].x - 32 &&
1321 bad_guys[i].x <= bad_guys[j].x + 32 &&
1322 bad_guys[i].y >= bad_guys[j].y - 32 &&
1323 bad_guys[i].y <= bad_guys[j].y + 32)
1325 if (bad_guys[i].mode != KICK)
1326 bad_guys[i].dir = !bad_guys[i].dir;
1329 /* We're in kick mode, kill the other guy: */
1331 bad_guys[j].dying = FALLING;
1332 bad_guys[j].ym = -8;
1333 playsound(sounds[SND_FALL]);
1335 add_score(bad_guys[i].x - scroll_x,
1336 bad_guys[i].y, 100);
1342 /* Fall if we get off the ground: */
1344 if (bad_guys[i].dying != FALLING)
1346 if (!issolid(bad_guys[i].x, bad_guys[i].y + 32, 0) &&
1347 bad_guys[i].ym < MAX_YM)
1349 bad_guys[i].ym = bad_guys[i].ym + GRAVITY;
1355 if (bad_guys[i].ym > 0)
1357 bad_guys[i].y = (bad_guys[i].y / 32) * 32;
1363 bad_guys[i].ym = bad_guys[i].ym + GRAVITY;
1365 if (bad_guys[i].y > 480)
1366 bad_guys[i].alive = NO;
1368 else if (bad_guys[i].kind == BAD_MONEY)
1370 /* --- MONEY BAGS: --- */
1373 /* Move vertically: */
1375 bad_guys[i].y = bad_guys[i].y + bad_guys[i].ym;
1378 /* Fall if we get off the ground: */
1380 if (bad_guys[i].dying != FALLING)
1382 if (!issolid(bad_guys[i].x, bad_guys[i].y + 32, 0))
1384 if (bad_guys[i].ym < MAX_YM)
1386 bad_guys[i].ym = bad_guys[i].ym + GRAVITY;
1393 if (bad_guys[i].ym > 0)
1395 bad_guys[i].y = (bad_guys[i].y / 32) * 32;
1396 bad_guys[i].ym = -MAX_YM;
1401 bad_guys[i].ym = bad_guys[i].ym + GRAVITY;
1403 if (bad_guys[i].y > 480)
1404 bad_guys[i].alive = NO;
1406 else if (bad_guys[i].kind == -1)
1411 /* Kill it if the player jumped on it: */
1413 if (!bad_guys[i].dying && !tux_dying && !tux_safe &&
1414 tux_x + scroll_x >= bad_guys[i].x - 32 &&
1415 tux_x + scroll_x <= bad_guys[i].x + 32 &&
1416 tux_y >= bad_guys[i].y - 32 &&
1417 tux_y <= bad_guys[i].y - 8
1421 if (bad_guys[i].kind == BAD_BSOD)
1423 bad_guys[i].dying = SQUISHED;
1424 bad_guys[i].timer = 16;
1425 tux_ym = -KILL_BOUNCE_YM;
1427 add_score(bad_guys[i].x - scroll_x, bad_guys[i].y,
1428 50 * score_multiplier);
1430 playsound(sounds[SND_SQUISH]);
1432 else if (bad_guys[i].kind == BAD_LAPTOP)
1434 if (bad_guys[i].mode != FLAT)
1438 bad_guys[i].mode = FLAT;
1440 bad_guys[i].timer = 64;
1448 bad_guys[i].mode = KICK;
1450 if (tux_x + scroll_x <= bad_guys[i].x)
1451 bad_guys[i].dir = RIGHT;
1453 bad_guys[i].dir = LEFT;
1455 bad_guys[i].timer = 8;
1458 tux_ym = -KILL_BOUNCE_YM;
1460 add_score(bad_guys[i].x - scroll_x,
1462 25 * score_multiplier);
1464 /* playsound(sounds[SND_SQUISH]); */
1466 else if (bad_guys[i].kind == -1)
1474 /* Hurt the player if he just touched it: */
1476 if (!bad_guys[i].dying && !tux_dying &&
1478 tux_x + scroll_x >= bad_guys[i].x - 32 &&
1479 tux_x + scroll_x <= bad_guys[i].x + 32 &&
1480 tux_y >= bad_guys[i].y - 32 &&
1481 tux_y <= bad_guys[i].y + 32)
1483 if (bad_guys[i].mode == FLAT)
1487 bad_guys[i].mode = KICK;
1489 if (tux_x < bad_guys[i].x)
1491 bad_guys[i].dir = RIGHT;
1492 bad_guys[i].x = bad_guys[i].x + 16;
1496 bad_guys[i].dir = LEFT;
1497 bad_guys[i].x = bad_guys[i].x - 16;
1500 bad_guys[i].timer = 8;
1502 else if (bad_guys[i].mode == KICK)
1504 if (tux_y < bad_guys[i].y - 16 &&
1505 bad_guys[i].timer == 0)
1507 /* Step on (stop being kicked) */
1509 bad_guys[i].mode = FLAT;
1510 bad_guys[i].timer = 64;
1514 /* Hurt if you get hit by kicked laptop: */
1516 if (bad_guys[i].timer == 0)
1518 if (tux_invincible_time == 0)
1524 bad_guys[i].dying = FALLING;
1525 bad_guys[i].ym = -8;
1526 playsound(sounds[SND_FALL]);
1533 if (tux_invincible_time == 0)
1539 bad_guys[i].dying = FALLING;
1540 bad_guys[i].ym = -8;
1541 playsound(sounds[SND_FALL]);
1547 /* Handle mode timer: */
1549 if (bad_guys[i].mode == FLAT)
1551 bad_guys[i].timer--;
1553 if (bad_guys[i].timer <= 0)
1554 bad_guys[i].mode = NORMAL;
1556 else if (bad_guys[i].mode == KICK)
1558 if (bad_guys[i].timer > 0)
1559 bad_guys[i].timer--;
1563 /* Handle dying timer: */
1565 if (bad_guys[i].dying == SQUISHED)
1567 bad_guys[i].timer--;
1570 /* Remove it if time's up: */
1572 if (bad_guys[i].timer <= 0)
1573 bad_guys[i].alive = NO;
1577 /* Remove if it's far off the screen: */
1579 if (bad_guys[i].x < scroll_x - OFFSCREEN_DISTANCE)
1580 bad_guys[i].alive = NO;
1584 /* Once it's on screen, it's activated! */
1586 if (bad_guys[i].x <= scroll_x + 640 + OFFSCREEN_DISTANCE)
1587 bad_guys[i].seen = YES;
1593 /* Handle skidding: */
1595 if (tux_skidding > 0)
1603 if (tux_dying && (frame % 4) == 0)
1604 clearscreen(255, 255, 255);
1607 if (super_bkgd_time == 0)
1608 clearscreen(bkgd_red, bkgd_green, bkgd_blue);
1610 drawimage(img_super_bkgd, 0, 0, NO_UPDATE);
1614 /* Draw background: */
1616 for (y = 0; y < 15; y++)
1618 for (x = 0; x < 21; x++)
1620 drawshape(x * 32 - (scroll_x % 32), y * 32,
1621 tiles[y][x + (scroll_x / 32)]);
1626 /* (Bouncy bricks): */
1628 for (i = 0; i < NUM_BOUNCY_BRICKS; i++)
1630 if (bouncy_bricks[i].alive)
1632 if (bouncy_bricks[i].x >= scroll_x - 32 &&
1633 bouncy_bricks[i].x <= scroll_x + 640)
1635 dest.x = bouncy_bricks[i].x - scroll_x;
1636 dest.y = bouncy_bricks[i].y;
1640 SDL_FillRect(screen, &dest, SDL_MapRGB(screen->format,
1645 drawshape(bouncy_bricks[i].x - scroll_x,
1646 bouncy_bricks[i].y + bouncy_bricks[i].offset,
1647 bouncy_bricks[i].shape);
1655 for (i = 0; i < NUM_BAD_GUYS; i++)
1657 if (bad_guys[i].alive &&
1658 bad_guys[i].x > scroll_x - 32 &&
1659 bad_guys[i].x < scroll_x + 640)
1661 if (bad_guys[i].kind == BAD_BSOD)
1663 /* --- BLUE SCREEN OF DEATH MONSTER: --- */
1665 if (bad_guys[i].dying == NO)
1669 if (bad_guys[i].dir == LEFT)
1671 drawimage(img_bsod_left[(frame / 5) % 4],
1672 bad_guys[i].x - scroll_x,
1678 drawimage(img_bsod_right[(frame / 5) % 4],
1679 bad_guys[i].x - scroll_x,
1684 else if (bad_guys[i].dying == FALLING)
1688 if (bad_guys[i].dir == LEFT)
1690 drawimage(img_bsod_falling_left,
1691 bad_guys[i].x - scroll_x,
1697 drawimage(img_bsod_falling_right,
1698 bad_guys[i].x - scroll_x,
1703 else if (bad_guys[i].dying == SQUISHED)
1705 /* Dying - Squished: */
1707 if (bad_guys[i].dir == LEFT)
1709 drawimage(img_bsod_squished_left,
1710 bad_guys[i].x - scroll_x,
1716 drawimage(img_bsod_squished_right,
1717 bad_guys[i].x - scroll_x,
1723 else if (bad_guys[i].kind == BAD_LAPTOP)
1725 /* --- LAPTOP MONSTER: --- */
1727 if (bad_guys[i].dying == NO)
1731 if (bad_guys[i].mode == NORMAL)
1735 if (bad_guys[i].dir == LEFT)
1737 drawimage(img_laptop_left[(frame / 5) % 3],
1738 bad_guys[i].x - scroll_x,
1744 drawimage(img_laptop_right[(frame / 5) % 3],
1745 bad_guys[i].x - scroll_x,
1754 if (bad_guys[i].dir == LEFT)
1756 drawimage(img_laptop_flat_left,
1757 bad_guys[i].x - scroll_x,
1763 drawimage(img_laptop_flat_right,
1764 bad_guys[i].x - scroll_x,
1770 else if (bad_guys[i].dying == FALLING)
1774 if (bad_guys[i].dir == LEFT)
1776 drawimage(img_laptop_falling_left,
1777 bad_guys[i].x - scroll_x,
1783 drawimage(img_laptop_falling_right,
1784 bad_guys[i].x - scroll_x,
1790 else if (bad_guys[i].kind == BAD_MONEY)
1792 if (bad_guys[i].ym > -16)
1794 if (bad_guys[i].dir == LEFT)
1796 drawimage(img_money_left[0],
1797 bad_guys[i].x - scroll_x,
1803 drawimage(img_money_right[0],
1804 bad_guys[i].x - scroll_x,
1811 if (bad_guys[i].dir == LEFT)
1813 drawimage(img_money_left[1],
1814 bad_guys[i].x - scroll_x,
1820 drawimage(img_money_right[1],
1821 bad_guys[i].x - scroll_x,
1827 else if (bad_guys[i].kind == -1)
1836 if (right == UP && left == UP)
1843 if ((fire == DOWN && (frame % 2) == 0) ||
1845 tux_frame_main = (tux_frame_main + 1) % 4;
1847 tux_frame = tux_frame_main;
1854 if (tux_got_coffee && (frame % 2) == 1)
1858 drawimage(img_red_glow, tux_x - 8, tux_y - 32, NO_UPDATE);
1862 if (tux_safe == 0 || (frame % 2) == 0)
1864 if (tux_size == SMALL)
1866 if (tux_invincible_time)
1870 if (tux_dir == RIGHT)
1872 drawimage(cape_right[frame % 2],
1878 drawimage(cape_left[frame % 2],
1885 if (tux_dir == RIGHT)
1887 drawimage(tux_right[tux_frame], tux_x, tux_y, NO_UPDATE);
1891 drawimage(tux_left[tux_frame], tux_x, tux_y, NO_UPDATE);
1896 if (tux_invincible_time)
1900 if (tux_dir == RIGHT)
1902 drawimage(bigcape_right[frame % 2],
1903 tux_x - 8 - 16, tux_y - 32,
1908 drawimage(bigcape_left[frame % 2],
1909 tux_x - 8, tux_y - 32,
1918 if (!jumping || tux_ym > 0)
1920 if (tux_dir == RIGHT)
1922 drawimage(bigtux_right[tux_frame],
1923 tux_x - 8, tux_y - 32,
1928 drawimage(bigtux_left[tux_frame],
1929 tux_x - 8, tux_y - 32,
1935 if (tux_dir == RIGHT)
1937 drawimage(bigtux_right_jump,
1938 tux_x - 8, tux_y - 32,
1943 drawimage(bigtux_left_jump,
1944 tux_x - 8, tux_y - 32,
1951 if (tux_dir == RIGHT)
1953 drawimage(skidtux_right,
1954 tux_x - 8, tux_y - 32,
1959 drawimage(skidtux_left,
1960 tux_x - 8, tux_y - 32,
1967 if (tux_dir == RIGHT)
1969 drawimage(ducktux_right, tux_x - 8, tux_y - 16,
1974 drawimage(ducktux_left, tux_x - 8, tux_y - 16,
1984 for (i = 0; i < NUM_BULLETS; i++)
1986 if (bullets[i].alive &&
1987 bullets[i].x >= scroll_x - 4 &&
1988 bullets[i].x <= scroll_x + 640)
1990 drawimage(img_bullet, bullets[i].x - scroll_x, bullets[i].y,
1996 /* (Floating scores): */
1998 for (i = 0; i < NUM_FLOATING_SCORES; i++)
2000 if (floating_scores[i].alive)
2002 sprintf(str, "%d", floating_scores[i].value);
2004 floating_scores[i].x + 16 - strlen(str) * 8,
2005 floating_scores[i].y,
2006 letters_gold, NO_UPDATE);
2013 for (i = 0; i < NUM_UPGRADES; i++)
2015 if (upgrades[i].alive)
2017 if (upgrades[i].height < 32)
2021 dest.x = upgrades[i].x - scroll_x;
2022 dest.y = upgrades[i].y + 32 - upgrades[i].height;
2024 dest.h = upgrades[i].height;
2029 src.h = upgrades[i].height;
2031 if (upgrades[i].kind == UPGRADE_MINTS)
2032 SDL_BlitSurface(img_mints, &src, screen, &dest);
2033 else if (upgrades[i].kind == UPGRADE_COFFEE)
2034 SDL_BlitSurface(img_coffee, &src, screen, &dest);
2035 else if (upgrades[i].kind == UPGRADE_HERRING)
2036 SDL_BlitSurface(img_golden_herring, &src, screen, &dest);
2040 if (upgrades[i].kind == UPGRADE_MINTS)
2042 drawimage(img_mints,
2043 upgrades[i].x - scroll_x, upgrades[i].y,
2046 else if (upgrades[i].kind == UPGRADE_COFFEE)
2048 drawimage(img_coffee,
2049 upgrades[i].x - scroll_x, upgrades[i].y,
2052 else if (upgrades[i].kind == UPGRADE_HERRING)
2054 drawimage(img_golden_herring,
2055 upgrades[i].x - scroll_x, upgrades[i].y,
2063 /* (Bouncy distros): */
2065 for (i = 0; i < NUM_BOUNCY_DISTROS; i++)
2067 if (bouncy_distros[i].alive)
2069 drawimage(img_distro[0],
2070 bouncy_distros[i].x - scroll_x,
2071 bouncy_distros[i].y,
2077 /* (Broken bricks): */
2079 for (i = 0; i < NUM_BROKEN_BRICKS; i++)
2081 if (broken_bricks[i].alive)
2083 src.x = rand() % 16;
2084 src.y = rand() % 16;
2088 dest.x = broken_bricks[i].x - scroll_x;
2089 dest.y = broken_bricks[i].y;
2093 SDL_BlitSurface(img_brick[0], &src, screen, &dest);
2100 sprintf(str, "%d", score);
2101 drawtext("SCORE", 0, 0, letters_blue, NO_UPDATE);
2102 drawtext(str, 96, 0, letters_gold, NO_UPDATE);
2104 sprintf(str, "%d", highscore);
2105 drawtext("HIGH", 0, 20, letters_blue, NO_UPDATE);
2106 drawtext(str, 96, 20, letters_gold, NO_UPDATE);
2108 if (time_left >= 50 || (frame % 10) < 5)
2110 sprintf(str, "%d", time_left);
2111 drawtext("TIME", 224, 0, letters_blue, NO_UPDATE);
2112 drawtext(str, 304, 0, letters_gold, NO_UPDATE);
2115 sprintf(str, "%d", distros);
2116 drawtext("DISTROS", 480, 0, letters_blue, NO_UPDATE);
2117 drawtext(str, 608, 0, letters_gold, NO_UPDATE);
2120 /* (Update it all!) */
2125 /* Keep playing music: */
2129 if (!Mix_PlayingMusic())
2131 Mix_PlayMusic(song, 1);
2136 /* Pause til next frame: */
2138 now_time = SDL_GetTicks();
2139 if (now_time < last_time + FPS)
2140 SDL_Delay(last_time + FPS - now_time);
2145 if ((frame % 10) == 0 && time_left > 0)
2153 while (!done && !quit);
2157 if (Mix_PlayingMusic())
2169 /* Initialize the game stuff: */
2180 /* Load data for this level: */
2182 void loadlevel(void)
2193 for (i = 0; i < NUM_BOUNCY_DISTROS; i++)
2194 bouncy_distros[i].alive = NO;
2196 for (i = 0; i < NUM_BROKEN_BRICKS; i++)
2197 broken_bricks[i].alive = NO;
2199 for (i = 0; i < NUM_BOUNCY_BRICKS; i++)
2200 bouncy_bricks[i].alive = NO;
2202 for (i = 0; i < NUM_BAD_GUYS; i++)
2203 bad_guys[i].alive = NO;
2205 for (i = 0; i < NUM_FLOATING_SCORES; i++)
2206 floating_scores[i].alive = NO;
2208 for (i = 0; i < NUM_UPGRADES; i++)
2209 upgrades[i].alive = NO;
2211 for (i = 0; i < NUM_BULLETS; i++)
2212 bullets[i].alive = NO;
2215 /* Load data file: */
2217 filename = (char *) malloc(sizeof(char) * (strlen(DATA_PREFIX) + 20));
2218 sprintf(filename, "%s/levels/level%d.dat", DATA_PREFIX, level);
2219 fi = fopen(filename, "r");
2228 /* Load header info: */
2232 strcpy(levelname, str);
2236 strcpy(leveltheme, str);
2237 leveltheme[strlen(leveltheme)-1] = '\0';
2239 /* (Time to beat level) */
2241 time_left = atoi(str);
2243 /* (Song file for this level) */
2245 strcpy(song_title, str);
2247 /* (Level background color) */
2249 bkgd_red = atoi(str);
2251 bkgd_green= atoi(str);
2253 bkgd_blue = atoi(str);
2257 level_width = atoi(str);
2260 /* Allocate some space for the line-reading! */
2262 line = (char *) malloc(sizeof(char) * (level_width + 5));
2265 fprintf(stderr, "Couldn't allocate space to load level data!");
2270 /* Load the level lines: */
2272 for (y = 0; y < 15; y++)
2274 fgets(line, level_width + 5, fi);
2275 line[strlen(line) - 1] = '\0';
2276 tiles[y] = strdup(line);
2282 /* Activate bad guys: */
2284 for (y = 0; y < 15; y++)
2286 for (x = 0; x < level_width; x++)
2288 if (tiles[y][x] >= '0' && tiles[y][x] <= '9')
2290 add_bad_guy(x * 32, y * 32, tiles[y][x] - '0');
2305 tux_got_coffee = NO;
2306 tux_invincible_time = 0;
2310 tux_safe = TUX_SAFE_TIME;
2326 score_multiplier = 1;
2327 super_bkgd_time = 0;
2331 counting_distros = NO;
2337 clearscreen(0, 0, 0);
2339 sprintf(str, "LEVEL %d", level);
2340 drawcenteredtext(str, 200, letters_red, NO_UPDATE);
2342 sprintf(str, "%s", levelname);
2343 drawcenteredtext(str, 224, letters_gold, NO_UPDATE);
2345 sprintf(str, "TUX x %d", lives);
2346 drawcenteredtext(str, 256, letters_blue, NO_UPDATE);
2354 /* Load a level-specific graphic... */
2356 SDL_Surface * load_level_image(char * file, int use_alpha)
2360 snprintf(fname, 1024, "%s/images/%s/%s", DATA_PREFIX, leveltheme, file);
2362 return(load_image(fname, use_alpha));
2366 /* Load graphics: */
2368 void loadlevelgfx(void)
2370 img_brick[0] = load_level_image("brick0.png", IGNORE_ALPHA);
2371 img_brick[1] = load_level_image("brick1.png", IGNORE_ALPHA);
2373 img_solid[0] = load_level_image("solid0.png", USE_ALPHA);
2374 img_solid[1] = load_level_image("solid1.png", USE_ALPHA);
2375 img_solid[2] = load_level_image("solid2.png", USE_ALPHA);
2376 img_solid[3] = load_level_image("solid3.png", USE_ALPHA);
2378 img_bkgd[0][0] = load_level_image("bkgd-00.png", USE_ALPHA);
2379 img_bkgd[0][1] = load_level_image("bkgd-01.png", USE_ALPHA);
2380 img_bkgd[0][2] = load_level_image("bkgd-02.png", USE_ALPHA);
2381 img_bkgd[0][3] = load_level_image("bkgd-03.png", USE_ALPHA);
2383 img_bkgd[1][0] = load_level_image("bkgd-10.png", USE_ALPHA);
2384 img_bkgd[1][1] = load_level_image("bkgd-11.png", USE_ALPHA);
2385 img_bkgd[1][2] = load_level_image("bkgd-12.png", USE_ALPHA);
2386 img_bkgd[1][3] = load_level_image("bkgd-13.png", USE_ALPHA);
2392 void loadlevelsong(void)
2397 song_path = (char *) malloc(sizeof(char) * (strlen(DATA_PREFIX) +
2398 strlen(song_title) + 8));
2400 sprintf(song_path, "%s/music/%s", DATA_PREFIX, song_title);
2402 song = load_song(DATA_PREFIX "/music/ji_turn.it");
2408 /* Free graphics data for this level: */
2410 void unloadlevelgfx(void)
2414 for (i = 0; i < 2; i++)
2416 SDL_FreeSurface(img_brick[i]);
2418 for (i = 0; i < 4; i++)
2420 SDL_FreeSurface(img_solid[i]);
2421 SDL_FreeSurface(img_bkgd[0][i]);
2422 SDL_FreeSurface(img_bkgd[1][i]);
2427 /* Free music data for this level: */
2429 void unloadlevelsong(void)
2433 Mix_FreeMusic(song);
2438 /* Load graphics shared between all levels: */
2440 void loadshared(void)
2447 tux_right[0] = load_image(DATA_PREFIX "/images/shared/tux-right-0.png",
2450 tux_right[1] = load_image(DATA_PREFIX "/images/shared/tux-right-1.png",
2453 tux_right[2] = load_image(DATA_PREFIX "/images/shared/tux-right-2.png",
2456 tux_left[0] = load_image(DATA_PREFIX "/images/shared/tux-left-0.png",
2459 tux_left[1] = load_image(DATA_PREFIX "/images/shared/tux-left-1.png",
2462 tux_left[2] = load_image(DATA_PREFIX "/images/shared/tux-left-2.png",
2465 cape_right[0] = load_image(DATA_PREFIX "/images/shared/cape-right-0.png",
2468 cape_right[1] = load_image(DATA_PREFIX "/images/shared/cape-right-1.png",
2471 cape_left[0] = load_image(DATA_PREFIX "/images/shared/cape-left-0.png",
2474 cape_left[1] = load_image(DATA_PREFIX "/images/shared/cape-left-1.png",
2477 bigtux_right[0] = load_image(DATA_PREFIX "/images/shared/bigtux-right-0.png",
2480 bigtux_right[1] = load_image(DATA_PREFIX "/images/shared/bigtux-right-1.png",
2483 bigtux_right[2] = load_image(DATA_PREFIX "/images/shared/bigtux-right-2.png",
2487 load_image(DATA_PREFIX "/images/shared/bigtux-right-jump.png", USE_ALPHA);
2489 bigtux_left[0] = load_image(DATA_PREFIX "/images/shared/bigtux-left-0.png",
2492 bigtux_left[1] = load_image(DATA_PREFIX "/images/shared/bigtux-left-1.png",
2495 bigtux_left[2] = load_image(DATA_PREFIX "/images/shared/bigtux-left-2.png",
2499 load_image(DATA_PREFIX "/images/shared/bigtux-left-jump.png", USE_ALPHA);
2502 load_image(DATA_PREFIX "/images/shared/bigcape-right-0.png",
2506 load_image(DATA_PREFIX "/images/shared/bigcape-right-1.png",
2510 load_image(DATA_PREFIX "/images/shared/bigcape-left-0.png",
2514 load_image(DATA_PREFIX "/images/shared/bigcape-left-1.png",
2517 ducktux_right = load_image(DATA_PREFIX
2518 "/images/shared/ducktux-right.png",
2521 ducktux_left = load_image(DATA_PREFIX
2522 "/images/shared/ducktux-left.png",
2525 skidtux_right = load_image(DATA_PREFIX
2526 "/images/shared/skidtux-right.png",
2529 skidtux_left = load_image(DATA_PREFIX
2530 "/images/shared/skidtux-left.png",
2536 img_box_full = load_image(DATA_PREFIX "/images/shared/box-full.png",
2538 img_box_empty = load_image(DATA_PREFIX "/images/shared/box-empty.png",
2545 img_water = load_image(DATA_PREFIX "/images/shared/water.png", IGNORE_ALPHA);
2547 img_waves[0] = load_image(DATA_PREFIX "/images/shared/waves-0.png",
2550 img_waves[1] = load_image(DATA_PREFIX "/images/shared/waves-1.png",
2553 img_waves[2] = load_image(DATA_PREFIX "/images/shared/waves-2.png",
2559 img_pole = load_image(DATA_PREFIX "/images/shared/pole.png", USE_ALPHA);
2560 img_poletop = load_image(DATA_PREFIX "/images/shared/poletop.png",
2566 img_flag[0] = load_image(DATA_PREFIX "/images/shared/flag-0.png",
2568 img_flag[1] = load_image(DATA_PREFIX "/images/shared/flag-1.png",
2574 img_cloud[0][0] = load_image(DATA_PREFIX "/images/shared/cloud-00.png",
2577 img_cloud[0][1] = load_image(DATA_PREFIX "/images/shared/cloud-01.png",
2580 img_cloud[0][2] = load_image(DATA_PREFIX "/images/shared/cloud-02.png",
2583 img_cloud[0][3] = load_image(DATA_PREFIX "/images/shared/cloud-03.png",
2587 img_cloud[1][0] = load_image(DATA_PREFIX "/images/shared/cloud-10.png",
2590 img_cloud[1][1] = load_image(DATA_PREFIX "/images/shared/cloud-11.png",
2593 img_cloud[1][2] = load_image(DATA_PREFIX "/images/shared/cloud-12.png",
2596 img_cloud[1][3] = load_image(DATA_PREFIX "/images/shared/cloud-13.png",
2604 img_bsod_left[0] = load_image(DATA_PREFIX
2605 "/images/shared/bsod-left-0.png",
2608 img_bsod_left[1] = load_image(DATA_PREFIX
2609 "/images/shared/bsod-left-1.png",
2612 img_bsod_left[2] = load_image(DATA_PREFIX
2613 "/images/shared/bsod-left-2.png",
2616 img_bsod_left[3] = load_image(DATA_PREFIX
2617 "/images/shared/bsod-left-3.png",
2620 img_bsod_right[0] = load_image(DATA_PREFIX
2621 "/images/shared/bsod-right-0.png",
2624 img_bsod_right[1] = load_image(DATA_PREFIX
2625 "/images/shared/bsod-right-1.png",
2628 img_bsod_right[2] = load_image(DATA_PREFIX
2629 "/images/shared/bsod-right-2.png",
2632 img_bsod_right[3] = load_image(DATA_PREFIX
2633 "/images/shared/bsod-right-3.png",
2636 img_bsod_squished_left = load_image(DATA_PREFIX
2637 "/images/shared/bsod-squished-left.png",
2640 img_bsod_squished_right = load_image(DATA_PREFIX
2641 "/images/shared/bsod-squished-right.png",
2644 img_bsod_falling_left = load_image(DATA_PREFIX
2645 "/images/shared/bsod-falling-left.png",
2648 img_bsod_falling_right = load_image(DATA_PREFIX
2649 "/images/shared/bsod-falling-right.png",
2655 img_laptop_left[0] = load_image(DATA_PREFIX
2656 "/images/shared/laptop-left-0.png",
2659 img_laptop_left[1] = load_image(DATA_PREFIX
2660 "/images/shared/laptop-left-1.png",
2663 img_laptop_left[2] = load_image(DATA_PREFIX
2664 "/images/shared/laptop-left-2.png",
2667 img_laptop_right[0] = load_image(DATA_PREFIX
2668 "/images/shared/laptop-right-0.png",
2671 img_laptop_right[1] = load_image(DATA_PREFIX
2672 "/images/shared/laptop-right-1.png",
2675 img_laptop_right[2] = load_image(DATA_PREFIX
2676 "/images/shared/laptop-right-2.png",
2679 img_laptop_flat_left = load_image(DATA_PREFIX
2680 "/images/shared/laptop-flat-left.png",
2683 img_laptop_flat_right = load_image(DATA_PREFIX
2684 "/images/shared/laptop-flat-right.png",
2687 img_laptop_falling_left =
2688 load_image(DATA_PREFIX
2689 "/images/shared/laptop-falling-left.png",
2692 img_laptop_falling_right =
2693 load_image(DATA_PREFIX
2694 "/images/shared/laptop-falling-right.png",
2700 img_money_left[0] = load_image(DATA_PREFIX
2701 "/images/shared/bag-left-0.png",
2704 img_money_left[1] = load_image(DATA_PREFIX
2705 "/images/shared/bag-left-1.png",
2708 img_money_right[0] = load_image(DATA_PREFIX
2709 "/images/shared/bag-right-0.png",
2712 img_money_right[1] = load_image(DATA_PREFIX
2713 "/images/shared/bag-right-1.png",
2720 img_mints = load_image(DATA_PREFIX "/images/shared/mints.png", USE_ALPHA);
2721 img_coffee = load_image(DATA_PREFIX "/images/shared/coffee.png", USE_ALPHA);
2726 img_bullet = load_image(DATA_PREFIX "/images/shared/bullet.png", USE_ALPHA);
2728 img_red_glow = load_image(DATA_PREFIX "/images/shared/red-glow.png",
2734 img_distro[0] = load_image(DATA_PREFIX "/images/shared/distro-0.png",
2737 img_distro[1] = load_image(DATA_PREFIX "/images/shared/distro-1.png",
2740 img_distro[2] = load_image(DATA_PREFIX "/images/shared/distro-2.png",
2743 img_distro[3] = load_image(DATA_PREFIX "/images/shared/distro-3.png",
2749 img_golden_herring =
2750 load_image(DATA_PREFIX "/images/shared/golden-herring.png",
2754 /* Super background: */
2756 img_super_bkgd = load_image(DATA_PREFIX "/images/shared/super-bkgd.png",
2760 /* Sound effects: */
2764 for (i = 0; i < NUM_SOUNDS; i++)
2765 sounds[i] = load_sound(soundfilenames[i]);
2771 /* Free shared data: */
2773 void unloadshared(void)
2777 for (i = 0; i < 3; i++)
2779 SDL_FreeSurface(tux_right[i]);
2780 SDL_FreeSurface(tux_left[i]);
2781 SDL_FreeSurface(bigtux_right[i]);
2782 SDL_FreeSurface(bigtux_left[i]);
2785 SDL_FreeSurface(bigtux_right_jump);
2786 SDL_FreeSurface(bigtux_left_jump);
2788 for (i = 0; i < 2; i++)
2790 SDL_FreeSurface(cape_right[i]);
2791 SDL_FreeSurface(cape_left[i]);
2792 SDL_FreeSurface(bigcape_right[i]);
2793 SDL_FreeSurface(bigcape_left[i]);
2796 SDL_FreeSurface(ducktux_left);
2797 SDL_FreeSurface(ducktux_right);
2799 SDL_FreeSurface(skidtux_left);
2800 SDL_FreeSurface(skidtux_right);
2802 for (i = 0; i < 4; i++)
2804 SDL_FreeSurface(img_bsod_left[i]);
2805 SDL_FreeSurface(img_bsod_right[i]);
2808 SDL_FreeSurface(img_bsod_squished_left);
2809 SDL_FreeSurface(img_bsod_squished_right);
2811 SDL_FreeSurface(img_bsod_falling_left);
2812 SDL_FreeSurface(img_bsod_falling_right);
2814 for (i = 0; i < 3; i++)
2816 SDL_FreeSurface(img_laptop_left[i]);
2817 SDL_FreeSurface(img_laptop_right[i]);
2820 SDL_FreeSurface(img_laptop_flat_left);
2821 SDL_FreeSurface(img_laptop_flat_right);
2823 SDL_FreeSurface(img_laptop_falling_left);
2824 SDL_FreeSurface(img_laptop_falling_right);
2826 for (i = 0; i < 2; i++)
2828 SDL_FreeSurface(img_money_left[i]);
2829 SDL_FreeSurface(img_money_right[i]);
2832 SDL_FreeSurface(img_box_full);
2833 SDL_FreeSurface(img_box_empty);
2835 SDL_FreeSurface(img_water);
2836 for (i = 0; i < 3; i++)
2837 SDL_FreeSurface(img_waves[i]);
2839 SDL_FreeSurface(img_pole);
2840 SDL_FreeSurface(img_poletop);
2842 for (i = 0; i < 2; i++)
2843 SDL_FreeSurface(img_flag[i]);
2845 SDL_FreeSurface(img_mints);
2846 SDL_FreeSurface(img_coffee);
2848 for (i = 0; i < 4; i++)
2850 SDL_FreeSurface(img_distro[i]);
2851 SDL_FreeSurface(img_cloud[0][i]);
2852 SDL_FreeSurface(img_cloud[1][i]);
2855 SDL_FreeSurface(img_golden_herring);
2859 for (i = 0; i < NUM_SOUNDS; i++)
2860 Mix_FreeChunk(sounds[i]);
2865 /* Draw a tile on the screen: */
2867 void drawshape(int x, int y, unsigned char c)
2871 if (c == 'X' || c == 'x')
2872 drawimage(img_brick[0], x, y, NO_UPDATE);
2873 else if (c == 'Y' || c == 'y')
2874 drawimage(img_brick[1], x, y, NO_UPDATE);
2875 else if (c == 'A' || c =='B' || c == '!')
2876 drawimage(img_box_full, x, y, NO_UPDATE);
2878 drawimage(img_box_empty, x, y, NO_UPDATE);
2879 else if (c >= 'C' && c <= 'F')
2880 drawimage(img_cloud[0][c - 'C'], x, y, NO_UPDATE);
2881 else if (c >= 'c' && c <= 'f')
2882 drawimage(img_cloud[1][c - 'c'], x, y, NO_UPDATE);
2883 else if (c >= 'G' && c <= 'J')
2884 drawimage(img_bkgd[0][c - 'G'], x, y, NO_UPDATE);
2885 else if (c >= 'g' && c <= 'j')
2886 drawimage(img_bkgd[1][c - 'g'], x, y, NO_UPDATE);
2888 drawimage(img_solid[0], x, y, NO_UPDATE);
2890 drawimage(img_solid[1], x, y, NO_UPDATE);
2892 drawimage(img_solid[2], x, y, NO_UPDATE);
2894 drawimage(img_solid[3], x, y, NO_UPDATE);
2897 z = (frame / 2) % 6;
2900 drawimage(img_distro[z], x, y, NO_UPDATE);
2902 drawimage(img_distro[2], x, y, NO_UPDATE);
2904 drawimage(img_distro[1], x, y, NO_UPDATE);
2908 z = (frame / 3) % 3;
2910 drawimage(img_waves[z], x, y, NO_UPDATE);
2913 drawimage(img_poletop, x, y, NO_UPDATE);
2916 drawimage(img_pole, x, y, NO_UPDATE);
2918 /* Mark this as the end position of the level! */
2924 z = (frame / 3) % 2;
2926 drawimage(img_flag[z], x + 16, y, NO_UPDATE);
2929 drawimage(img_water, x, y, NO_UPDATE);
2933 /* What shape is at some position? */
2935 unsigned char shape(int x, int y, int sx)
2941 xx = ((x + sx) / 32);
2943 if (yy >= 0 && yy <= 15 && xx >= 0 && xx <= level_width)
2954 int issolid(int x, int y, int sx)
2960 if (isbrick(x, y, sx) ||
2961 isbrick(x + 31, y, sx) ||
2963 isice(x + 31, y, sx) ||
2964 (shape(x, y, sx) == '[' ||
2965 shape(x + 31, y, sx) == '[') ||
2966 (shape(x, y, sx) == '=' ||
2967 shape(x + 31, y, sx) == '=') ||
2968 (shape(x, y, sx) == ']' ||
2969 shape(x + 31, y, sx) == ']') ||
2970 (shape(x, y, sx) == 'A' ||
2971 shape(x + 31, y, sx) == 'A') ||
2972 (shape(x, y, sx) == 'B' ||
2973 shape(x + 31, y, sx) == 'B') ||
2974 (shape(x, y, sx) == '!' ||
2975 shape(x + 31, y, sx) == '!') ||
2976 (shape(x, y, sx) == 'a' ||
2977 shape(x + 31, y, sx) == 'a'))
2986 /* Is it a brick? */
2988 int isbrick(int x, int y, int sx)
2994 if (shape(x, y, sx) == 'X' ||
2995 shape(x, y, sx) == 'x' ||
2996 shape(x, y, sx) == 'Y' ||
2997 shape(x, y, sx) == 'y')
3008 int isice(int x, int y, int sx)
3014 if (shape(x, y, sx) == '#')
3023 /* Is it a full box? */
3025 int isfullbox(int x, int y, int sx)
3031 if (shape(x, y, sx) == 'A' ||
3032 shape(x, y, sx) == 'B' ||
3033 shape(x, y, sx) == '!')
3042 /* Edit a piece of the map! */
3044 void change(int x, int y, int sx, unsigned char c)
3049 xx = ((x + sx) / 32);
3051 if (yy >= 0 && yy <= 15 && xx >= 0 && xx <= level_width)
3056 /* Break a brick: */
3058 void trybreakbrick(int x, int y, int sx)
3060 if (isbrick(x, y, sx))
3062 if (shape(x, y, sx) == 'x' || shape(x, y, sx) == 'y')
3064 /* Get a distro from it: */
3066 add_bouncy_distro(((x + sx + 1) / 32) * 32,
3069 if (counting_distros == NO)
3071 counting_distros = YES;
3072 distro_counter = 50;
3075 if (distro_counter <= 0)
3076 change(x, y, sx, 'a');
3078 playsound(sounds[SND_DISTRO]);
3079 score = score + SCORE_DISTRO;
3084 /* Get rid of it: */
3086 change(x, y, sx, '.');
3090 /* Replace it with broken bits: */
3092 add_broken_brick(((x + sx + 1) / 32) * 32,
3096 /* Get some score: */
3098 playsound(sounds[SND_BRICK]);
3099 score = score + SCORE_BRICK;
3104 /* Bounce a brick: */
3106 void bumpbrick(int x, int y, int sx)
3108 add_bouncy_brick(((x + sx + 1) / 32) * 32,
3111 playsound(sounds[SND_BRICK]);
3117 void tryemptybox(int x, int y, int sx)
3119 if (isfullbox(x, y, sx))
3121 if (shape(x, y, sx) == 'A')
3123 /* Box with a distro! */
3125 add_bouncy_distro(((x + sx + 1) / 32) * 32,
3126 (y / 32) * 32 - 32);
3128 playsound(sounds[SND_DISTRO]);
3129 score = score + SCORE_DISTRO;
3132 else if (shape(x, y, sx) == 'B')
3134 /* Add an upgrade! */
3136 if (tux_size == SMALL)
3138 /* Tux is small, add mints! */
3140 add_upgrade(((x + sx + 1) / 32) * 32,
3146 /* Tux is big, add coffee: */
3148 add_upgrade(((x + sx + 1) / 32) * 32,
3153 playsound(sounds[SND_UPGRADE]);
3155 else if (shape(x, y, sx) == '!')
3157 /* Add a golden herring */
3159 add_upgrade(((x + sx + 1) / 32) * 32,
3164 /* Empty the box: */
3166 change(x, y, sx, 'a');
3171 /* Try to grab a distro: */
3173 void trygrabdistro(int x, int y, int sx, int bounciness)
3175 if (shape(x, y, sx) == '$')
3177 change(x, y, sx, '.');
3178 playsound(sounds[SND_DISTRO]);
3180 if (bounciness == BOUNCE)
3182 add_bouncy_distro(((x + sx + 1) / 32) * 32,
3186 score = score + SCORE_DISTRO;
3192 /* Add a bouncy distro: */
3194 void add_bouncy_distro(int x, int y)
3200 for (i = 0; i < NUM_BOUNCY_DISTROS && found == -1; i++)
3202 if (!bouncy_distros[i].alive)
3208 bouncy_distros[found].alive = YES;
3209 bouncy_distros[found].x = x;
3210 bouncy_distros[found].y = y;
3211 bouncy_distros[found].ym = -6;
3216 /* Add broken brick pieces: */
3218 void add_broken_brick(int x, int y)
3220 add_broken_brick_piece(x, y, -4, -16);
3221 add_broken_brick_piece(x, y + 16, -6, -12);
3223 add_broken_brick_piece(x + 16, y, 4, -16);
3224 add_broken_brick_piece(x + 16, y + 16, 6, -12);
3228 /* Add a broken brick piece: */
3230 void add_broken_brick_piece(int x, int y, int xm, int ym)
3236 for (i = 0; i < NUM_BROKEN_BRICKS && found == -1; i++)
3238 if (!broken_bricks[i].alive)
3244 broken_bricks[found].alive = YES;
3245 broken_bricks[found].x = x;
3246 broken_bricks[found].y = y;
3247 broken_bricks[found].xm = xm;
3248 broken_bricks[found].ym = ym;
3253 /* Add a bouncy brick piece: */
3255 void add_bouncy_brick(int x, int y)
3261 for (i = 0; i < NUM_BOUNCY_BRICKS && found == -1; i++)
3263 if (!bouncy_bricks[i].alive)
3269 bouncy_bricks[found].alive = YES;
3270 bouncy_bricks[found].x = x;
3271 bouncy_bricks[found].y = y;
3272 bouncy_bricks[found].offset = 0;
3273 bouncy_bricks[found].offset_m = -BOUNCY_BRICK_SPEED;
3274 bouncy_bricks[found].shape = shape(x, y, 0);
3279 /* Add a bad guy: */
3281 void add_bad_guy(int x, int y, int kind)
3287 for (i = 0; i < NUM_BAD_GUYS && found == -1; i++)
3289 if (!bad_guys[i].alive)
3295 bad_guys[found].alive = YES;
3296 bad_guys[found].mode = NORMAL;
3297 bad_guys[found].dying = NO;
3298 bad_guys[found].timer = 0;
3299 bad_guys[found].kind = kind;
3300 bad_guys[found].x = x;
3301 bad_guys[found].y = y;
3302 bad_guys[found].xm = 0;
3303 bad_guys[found].ym = 0;
3304 bad_guys[found].dir = LEFT;
3305 bad_guys[found].seen = NO;
3312 void add_score(int x, int y, int s)
3317 /* Add the score: */
3322 /* Add a floating score thing to the game: */
3326 for (i = 0; i < NUM_FLOATING_SCORES && found == -1; i++)
3328 if (!floating_scores[i].alive)
3335 floating_scores[found].alive = YES;
3336 floating_scores[found].x = x;
3337 floating_scores[found].y = y - 16;
3338 floating_scores[found].timer = 8;
3339 floating_scores[found].value = s;
3344 /* Try to bump a bad guy from below: */
3346 void trybumpbadguy(int x, int y, int sx)
3353 for (i = 0; i < NUM_BAD_GUYS; i++)
3355 if (bad_guys[i].alive &&
3356 bad_guys[i].x >= x + sx - 32 && bad_guys[i].x <= x + sx + 32 &&
3357 bad_guys[i].y >= y - 16 && bad_guys[i].y <= y + 16)
3359 if (bad_guys[i].kind == BAD_BSOD ||
3360 bad_guys[i].kind == BAD_LAPTOP)
3362 bad_guys[i].dying = FALLING;
3363 bad_guys[i].ym = -8;
3364 playsound(sounds[SND_FALL]);
3372 for (i = 0; i < NUM_UPGRADES; i++)
3374 if (upgrades[i].alive && upgrades[i].height == 32 &&
3375 upgrades[i].x >= x + sx - 32 && upgrades[i].x <= x + sx + 32 &&
3376 upgrades[i].y >= y - 16 && upgrades[i].y <= y + 16)
3378 upgrades[i].xm = -upgrades[i].xm;
3379 upgrades[i].ym = -8;
3380 playsound(sounds[SND_BUMP_UPGRADE]);
3386 /* Add an upgrade: */
3388 void add_upgrade(int x, int y, int kind)
3394 for (i = 0; i < NUM_UPGRADES && found == -1; i++)
3396 if (!upgrades[i].alive)
3402 upgrades[found].alive = YES;
3403 upgrades[found].kind = kind;
3404 upgrades[found].x = x;
3405 upgrades[found].y = y;
3406 upgrades[found].xm = 4;
3407 upgrades[found].ym = -4;
3408 upgrades[found].height = 0;
3415 void killtux(int mode)
3419 playsound(sounds[SND_HURT]);
3421 if (tux_dir == RIGHT)
3423 else if (tux_dir == LEFT)
3426 if (mode == SHRINK && tux_size == BIG)
3429 tux_got_coffee = NO;
3433 tux_safe = TUX_SAFE_TIME;
3444 void add_bullet(int x, int y, int dir, int xm)
3450 for (i = 0; i < NUM_BULLETS && found == -1; i++)
3452 if (!bullets[i].alive)
3458 bullets[found].alive = YES;
3462 bullets[found].x = x + 32;
3463 bullets[found].xm = BULLET_XM + xm;
3467 bullets[found].x = x;
3468 bullets[found].xm = -BULLET_XM + xm;
3471 bullets[found].y = y;
3472 bullets[found].ym = BULLET_STARTING_YM;
3474 playsound(sounds[SND_SHOOT]);
3479 void drawendscreen(void)
3483 clearscreen(0, 0, 0);
3485 drawcenteredtext("GAMEOVER", 200, letters_red, NO_UPDATE);
3487 sprintf(str, "SCORE: %d", score);
3488 drawcenteredtext(str, 224, letters_gold, NO_UPDATE);
3490 sprintf(str, "DISTROS: %d", distros);
3491 drawcenteredtext(str, 256, letters_blue, NO_UPDATE);
3497 void drawresultscreen(void)
3501 clearscreen(0, 0, 0);
3503 drawcenteredtext("Result:", 200, letters_red, NO_UPDATE);
3505 sprintf(str, "SCORE: %d", score);
3506 drawcenteredtext(str, 224, letters_gold, NO_UPDATE);
3508 sprintf(str, "DISTROS: %d", distros);
3509 drawcenteredtext(str, 256, letters_blue, NO_UPDATE);