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)
448 if (jump_counter == 0)
452 if (!issolid(tux_x, tux_y + 32, scroll_x) ||
455 /* If they're not on the ground, or are currently moving
456 vertically, don't jump! */
458 jump_counter = MAX_JUMP_COUNT;
462 /* Make sure we're not standing back up into a solid! */
464 if (tux_size == SMALL || tux_duck == NO ||
465 !issolid(tux_x, tux_y, scroll_x))
469 if (tux_size == SMALL)
470 playsound(sounds[SND_JUMP]);
472 playsound(sounds[SND_BIGJUMP]);
478 /* Keep jumping for a while: */
480 if (jump_counter < MAX_JUMP_COUNT)
482 tux_ym = tux_ym - JUMP_SPEED;
492 if (fire == DOWN && old_fire == UP && tux_got_coffee)
494 add_bullet(tux_x + scroll_x, tux_y, tux_dir, tux_xm);
507 if (tux_size == BIG && tux_duck == YES)
509 /* Make sure we're not standing back up into a solid! */
511 if (!issolid(tux_x, tux_y - 32, scroll_x))
517 } /* (tux_dying || next_level) */
520 /* Tux either died, or reached the end of a level! */
525 if (Mix_PlayingMusic())
532 /* End of a level! */
540 tux_ym = tux_ym + GRAVITY;
548 /* No more lives!? */
554 if (score > highscore)
561 /* Either way, (re-)load the (next) level... */
571 tux_x = tux_x + tux_xm;
572 tux_y = tux_y + tux_ym;
575 /* Keep tux in bounds: */
579 else if (tux_x > 320 && scroll_x < ((level_width * 32) - 640))
581 /* Scroll the screen in past center: */
583 scroll_x = scroll_x + (tux_x - 320);
586 if (scroll_x > ((level_width * 32) - 640))
587 scroll_x = ((level_width * 32) - 640);
589 else if (tux_x > 608)
591 /* ... unless there's no more to scroll! */
601 if (issolid(tux_x, tux_y + 31, scroll_x) &&
602 !issolid(tux_x - tux_xm, tux_y + 31, scroll_x))
604 while (issolid(tux_x, tux_y + 31, scroll_x))
615 if (issolid(tux_x, tux_y, scroll_x) &&
616 !issolid(tux_x - tux_xm, tux_y, scroll_x))
618 while (issolid(tux_x, tux_y, scroll_x))
629 if (issolid(tux_x, tux_y + 31, scroll_x))
631 /* Set down properly: */
633 while (issolid(tux_x, tux_y + 31, scroll_x))
642 /* Reset score multiplier (for mutli-hits): */
645 score_multiplier = 1;
655 /* Bump into things: */
657 if (issolid(tux_x, tux_y, scroll_x) ||
658 (tux_size == BIG && !tux_duck &&
659 (issolid(tux_x, tux_y - 32, scroll_x))))
661 if (!issolid(tux_x - tux_xm, tux_y, scroll_x) &&
662 (tux_size == SMALL || tux_duck ||
663 !issolid(tux_x - tux_xm, tux_y - 32, scroll_x)))
665 tux_x = tux_x - tux_xm;
668 else if (!issolid(tux_x, tux_y - tux_ym, scroll_x) &&
669 (tux_size == SMALL || tux_duck ||
670 !issolid(tux_x, tux_y - 32 - tux_ym, scroll_x)))
678 /* Break bricks and empty boxes: */
682 if (isbrick(tux_x, tux_y - 32, scroll_x) ||
683 isfullbox(tux_x, tux_y - 32, scroll_x))
685 trygrabdistro(tux_x, tux_y - 64, scroll_x,
687 trybumpbadguy(tux_x, tux_y - 96, scroll_x);
689 if (isfullbox(tux_x, tux_y - 32,
692 bumpbrick(tux_x, tux_y - 32,
696 trybreakbrick(tux_x, tux_y - 32, scroll_x);
697 tryemptybox(tux_x, tux_y - 32, scroll_x);
700 if (isbrick(tux_x + 31, tux_y - 32, scroll_x) ||
701 isfullbox(tux_x + 31, tux_y - 32, scroll_x))
703 trygrabdistro(tux_x + 31,
707 trybumpbadguy(tux_x + 31,
711 if (isfullbox(tux_x + 31, tux_y - 32,
714 bumpbrick(tux_x + 31, tux_y - 32,
718 trybreakbrick(tux_x + 31,
721 tryemptybox(tux_x + 31,
728 if (isbrick(tux_x, tux_y, scroll_x) ||
729 isfullbox(tux_x, tux_y, scroll_x))
731 trygrabdistro(tux_x, tux_y - 32, scroll_x,
733 trybumpbadguy(tux_x, tux_y - 64, scroll_x);
734 if (isfullbox(tux_x, tux_y, scroll_x))
735 bumpbrick(tux_x, tux_y, scroll_x);
736 trybreakbrick(tux_x, tux_y, scroll_x);
737 tryemptybox(tux_x, tux_y, scroll_x);
740 if (isbrick(tux_x + 31, tux_y, scroll_x) ||
741 isfullbox(tux_x + 31, tux_y, scroll_x))
743 trygrabdistro(tux_x + 31,
747 trybumpbadguy(tux_x + 31,
750 if (isfullbox(tux_x + 31, tux_y, scroll_x))
751 bumpbrick(tux_x + 31, tux_y, scroll_x);
752 trybreakbrick(tux_x + 31, tux_y, scroll_x);
753 tryemptybox(tux_x + 31, tux_y, scroll_x);
759 /* It's a brick and we're small, make the brick
760 bounce, and grab any distros above it: */
762 if (isbrick(tux_x, tux_y, scroll_x) ||
763 isfullbox(tux_x, tux_y, scroll_x))
765 trygrabdistro(tux_x, tux_y - 32, scroll_x,
767 trybumpbadguy(tux_x, tux_y - 64, scroll_x);
768 bumpbrick(tux_x, tux_y, scroll_x);
769 tryemptybox(tux_x, tux_y, scroll_x);
772 if (isbrick(tux_x + 31, tux_y, scroll_x) ||
773 isfullbox(tux_x + 31, tux_y, scroll_x))
775 trygrabdistro(tux_x + 31, tux_y - 32, scroll_x,
777 trybumpbadguy(tux_x + 31, tux_y - 64, scroll_x);
778 bumpbrick(tux_x + 31, tux_y, scroll_x);
779 tryemptybox(tux_x + 31, tux_y, scroll_x);
783 /* Get a distro from a brick? */
785 if (shape(tux_x, tux_y, scroll_x) == 'x' ||
786 shape(tux_x, tux_y, scroll_x) == 'y')
788 add_bouncy_distro(((tux_x + scroll_x + 1)
792 if (counting_distros == NO)
794 counting_distros = YES;
795 distro_counter = 100;
798 if (distro_counter <= 0)
799 change(tux_x, tux_y, scroll_x, 'a');
801 playsound(sounds[SND_DISTRO]);
802 score = score + SCORE_DISTRO;
805 else if (shape(tux_x + 31, tux_y, scroll_x) == 'x' ||
806 shape(tux_x + 31, tux_y, scroll_x) == 'y')
808 add_bouncy_distro(((tux_x + scroll_x + 1 + 31)
812 if (counting_distros == NO)
814 counting_distros = YES;
815 distro_counter = 100;
818 if (distro_counter <= 0)
819 change(tux_x + 31, tux_y, scroll_x, 'a');
821 playsound(sounds[SND_DISTRO]);
822 score = score + SCORE_DISTRO;
830 tux_y = (tux_y / 32) * 32 + 30;
836 tux_y = (tux_y / 32) * 32 - 32;
841 jump_counter = MAX_JUMP_COUNT;
851 trygrabdistro(tux_x, tux_y, scroll_x, NO_BOUNCE);
852 trygrabdistro(tux_x + 31, tux_y, scroll_x, NO_BOUNCE);
854 if (tux_size == BIG && !tux_duck)
856 trygrabdistro(tux_x, tux_y - 32, scroll_x, NO_BOUNCE);
857 trygrabdistro(tux_x + 31, tux_y - 32, scroll_x, NO_BOUNCE);
862 /* Enough distros for a One-up? */
864 if (distros >= DISTROS_LIFEUP)
866 distros = distros - DISTROS_LIFEUP;
867 if(lives < MAX_LIVES)
869 playsound(sounds[SND_LIFEUP]); /*We want to hear the sound even, if MAX_LIVES is reached*/
873 /* Keep in-bounds, vertically: */
877 else if (tux_y > 480)
883 /* Slow down horizontally: */
887 if (right == UP && left == UP)
889 if (isice(tux_x, tux_y + 32, scroll_x) ||
890 !issolid(tux_x, tux_y + 32, scroll_x))
892 /* Slowly on ice or in air: */
901 /* Quickly, otherwise: */
908 /* Drop vertically: */
910 if (!issolid(tux_x, tux_y + 32, scroll_x))
912 tux_ym = tux_ym + GRAVITY;
924 /* ---- DONE HANDLING TUX! --- */
927 /* Handle bouncy distros: */
929 for (i = 0; i < NUM_BOUNCY_DISTROS; i++)
931 if (bouncy_distros[i].alive)
933 bouncy_distros[i].y = bouncy_distros[i].y + bouncy_distros[i].ym;
935 bouncy_distros[i].ym++;
937 if (bouncy_distros[i].ym >= 0)
938 bouncy_distros[i].alive = NO;
943 /* Handle broken bricks: */
945 for (i = 0; i < NUM_BROKEN_BRICKS; i++)
947 if (broken_bricks[i].alive)
949 broken_bricks[i].x = broken_bricks[i].x + broken_bricks[i].xm;
950 broken_bricks[i].y = broken_bricks[i].y + broken_bricks[i].ym;
952 broken_bricks[i].ym++;
954 if (broken_bricks[i].ym >= 0)
955 broken_bricks[i].alive = NO;
960 /* Handle distro counting: */
962 if (counting_distros == YES)
966 if (distro_counter <= 0)
967 counting_distros = -1;
971 /* Handle bouncy bricks: */
973 for (i = 0; i < NUM_BOUNCY_BRICKS; i++)
975 if (bouncy_bricks[i].alive)
977 bouncy_bricks[i].offset = (bouncy_bricks[i].offset +
978 bouncy_bricks[i].offset_m);
982 if (bouncy_bricks[i].offset < -BOUNCY_BRICK_MAX_OFFSET)
983 bouncy_bricks[i].offset_m = BOUNCY_BRICK_SPEED;
988 if (bouncy_bricks[i].offset == 0)
989 bouncy_bricks[i].alive = NO;
994 /* Handle floating scores: */
996 for (i = 0; i < NUM_FLOATING_SCORES; i++)
998 if (floating_scores[i].alive)
1000 floating_scores[i].y = floating_scores[i].y - 2;
1001 floating_scores[i].timer--;
1003 if (floating_scores[i].timer <= 0)
1004 floating_scores[i].alive = NO;
1009 /* Handle bullets: */
1011 for (i = 0; i < NUM_BULLETS; i++)
1013 if (bullets[i].alive)
1015 bullets[i].x = bullets[i].x + bullets[i].xm;
1016 bullets[i].y = bullets[i].y + bullets[i].ym;
1018 if (issolid(bullets[i].x, bullets[i].y, 0))
1020 if (issolid(bullets[i].x, bullets[i].y - bullets[i].ym, 0))
1021 bullets[i].alive = NO;
1024 if (bullets[i].ym >= 0)
1026 bullets[i].y = (bullets[i].y / 32) * 32 - 8;
1028 bullets[i].ym = -bullets[i].ym;
1032 bullets[i].ym = bullets[i].ym + GRAVITY;
1034 if (bullets[i].x < scroll_x ||
1035 bullets[i].x > scroll_x + 640)
1037 bullets[i].alive = NO;
1042 if (bullets[i].alive)
1044 for (j = 0; j < NUM_BAD_GUYS; j++)
1046 if (bad_guys[j].alive && !bad_guys[j].dying)
1048 if (bullets[i].x >= bad_guys[j].x - 4 &&
1049 bullets[i].x <= bad_guys[j].x + 32 + 4 &&
1050 bullets[i].y >= bad_guys[j].y - 4 &&
1051 bullets[i].y <= bad_guys[j].y + 32 + 4)
1053 /* Kill the bad guy! */
1055 bullets[i].alive = 0;
1056 bad_guys[j].dying = FALLING;
1057 bad_guys[j].ym = -8;
1060 /* Gain some points: */
1062 if (bad_guys[j].kind == BAD_BSOD)
1064 add_score(bad_guys[j].x - scroll_x, bad_guys[j].y,
1065 50 * score_multiplier);
1067 else if (bad_guys[j].kind == BAD_LAPTOP)
1069 add_score(bad_guys[j].x - scroll_x, bad_guys[j].y,
1070 25 * score_multiplier);
1074 /* Play death sound: */
1075 playsound(sounds[SND_FALL]);
1083 /* Handle background timer: */
1085 if (super_bkgd_time)
1089 /* Handle invincibility timer: */
1091 if (tux_invincible_time)
1092 tux_invincible_time--;
1095 /* Handle upgrades: */
1097 for (i = 0; i < NUM_UPGRADES; i++)
1099 if (upgrades[i].alive)
1101 if (upgrades[i].height < 32)
1105 upgrades[i].height++;
1111 if (upgrades[i].kind == UPGRADE_MINTS ||
1112 upgrades[i].kind == UPGRADE_HERRING)
1114 upgrades[i].x = upgrades[i].x + upgrades[i].xm;
1115 upgrades[i].y = upgrades[i].y + upgrades[i].ym;
1117 if (issolid(upgrades[i].x, upgrades[i].y + 31, 0) ||
1118 issolid(upgrades[i].x + 31, upgrades[i].y + 31, 0))
1120 if (upgrades[i].ym > 0)
1122 if (upgrades[i].kind == UPGRADE_MINTS)
1126 else if (upgrades[i].kind == UPGRADE_HERRING)
1128 upgrades[i].ym = -24;
1131 upgrades[i].y = (upgrades[i].y / 32) * 32;
1135 upgrades[i].ym = upgrades[i].ym + GRAVITY;
1137 if (issolid(upgrades[i].x, upgrades[i].y, 0))
1139 upgrades[i].xm = -upgrades[i].xm;
1144 /* Off the screen? Kill it! */
1146 if (upgrades[i].x < scroll_x)
1147 upgrades[i].alive = NO;
1150 /* Did the player grab it? */
1152 if (tux_x + scroll_x >= upgrades[i].x - 32 &&
1153 tux_x + scroll_x <= upgrades[i].x + 32 &&
1154 tux_y >= upgrades[i].y - 32 &&
1155 tux_y <= upgrades[i].y + 32)
1157 /* Remove the upgrade: */
1159 upgrades[i].alive = NO;
1162 /* Affect the player: */
1164 if (upgrades[i].kind == UPGRADE_MINTS)
1166 playsound(sounds[SND_EXCELLENT]);
1168 super_bkgd_time = 8;
1170 else if (upgrades[i].kind == UPGRADE_COFFEE)
1172 playsound(sounds[SND_COFFEE]);
1173 tux_got_coffee = YES;
1174 super_bkgd_time = 4;
1176 else if (upgrades[i].kind == UPGRADE_HERRING)
1178 playsound(sounds[SND_HERRING]);
1179 tux_invincible_time = 200;
1180 super_bkgd_time = 4;
1188 /* Handle bad guys: */
1190 for (i = 0; i < NUM_BAD_GUYS; i++)
1192 if (bad_guys[i].alive)
1194 if (bad_guys[i].seen)
1196 if (bad_guys[i].kind == BAD_BSOD)
1198 /* --- BLUE SCREEN OF DEATH MONSTER: --- */
1200 /* Move left/right: */
1202 if (bad_guys[i].dying == NO ||
1203 bad_guys[i].dying == FALLING)
1205 if (bad_guys[i].dir == RIGHT)
1206 bad_guys[i].x = bad_guys[i].x + 4;
1207 else if (bad_guys[i].dir == LEFT)
1208 bad_guys[i].x = bad_guys[i].x - 4;
1212 /* Move vertically: */
1214 bad_guys[i].y = bad_guys[i].y + bad_guys[i].ym;
1217 /* Bump into things horizontally: */
1219 if (!bad_guys[i].dying)
1221 if (issolid(bad_guys[i].x, bad_guys[i].y, 0))
1222 bad_guys[i].dir = !bad_guys[i].dir;
1226 /* Bump into other bad guys: */
1228 for (j = 0; j < NUM_BAD_GUYS; j++)
1230 if (j != i && bad_guys[j].alive &&
1231 !bad_guys[j].dying && !bad_guys[i].dying &&
1232 bad_guys[i].x >= bad_guys[j].x - 32 &&
1233 bad_guys[i].x <= bad_guys[j].x + 32 &&
1234 bad_guys[i].y >= bad_guys[j].y - 32 &&
1235 bad_guys[i].y <= bad_guys[j].y + 32)
1237 bad_guys[i].dir = !bad_guys[i].dir;
1242 /* Fall if we get off the ground: */
1244 if (bad_guys[i].dying != FALLING)
1246 if (!issolid(bad_guys[i].x, bad_guys[i].y + 32, 0) &&
1247 bad_guys[i].ym < MAX_YM)
1249 bad_guys[i].ym = bad_guys[i].ym + GRAVITY;
1255 if (bad_guys[i].ym > 0)
1257 bad_guys[i].y = (bad_guys[i].y / 32) * 32;
1263 bad_guys[i].ym = bad_guys[i].ym + GRAVITY;
1265 if (bad_guys[i].y > 480)
1266 bad_guys[i].alive = NO;
1268 else if (bad_guys[i].kind == BAD_LAPTOP)
1270 /* --- LAPTOP MONSTER: --- */
1272 /* Move left/right: */
1274 if (bad_guys[i].mode != FLAT && bad_guys[i].mode != KICK)
1276 if (bad_guys[i].dying == NO ||
1277 bad_guys[i].dying == FALLING)
1279 if (bad_guys[i].dir == RIGHT)
1280 bad_guys[i].x = bad_guys[i].x + 4;
1281 else if (bad_guys[i].dir == LEFT)
1282 bad_guys[i].x = bad_guys[i].x - 4;
1285 else if (bad_guys[i].mode == KICK)
1287 if (bad_guys[i].dir == RIGHT)
1288 bad_guys[i].x = bad_guys[i].x + 16;
1289 else if (bad_guys[i].dir == LEFT)
1290 bad_guys[i].x = bad_guys[i].x - 16;
1294 /* Move vertically: */
1296 bad_guys[i].y = bad_guys[i].y + bad_guys[i].ym;
1299 /* Bump into things horizontally: */
1301 if (!bad_guys[i].dying)
1303 if (issolid(bad_guys[i].x, bad_guys[i].y, 0))
1305 bad_guys[i].dir = !bad_guys[i].dir;
1307 if (bad_guys[i].mode == KICK)
1308 playsound(sounds[SND_RICOCHET]);
1313 /* Bump into other bad guys: */
1315 for (j = 0; j < NUM_BAD_GUYS; j++)
1317 if (j != i && bad_guys[j].alive &&
1318 !bad_guys[j].dying && !bad_guys[i].dying &&
1319 bad_guys[i].x >= bad_guys[j].x - 32 &&
1320 bad_guys[i].x <= bad_guys[j].x + 32 &&
1321 bad_guys[i].y >= bad_guys[j].y - 32 &&
1322 bad_guys[i].y <= bad_guys[j].y + 32)
1324 if (bad_guys[i].mode != KICK)
1325 bad_guys[i].dir = !bad_guys[i].dir;
1328 /* We're in kick mode, kill the other guy: */
1330 bad_guys[j].dying = FALLING;
1331 bad_guys[j].ym = -8;
1332 playsound(sounds[SND_FALL]);
1334 add_score(bad_guys[i].x - scroll_x,
1335 bad_guys[i].y, 100);
1341 /* Fall if we get off the ground: */
1343 if (bad_guys[i].dying != FALLING)
1345 if (!issolid(bad_guys[i].x, bad_guys[i].y + 32, 0) &&
1346 bad_guys[i].ym < MAX_YM)
1348 bad_guys[i].ym = bad_guys[i].ym + GRAVITY;
1354 if (bad_guys[i].ym > 0)
1356 bad_guys[i].y = (bad_guys[i].y / 32) * 32;
1362 bad_guys[i].ym = bad_guys[i].ym + GRAVITY;
1364 if (bad_guys[i].y > 480)
1365 bad_guys[i].alive = NO;
1367 else if (bad_guys[i].kind == BAD_MONEY)
1369 /* --- MONEY BAGS: --- */
1372 /* Move vertically: */
1374 bad_guys[i].y = bad_guys[i].y + bad_guys[i].ym;
1377 /* Fall if we get off the ground: */
1379 if (bad_guys[i].dying != FALLING)
1381 if (!issolid(bad_guys[i].x, bad_guys[i].y + 32, 0))
1383 if (bad_guys[i].ym < MAX_YM)
1385 bad_guys[i].ym = bad_guys[i].ym + GRAVITY;
1392 if (bad_guys[i].ym > 0)
1394 bad_guys[i].y = (bad_guys[i].y / 32) * 32;
1395 bad_guys[i].ym = -MAX_YM;
1400 bad_guys[i].ym = bad_guys[i].ym + GRAVITY;
1402 if (bad_guys[i].y > 480)
1403 bad_guys[i].alive = NO;
1405 else if (bad_guys[i].kind == -1)
1410 /* Kill it if the player jumped on it: */
1412 if (!bad_guys[i].dying && !tux_dying && !tux_safe &&
1413 tux_x + scroll_x >= bad_guys[i].x - 32 &&
1414 tux_x + scroll_x <= bad_guys[i].x + 32 &&
1415 tux_y >= bad_guys[i].y - 32 &&
1416 tux_y <= bad_guys[i].y - 8
1420 if (bad_guys[i].kind == BAD_BSOD)
1422 bad_guys[i].dying = SQUISHED;
1423 bad_guys[i].timer = 16;
1424 tux_ym = -KILL_BOUNCE_YM;
1426 add_score(bad_guys[i].x - scroll_x, bad_guys[i].y,
1427 50 * score_multiplier);
1429 playsound(sounds[SND_SQUISH]);
1431 else if (bad_guys[i].kind == BAD_LAPTOP)
1433 if (bad_guys[i].mode != FLAT)
1437 bad_guys[i].mode = FLAT;
1439 bad_guys[i].timer = 64;
1447 bad_guys[i].mode = KICK;
1449 if (tux_x + scroll_x <= bad_guys[i].x)
1450 bad_guys[i].dir = RIGHT;
1452 bad_guys[i].dir = LEFT;
1454 bad_guys[i].timer = 8;
1457 tux_ym = -KILL_BOUNCE_YM;
1459 add_score(bad_guys[i].x - scroll_x,
1461 25 * score_multiplier);
1463 /* playsound(sounds[SND_SQUISH]); */
1465 else if (bad_guys[i].kind == -1)
1473 /* Hurt the player if he just touched it: */
1475 if (!bad_guys[i].dying && !tux_dying &&
1477 tux_x + scroll_x >= bad_guys[i].x - 32 &&
1478 tux_x + scroll_x <= bad_guys[i].x + 32 &&
1479 tux_y >= bad_guys[i].y - 32 &&
1480 tux_y <= bad_guys[i].y + 32)
1482 if (bad_guys[i].mode == FLAT)
1486 bad_guys[i].mode = KICK;
1488 if (tux_x < bad_guys[i].x)
1490 bad_guys[i].dir = RIGHT;
1491 bad_guys[i].x = bad_guys[i].x + 16;
1495 bad_guys[i].dir = LEFT;
1496 bad_guys[i].x = bad_guys[i].x - 16;
1499 bad_guys[i].timer = 8;
1501 else if (bad_guys[i].mode == KICK)
1503 if (tux_y < bad_guys[i].y - 16 &&
1504 bad_guys[i].timer == 0)
1506 /* Step on (stop being kicked) */
1508 bad_guys[i].mode = FLAT;
1509 bad_guys[i].timer = 64;
1513 /* Hurt if you get hit by kicked laptop: */
1515 if (bad_guys[i].timer == 0)
1517 if (tux_invincible_time == 0)
1523 bad_guys[i].dying = FALLING;
1524 bad_guys[i].ym = -8;
1525 playsound(sounds[SND_FALL]);
1532 if (tux_invincible_time == 0)
1538 bad_guys[i].dying = FALLING;
1539 bad_guys[i].ym = -8;
1540 playsound(sounds[SND_FALL]);
1546 /* Handle mode timer: */
1548 if (bad_guys[i].mode == FLAT)
1550 bad_guys[i].timer--;
1552 if (bad_guys[i].timer <= 0)
1553 bad_guys[i].mode = NORMAL;
1555 else if (bad_guys[i].mode == KICK)
1557 if (bad_guys[i].timer > 0)
1558 bad_guys[i].timer--;
1562 /* Handle dying timer: */
1564 if (bad_guys[i].dying == SQUISHED)
1566 bad_guys[i].timer--;
1569 /* Remove it if time's up: */
1571 if (bad_guys[i].timer <= 0)
1572 bad_guys[i].alive = NO;
1576 /* Remove if it's far off the screen: */
1578 if (bad_guys[i].x < scroll_x - OFFSCREEN_DISTANCE)
1579 bad_guys[i].alive = NO;
1583 /* Once it's on screen, it's activated! */
1585 if (bad_guys[i].x <= scroll_x + 640 + OFFSCREEN_DISTANCE)
1586 bad_guys[i].seen = YES;
1592 /* Handle skidding: */
1594 if (tux_skidding > 0)
1602 if (tux_dying && (frame % 4) == 0)
1603 clearscreen(255, 255, 255);
1606 if (super_bkgd_time == 0)
1607 clearscreen(bkgd_red, bkgd_green, bkgd_blue);
1609 drawimage(img_super_bkgd, 0, 0, NO_UPDATE);
1613 /* Draw background: */
1615 for (y = 0; y < 15; y++)
1617 for (x = 0; x < 21; x++)
1619 drawshape(x * 32 - (scroll_x % 32), y * 32,
1620 tiles[y][x + (scroll_x / 32)]);
1625 /* (Bouncy bricks): */
1627 for (i = 0; i < NUM_BOUNCY_BRICKS; i++)
1629 if (bouncy_bricks[i].alive)
1631 if (bouncy_bricks[i].x >= scroll_x - 32 &&
1632 bouncy_bricks[i].x <= scroll_x + 640)
1634 dest.x = bouncy_bricks[i].x - scroll_x;
1635 dest.y = bouncy_bricks[i].y;
1639 SDL_FillRect(screen, &dest, SDL_MapRGB(screen->format,
1644 drawshape(bouncy_bricks[i].x - scroll_x,
1645 bouncy_bricks[i].y + bouncy_bricks[i].offset,
1646 bouncy_bricks[i].shape);
1654 for (i = 0; i < NUM_BAD_GUYS; i++)
1656 if (bad_guys[i].alive &&
1657 bad_guys[i].x > scroll_x - 32 &&
1658 bad_guys[i].x < scroll_x + 640)
1660 if (bad_guys[i].kind == BAD_BSOD)
1662 /* --- BLUE SCREEN OF DEATH MONSTER: --- */
1664 if (bad_guys[i].dying == NO)
1668 if (bad_guys[i].dir == LEFT)
1670 drawimage(img_bsod_left[(frame / 5) % 4],
1671 bad_guys[i].x - scroll_x,
1677 drawimage(img_bsod_right[(frame / 5) % 4],
1678 bad_guys[i].x - scroll_x,
1683 else if (bad_guys[i].dying == FALLING)
1687 if (bad_guys[i].dir == LEFT)
1689 drawimage(img_bsod_falling_left,
1690 bad_guys[i].x - scroll_x,
1696 drawimage(img_bsod_falling_right,
1697 bad_guys[i].x - scroll_x,
1702 else if (bad_guys[i].dying == SQUISHED)
1704 /* Dying - Squished: */
1706 if (bad_guys[i].dir == LEFT)
1708 drawimage(img_bsod_squished_left,
1709 bad_guys[i].x - scroll_x,
1715 drawimage(img_bsod_squished_right,
1716 bad_guys[i].x - scroll_x,
1722 else if (bad_guys[i].kind == BAD_LAPTOP)
1724 /* --- LAPTOP MONSTER: --- */
1726 if (bad_guys[i].dying == NO)
1730 if (bad_guys[i].mode == NORMAL)
1734 if (bad_guys[i].dir == LEFT)
1736 drawimage(img_laptop_left[(frame / 5) % 3],
1737 bad_guys[i].x - scroll_x,
1743 drawimage(img_laptop_right[(frame / 5) % 3],
1744 bad_guys[i].x - scroll_x,
1753 if (bad_guys[i].dir == LEFT)
1755 drawimage(img_laptop_flat_left,
1756 bad_guys[i].x - scroll_x,
1762 drawimage(img_laptop_flat_right,
1763 bad_guys[i].x - scroll_x,
1769 else if (bad_guys[i].dying == FALLING)
1773 if (bad_guys[i].dir == LEFT)
1775 drawimage(img_laptop_falling_left,
1776 bad_guys[i].x - scroll_x,
1782 drawimage(img_laptop_falling_right,
1783 bad_guys[i].x - scroll_x,
1789 else if (bad_guys[i].kind == BAD_MONEY)
1791 if (bad_guys[i].ym > -16)
1793 if (bad_guys[i].dir == LEFT)
1795 drawimage(img_money_left[0],
1796 bad_guys[i].x - scroll_x,
1802 drawimage(img_money_right[0],
1803 bad_guys[i].x - scroll_x,
1810 if (bad_guys[i].dir == LEFT)
1812 drawimage(img_money_left[1],
1813 bad_guys[i].x - scroll_x,
1819 drawimage(img_money_right[1],
1820 bad_guys[i].x - scroll_x,
1826 else if (bad_guys[i].kind == -1)
1835 if (right == UP && left == UP)
1842 if ((fire == DOWN && (frame % 2) == 0) ||
1844 tux_frame_main = (tux_frame_main + 1) % 4;
1846 tux_frame = tux_frame_main;
1853 if (tux_got_coffee && (frame % 2) == 1)
1857 drawimage(img_red_glow, tux_x - 8, tux_y - 32, NO_UPDATE);
1861 if (tux_safe == 0 || (frame % 2) == 0)
1863 if (tux_size == SMALL)
1865 if (tux_invincible_time)
1869 if (tux_dir == RIGHT)
1871 drawimage(cape_right[frame % 2],
1877 drawimage(cape_left[frame % 2],
1884 if (tux_dir == RIGHT)
1886 drawimage(tux_right[tux_frame], tux_x, tux_y, NO_UPDATE);
1890 drawimage(tux_left[tux_frame], tux_x, tux_y, NO_UPDATE);
1895 if (tux_invincible_time)
1899 if (tux_dir == RIGHT)
1901 drawimage(bigcape_right[frame % 2],
1902 tux_x - 8 - 16, tux_y - 32,
1907 drawimage(bigcape_left[frame % 2],
1908 tux_x - 8, tux_y - 32,
1917 if (!jumping || tux_ym > 0)
1919 if (tux_dir == RIGHT)
1921 drawimage(bigtux_right[tux_frame],
1922 tux_x - 8, tux_y - 32,
1927 drawimage(bigtux_left[tux_frame],
1928 tux_x - 8, tux_y - 32,
1934 if (tux_dir == RIGHT)
1936 drawimage(bigtux_right_jump,
1937 tux_x - 8, tux_y - 32,
1942 drawimage(bigtux_left_jump,
1943 tux_x - 8, tux_y - 32,
1950 if (tux_dir == RIGHT)
1952 drawimage(skidtux_right,
1953 tux_x - 8, tux_y - 32,
1958 drawimage(skidtux_left,
1959 tux_x - 8, tux_y - 32,
1966 if (tux_dir == RIGHT)
1968 drawimage(ducktux_right, tux_x - 8, tux_y - 16,
1973 drawimage(ducktux_left, tux_x - 8, tux_y - 16,
1983 for (i = 0; i < NUM_BULLETS; i++)
1985 if (bullets[i].alive &&
1986 bullets[i].x >= scroll_x - 4 &&
1987 bullets[i].x <= scroll_x + 640)
1989 drawimage(img_bullet, bullets[i].x - scroll_x, bullets[i].y,
1995 /* (Floating scores): */
1997 for (i = 0; i < NUM_FLOATING_SCORES; i++)
1999 if (floating_scores[i].alive)
2001 sprintf(str, "%d", floating_scores[i].value);
2003 floating_scores[i].x + 16 - strlen(str) * 8,
2004 floating_scores[i].y,
2005 letters_gold, NO_UPDATE);
2012 for (i = 0; i < NUM_UPGRADES; i++)
2014 if (upgrades[i].alive)
2016 if (upgrades[i].height < 32)
2020 dest.x = upgrades[i].x - scroll_x;
2021 dest.y = upgrades[i].y + 32 - upgrades[i].height;
2023 dest.h = upgrades[i].height;
2028 src.h = upgrades[i].height;
2030 if (upgrades[i].kind == UPGRADE_MINTS)
2031 SDL_BlitSurface(img_mints, &src, screen, &dest);
2032 else if (upgrades[i].kind == UPGRADE_COFFEE)
2033 SDL_BlitSurface(img_coffee, &src, screen, &dest);
2034 else if (upgrades[i].kind == UPGRADE_HERRING)
2035 SDL_BlitSurface(img_golden_herring, &src, screen, &dest);
2039 if (upgrades[i].kind == UPGRADE_MINTS)
2041 drawimage(img_mints,
2042 upgrades[i].x - scroll_x, upgrades[i].y,
2045 else if (upgrades[i].kind == UPGRADE_COFFEE)
2047 drawimage(img_coffee,
2048 upgrades[i].x - scroll_x, upgrades[i].y,
2051 else if (upgrades[i].kind == UPGRADE_HERRING)
2053 drawimage(img_golden_herring,
2054 upgrades[i].x - scroll_x, upgrades[i].y,
2062 /* (Bouncy distros): */
2064 for (i = 0; i < NUM_BOUNCY_DISTROS; i++)
2066 if (bouncy_distros[i].alive)
2068 drawimage(img_distro[0],
2069 bouncy_distros[i].x - scroll_x,
2070 bouncy_distros[i].y,
2076 /* (Broken bricks): */
2078 for (i = 0; i < NUM_BROKEN_BRICKS; i++)
2080 if (broken_bricks[i].alive)
2082 src.x = rand() % 16;
2083 src.y = rand() % 16;
2087 dest.x = broken_bricks[i].x - scroll_x;
2088 dest.y = broken_bricks[i].y;
2092 SDL_BlitSurface(img_brick[0], &src, screen, &dest);
2099 sprintf(str, "%d", score);
2100 drawtext("SCORE", 0, 0, letters_blue, NO_UPDATE);
2101 drawtext(str, 96, 0, letters_gold, NO_UPDATE);
2103 sprintf(str, "%d", highscore);
2104 drawtext("HIGH", 0, 20, letters_blue, NO_UPDATE);
2105 drawtext(str, 96, 20, letters_gold, NO_UPDATE);
2107 if (time_left >= 50 || (frame % 10) < 5)
2109 sprintf(str, "%d", time_left);
2110 drawtext("TIME", 224, 0, letters_blue, NO_UPDATE);
2111 drawtext(str, 304, 0, letters_gold, NO_UPDATE);
2114 sprintf(str, "%d", distros);
2115 drawtext("DISTROS", 480, 0, letters_blue, NO_UPDATE);
2116 drawtext(str, 608, 0, letters_gold, NO_UPDATE);
2119 /* (Update it all!) */
2124 /* Keep playing music: */
2128 if (!Mix_PlayingMusic())
2130 Mix_PlayMusic(song, 1);
2135 /* Pause til next frame: */
2137 now_time = SDL_GetTicks();
2138 if (now_time < last_time + FPS)
2139 SDL_Delay(last_time + FPS - now_time);
2144 if ((frame % 10) == 0 && time_left > 0)
2152 while (!done && !quit);
2156 if (Mix_PlayingMusic())
2168 /* Initialize the game stuff: */
2179 /* Load data for this level: */
2181 void loadlevel(void)
2192 for (i = 0; i < NUM_BOUNCY_DISTROS; i++)
2193 bouncy_distros[i].alive = NO;
2195 for (i = 0; i < NUM_BROKEN_BRICKS; i++)
2196 broken_bricks[i].alive = NO;
2198 for (i = 0; i < NUM_BOUNCY_BRICKS; i++)
2199 bouncy_bricks[i].alive = NO;
2201 for (i = 0; i < NUM_BAD_GUYS; i++)
2202 bad_guys[i].alive = NO;
2204 for (i = 0; i < NUM_FLOATING_SCORES; i++)
2205 floating_scores[i].alive = NO;
2207 for (i = 0; i < NUM_UPGRADES; i++)
2208 upgrades[i].alive = NO;
2210 for (i = 0; i < NUM_BULLETS; i++)
2211 bullets[i].alive = NO;
2214 /* Load data file: */
2216 filename = (char *) malloc(sizeof(char) * (strlen(DATA_PREFIX) + 20));
2217 sprintf(filename, "%s/levels/level%d.dat", DATA_PREFIX, level);
2218 fi = fopen(filename, "r");
2227 /* Load header info: */
2231 strcpy(levelname, str);
2233 /* (Time to beat level) */
2235 time_left = atoi(str);
2237 /* (Song file for this level) */
2239 strcpy(song_title, str);
2241 /* (Level background color) */
2243 bkgd_red = atoi(str);
2245 bkgd_green= atoi(str);
2247 bkgd_blue = atoi(str);
2251 level_width = atoi(str);
2254 /* Allocate some space for the line-reading! */
2256 line = (char *) malloc(sizeof(char) * (level_width + 5));
2259 fprintf(stderr, "Couldn't allocate space to load level data!");
2264 /* Load the level lines: */
2266 for (y = 0; y < 15; y++)
2268 fgets(line, level_width + 5, fi);
2269 line[strlen(line) - 1] = '\0';
2270 tiles[y] = strdup(line);
2276 /* Activate bad guys: */
2278 for (y = 0; y < 15; y++)
2280 for (x = 0; x < level_width; x++)
2282 if (tiles[y][x] >= '0' && tiles[y][x] <= '9')
2284 add_bad_guy(x * 32, y * 32, tiles[y][x] - '0');
2299 tux_got_coffee = NO;
2300 tux_invincible_time = 0;
2304 tux_safe = TUX_SAFE_TIME;
2320 score_multiplier = 1;
2321 super_bkgd_time = 0;
2325 counting_distros = NO;
2331 clearscreen(0, 0, 0);
2333 sprintf(str, "LEVEL %d", level);
2334 drawcenteredtext(str, 200, letters_red, NO_UPDATE);
2336 sprintf(str, "%s", levelname);
2337 drawcenteredtext(str, 224, letters_gold, NO_UPDATE);
2339 sprintf(str, "TUX x %d", lives);
2340 drawcenteredtext(str, 256, letters_blue, NO_UPDATE);
2348 /* Load a level-specific graphic... */
2350 SDL_Surface * load_level_image(char * file, int use_alpha)
2354 snprintf(fname, 1024, "%s/images/level%d/%s", DATA_PREFIX, level, file);
2356 return(load_image(fname, use_alpha));
2360 /* Load graphics: */
2362 void loadlevelgfx(void)
2364 img_brick[0] = load_level_image("brick0.png", IGNORE_ALPHA);
2365 img_brick[1] = load_level_image("brick1.png", IGNORE_ALPHA);
2367 img_solid[0] = load_level_image("solid0.png", USE_ALPHA);
2368 img_solid[1] = load_level_image("solid1.png", USE_ALPHA);
2369 img_solid[2] = load_level_image("solid2.png", USE_ALPHA);
2370 img_solid[3] = load_level_image("solid3.png", USE_ALPHA);
2372 img_bkgd[0][0] = load_level_image("bkgd-00.png", USE_ALPHA);
2373 img_bkgd[0][1] = load_level_image("bkgd-01.png", USE_ALPHA);
2374 img_bkgd[0][2] = load_level_image("bkgd-02.png", USE_ALPHA);
2375 img_bkgd[0][3] = load_level_image("bkgd-03.png", USE_ALPHA);
2377 img_bkgd[1][0] = load_level_image("bkgd-10.png", USE_ALPHA);
2378 img_bkgd[1][1] = load_level_image("bkgd-11.png", USE_ALPHA);
2379 img_bkgd[1][2] = load_level_image("bkgd-12.png", USE_ALPHA);
2380 img_bkgd[1][3] = load_level_image("bkgd-13.png", USE_ALPHA);
2386 void loadlevelsong(void)
2391 song_path = (char *) malloc(sizeof(char) * (strlen(DATA_PREFIX) +
2392 strlen(song_title) + 8));
2394 sprintf(song_path, "%s/music/%s", DATA_PREFIX, song_title);
2396 song = load_song(DATA_PREFIX "/music/ji_turn.it");
2402 /* Free graphics data for this level: */
2404 void unloadlevelgfx(void)
2408 for (i = 0; i < 2; i++)
2410 SDL_FreeSurface(img_brick[i]);
2412 for (i = 0; i < 4; i++)
2414 SDL_FreeSurface(img_solid[i]);
2415 SDL_FreeSurface(img_bkgd[0][i]);
2416 SDL_FreeSurface(img_bkgd[1][i]);
2421 /* Free music data for this level: */
2423 void unloadlevelsong(void)
2427 Mix_FreeMusic(song);
2432 /* Load graphics shared between all levels: */
2434 void loadshared(void)
2441 tux_right[0] = load_image(DATA_PREFIX "/images/shared/tux-right-0.png",
2444 tux_right[1] = load_image(DATA_PREFIX "/images/shared/tux-right-1.png",
2447 tux_right[2] = load_image(DATA_PREFIX "/images/shared/tux-right-2.png",
2450 tux_left[0] = load_image(DATA_PREFIX "/images/shared/tux-left-0.png",
2453 tux_left[1] = load_image(DATA_PREFIX "/images/shared/tux-left-1.png",
2456 tux_left[2] = load_image(DATA_PREFIX "/images/shared/tux-left-2.png",
2459 cape_right[0] = load_image(DATA_PREFIX "/images/shared/cape-right-0.png",
2462 cape_right[1] = load_image(DATA_PREFIX "/images/shared/cape-right-1.png",
2465 cape_left[0] = load_image(DATA_PREFIX "/images/shared/cape-left-0.png",
2468 cape_left[1] = load_image(DATA_PREFIX "/images/shared/cape-left-1.png",
2471 bigtux_right[0] = load_image(DATA_PREFIX "/images/shared/bigtux-right-0.png",
2474 bigtux_right[1] = load_image(DATA_PREFIX "/images/shared/bigtux-right-1.png",
2477 bigtux_right[2] = load_image(DATA_PREFIX "/images/shared/bigtux-right-2.png",
2481 load_image(DATA_PREFIX "/images/shared/bigtux-right-jump.png", USE_ALPHA);
2483 bigtux_left[0] = load_image(DATA_PREFIX "/images/shared/bigtux-left-0.png",
2486 bigtux_left[1] = load_image(DATA_PREFIX "/images/shared/bigtux-left-1.png",
2489 bigtux_left[2] = load_image(DATA_PREFIX "/images/shared/bigtux-left-2.png",
2493 load_image(DATA_PREFIX "/images/shared/bigtux-left-jump.png", USE_ALPHA);
2496 load_image(DATA_PREFIX "/images/shared/bigcape-right-0.png",
2500 load_image(DATA_PREFIX "/images/shared/bigcape-right-1.png",
2504 load_image(DATA_PREFIX "/images/shared/bigcape-left-0.png",
2508 load_image(DATA_PREFIX "/images/shared/bigcape-left-1.png",
2511 ducktux_right = load_image(DATA_PREFIX
2512 "/images/shared/ducktux-right.png",
2515 ducktux_left = load_image(DATA_PREFIX
2516 "/images/shared/ducktux-left.png",
2519 skidtux_right = load_image(DATA_PREFIX
2520 "/images/shared/skidtux-right.png",
2523 skidtux_left = load_image(DATA_PREFIX
2524 "/images/shared/skidtux-left.png",
2530 img_box_full = load_image(DATA_PREFIX "/images/shared/box-full.png",
2532 img_box_empty = load_image(DATA_PREFIX "/images/shared/box-empty.png",
2539 img_water = load_image(DATA_PREFIX "/images/shared/water.png", IGNORE_ALPHA);
2541 img_waves[0] = load_image(DATA_PREFIX "/images/shared/waves-0.png",
2544 img_waves[1] = load_image(DATA_PREFIX "/images/shared/waves-1.png",
2547 img_waves[2] = load_image(DATA_PREFIX "/images/shared/waves-2.png",
2553 img_pole = load_image(DATA_PREFIX "/images/shared/pole.png", USE_ALPHA);
2554 img_poletop = load_image(DATA_PREFIX "/images/shared/poletop.png",
2560 img_flag[0] = load_image(DATA_PREFIX "/images/shared/flag-0.png",
2562 img_flag[1] = load_image(DATA_PREFIX "/images/shared/flag-1.png",
2568 img_cloud[0][0] = load_image(DATA_PREFIX "/images/shared/cloud-00.png",
2571 img_cloud[0][1] = load_image(DATA_PREFIX "/images/shared/cloud-01.png",
2574 img_cloud[0][2] = load_image(DATA_PREFIX "/images/shared/cloud-02.png",
2577 img_cloud[0][3] = load_image(DATA_PREFIX "/images/shared/cloud-03.png",
2581 img_cloud[1][0] = load_image(DATA_PREFIX "/images/shared/cloud-10.png",
2584 img_cloud[1][1] = load_image(DATA_PREFIX "/images/shared/cloud-11.png",
2587 img_cloud[1][2] = load_image(DATA_PREFIX "/images/shared/cloud-12.png",
2590 img_cloud[1][3] = load_image(DATA_PREFIX "/images/shared/cloud-13.png",
2598 img_bsod_left[0] = load_image(DATA_PREFIX
2599 "/images/shared/bsod-left-0.png",
2602 img_bsod_left[1] = load_image(DATA_PREFIX
2603 "/images/shared/bsod-left-1.png",
2606 img_bsod_left[2] = load_image(DATA_PREFIX
2607 "/images/shared/bsod-left-2.png",
2610 img_bsod_left[3] = load_image(DATA_PREFIX
2611 "/images/shared/bsod-left-3.png",
2614 img_bsod_right[0] = load_image(DATA_PREFIX
2615 "/images/shared/bsod-right-0.png",
2618 img_bsod_right[1] = load_image(DATA_PREFIX
2619 "/images/shared/bsod-right-1.png",
2622 img_bsod_right[2] = load_image(DATA_PREFIX
2623 "/images/shared/bsod-right-2.png",
2626 img_bsod_right[3] = load_image(DATA_PREFIX
2627 "/images/shared/bsod-right-3.png",
2630 img_bsod_squished_left = load_image(DATA_PREFIX
2631 "/images/shared/bsod-squished-left.png",
2634 img_bsod_squished_right = load_image(DATA_PREFIX
2635 "/images/shared/bsod-squished-right.png",
2638 img_bsod_falling_left = load_image(DATA_PREFIX
2639 "/images/shared/bsod-falling-left.png",
2642 img_bsod_falling_right = load_image(DATA_PREFIX
2643 "/images/shared/bsod-falling-right.png",
2649 img_laptop_left[0] = load_image(DATA_PREFIX
2650 "/images/shared/laptop-left-0.png",
2653 img_laptop_left[1] = load_image(DATA_PREFIX
2654 "/images/shared/laptop-left-1.png",
2657 img_laptop_left[2] = load_image(DATA_PREFIX
2658 "/images/shared/laptop-left-2.png",
2661 img_laptop_right[0] = load_image(DATA_PREFIX
2662 "/images/shared/laptop-right-0.png",
2665 img_laptop_right[1] = load_image(DATA_PREFIX
2666 "/images/shared/laptop-right-1.png",
2669 img_laptop_right[2] = load_image(DATA_PREFIX
2670 "/images/shared/laptop-right-2.png",
2673 img_laptop_flat_left = load_image(DATA_PREFIX
2674 "/images/shared/laptop-flat-left.png",
2677 img_laptop_flat_right = load_image(DATA_PREFIX
2678 "/images/shared/laptop-flat-right.png",
2681 img_laptop_falling_left =
2682 load_image(DATA_PREFIX
2683 "/images/shared/laptop-falling-left.png",
2686 img_laptop_falling_right =
2687 load_image(DATA_PREFIX
2688 "/images/shared/laptop-falling-right.png",
2694 img_money_left[0] = load_image(DATA_PREFIX
2695 "/images/shared/bag-left-0.png",
2698 img_money_left[1] = load_image(DATA_PREFIX
2699 "/images/shared/bag-left-1.png",
2702 img_money_right[0] = load_image(DATA_PREFIX
2703 "/images/shared/bag-right-0.png",
2706 img_money_right[1] = load_image(DATA_PREFIX
2707 "/images/shared/bag-right-1.png",
2714 img_mints = load_image(DATA_PREFIX "/images/shared/mints.png", USE_ALPHA);
2715 img_coffee = load_image(DATA_PREFIX "/images/shared/coffee.png", USE_ALPHA);
2720 img_bullet = load_image(DATA_PREFIX "/images/shared/bullet.png", USE_ALPHA);
2722 img_red_glow = load_image(DATA_PREFIX "/images/shared/red-glow.png",
2728 img_distro[0] = load_image(DATA_PREFIX "/images/shared/distro-0.png",
2731 img_distro[1] = load_image(DATA_PREFIX "/images/shared/distro-1.png",
2734 img_distro[2] = load_image(DATA_PREFIX "/images/shared/distro-2.png",
2737 img_distro[3] = load_image(DATA_PREFIX "/images/shared/distro-3.png",
2743 img_golden_herring =
2744 load_image(DATA_PREFIX "/images/shared/golden-herring.png",
2748 /* Super background: */
2750 img_super_bkgd = load_image(DATA_PREFIX "/images/shared/super-bkgd.png",
2754 /* Sound effects: */
2758 for (i = 0; i < NUM_SOUNDS; i++)
2759 sounds[i] = load_sound(soundfilenames[i]);
2765 /* Free shared data: */
2767 void unloadshared(void)
2771 for (i = 0; i < 3; i++)
2773 SDL_FreeSurface(tux_right[i]);
2774 SDL_FreeSurface(tux_left[i]);
2775 SDL_FreeSurface(bigtux_right[i]);
2776 SDL_FreeSurface(bigtux_left[i]);
2779 SDL_FreeSurface(bigtux_right_jump);
2780 SDL_FreeSurface(bigtux_left_jump);
2782 for (i = 0; i < 2; i++)
2784 SDL_FreeSurface(cape_right[i]);
2785 SDL_FreeSurface(cape_left[i]);
2786 SDL_FreeSurface(bigcape_right[i]);
2787 SDL_FreeSurface(bigcape_left[i]);
2790 SDL_FreeSurface(ducktux_left);
2791 SDL_FreeSurface(ducktux_right);
2793 SDL_FreeSurface(skidtux_left);
2794 SDL_FreeSurface(skidtux_right);
2796 for (i = 0; i < 4; i++)
2798 SDL_FreeSurface(img_bsod_left[i]);
2799 SDL_FreeSurface(img_bsod_right[i]);
2802 SDL_FreeSurface(img_bsod_squished_left);
2803 SDL_FreeSurface(img_bsod_squished_right);
2805 SDL_FreeSurface(img_bsod_falling_left);
2806 SDL_FreeSurface(img_bsod_falling_right);
2808 for (i = 0; i < 3; i++)
2810 SDL_FreeSurface(img_laptop_left[i]);
2811 SDL_FreeSurface(img_laptop_right[i]);
2814 SDL_FreeSurface(img_laptop_flat_left);
2815 SDL_FreeSurface(img_laptop_flat_right);
2817 SDL_FreeSurface(img_laptop_falling_left);
2818 SDL_FreeSurface(img_laptop_falling_right);
2820 for (i = 0; i < 2; i++)
2822 SDL_FreeSurface(img_money_left[i]);
2823 SDL_FreeSurface(img_money_right[i]);
2826 SDL_FreeSurface(img_box_full);
2827 SDL_FreeSurface(img_box_empty);
2829 SDL_FreeSurface(img_water);
2830 for (i = 0; i < 3; i++)
2831 SDL_FreeSurface(img_waves[i]);
2833 SDL_FreeSurface(img_pole);
2834 SDL_FreeSurface(img_poletop);
2836 for (i = 0; i < 2; i++)
2837 SDL_FreeSurface(img_flag[i]);
2839 SDL_FreeSurface(img_mints);
2840 SDL_FreeSurface(img_coffee);
2842 for (i = 0; i < 4; i++)
2844 SDL_FreeSurface(img_distro[i]);
2845 SDL_FreeSurface(img_cloud[0][i]);
2846 SDL_FreeSurface(img_cloud[1][i]);
2849 SDL_FreeSurface(img_golden_herring);
2853 for (i = 0; i < NUM_SOUNDS; i++)
2854 Mix_FreeChunk(sounds[i]);
2859 /* Draw a tile on the screen: */
2861 void drawshape(int x, int y, unsigned char c)
2865 if (c == 'X' || c == 'x')
2866 drawimage(img_brick[0], x, y, NO_UPDATE);
2867 else if (c == 'Y' || c == 'y')
2868 drawimage(img_brick[1], x, y, NO_UPDATE);
2869 else if (c == 'A' || c =='B' || c == '!')
2870 drawimage(img_box_full, x, y, NO_UPDATE);
2872 drawimage(img_box_empty, x, y, NO_UPDATE);
2873 else if (c >= 'C' && c <= 'F')
2874 drawimage(img_cloud[0][c - 'C'], x, y, NO_UPDATE);
2875 else if (c >= 'c' && c <= 'f')
2876 drawimage(img_cloud[1][c - 'c'], x, y, NO_UPDATE);
2877 else if (c >= 'G' && c <= 'J')
2878 drawimage(img_bkgd[0][c - 'G'], x, y, NO_UPDATE);
2879 else if (c >= 'g' && c <= 'j')
2880 drawimage(img_bkgd[1][c - 'g'], x, y, NO_UPDATE);
2882 drawimage(img_solid[0], x, y, NO_UPDATE);
2884 drawimage(img_solid[1], x, y, NO_UPDATE);
2886 drawimage(img_solid[2], x, y, NO_UPDATE);
2888 drawimage(img_solid[3], x, y, NO_UPDATE);
2891 z = (frame / 2) % 6;
2894 drawimage(img_distro[z], x, y, NO_UPDATE);
2896 drawimage(img_distro[2], x, y, NO_UPDATE);
2898 drawimage(img_distro[1], x, y, NO_UPDATE);
2902 z = (frame / 3) % 3;
2904 drawimage(img_waves[z], x, y, NO_UPDATE);
2907 drawimage(img_poletop, x, y, NO_UPDATE);
2910 drawimage(img_pole, x, y, NO_UPDATE);
2912 /* Mark this as the end position of the level! */
2918 z = (frame / 3) % 2;
2920 drawimage(img_flag[z], x + 16, y, NO_UPDATE);
2923 drawimage(img_water, x, y, NO_UPDATE);
2927 /* What shape is at some position? */
2929 unsigned char shape(int x, int y, int sx)
2935 xx = ((x + sx) / 32);
2937 if (yy >= 0 && yy <= 15 && xx >= 0 && xx <= level_width)
2948 int issolid(int x, int y, int sx)
2954 if (isbrick(x, y, sx) ||
2955 isbrick(x + 31, y, sx) ||
2957 isice(x + 31, y, sx) ||
2958 (shape(x, y, sx) == '[' ||
2959 shape(x + 31, y, sx) == '[') ||
2960 (shape(x, y, sx) == '=' ||
2961 shape(x + 31, y, sx) == '=') ||
2962 (shape(x, y, sx) == ']' ||
2963 shape(x + 31, y, sx) == ']') ||
2964 (shape(x, y, sx) == 'A' ||
2965 shape(x + 31, y, sx) == 'A') ||
2966 (shape(x, y, sx) == 'B' ||
2967 shape(x + 31, y, sx) == 'B') ||
2968 (shape(x, y, sx) == '!' ||
2969 shape(x + 31, y, sx) == '!') ||
2970 (shape(x, y, sx) == 'a' ||
2971 shape(x + 31, y, sx) == 'a'))
2980 /* Is it a brick? */
2982 int isbrick(int x, int y, int sx)
2988 if (shape(x, y, sx) == 'X' ||
2989 shape(x, y, sx) == 'x' ||
2990 shape(x, y, sx) == 'Y' ||
2991 shape(x, y, sx) == 'y')
3002 int isice(int x, int y, int sx)
3008 if (shape(x, y, sx) == '#')
3017 /* Is it a full box? */
3019 int isfullbox(int x, int y, int sx)
3025 if (shape(x, y, sx) == 'A' ||
3026 shape(x, y, sx) == 'B' ||
3027 shape(x, y, sx) == '!')
3036 /* Edit a piece of the map! */
3038 void change(int x, int y, int sx, unsigned char c)
3043 xx = ((x + sx) / 32);
3045 if (yy >= 0 && yy <= 15 && xx >= 0 && xx <= level_width)
3050 /* Break a brick: */
3052 void trybreakbrick(int x, int y, int sx)
3054 if (isbrick(x, y, sx))
3056 if (shape(x, y, sx) == 'x' || shape(x, y, sx) == 'y')
3058 /* Get a distro from it: */
3060 add_bouncy_distro(((x + sx + 1) / 32) * 32,
3063 if (counting_distros == NO)
3065 counting_distros = YES;
3066 distro_counter = 50;
3069 if (distro_counter <= 0)
3070 change(x, y, sx, 'a');
3072 playsound(sounds[SND_DISTRO]);
3073 score = score + SCORE_DISTRO;
3078 /* Get rid of it: */
3080 change(x, y, sx, '.');
3084 /* Replace it with broken bits: */
3086 add_broken_brick(((x + sx + 1) / 32) * 32,
3090 /* Get some score: */
3092 playsound(sounds[SND_BRICK]);
3093 score = score + SCORE_BRICK;
3098 /* Bounce a brick: */
3100 void bumpbrick(int x, int y, int sx)
3102 add_bouncy_brick(((x + sx + 1) / 32) * 32,
3105 playsound(sounds[SND_BRICK]);
3111 void tryemptybox(int x, int y, int sx)
3113 if (isfullbox(x, y, sx))
3115 if (shape(x, y, sx) == 'A')
3117 /* Box with a distro! */
3119 add_bouncy_distro(((x + sx + 1) / 32) * 32,
3120 (y / 32) * 32 - 32);
3122 playsound(sounds[SND_DISTRO]);
3123 score = score + SCORE_DISTRO;
3126 else if (shape(x, y, sx) == 'B')
3128 /* Add an upgrade! */
3130 if (tux_size == SMALL)
3132 /* Tux is small, add mints! */
3134 add_upgrade(((x + sx + 1) / 32) * 32,
3140 /* Tux is big, add coffee: */
3142 add_upgrade(((x + sx + 1) / 32) * 32,
3147 playsound(sounds[SND_UPGRADE]);
3149 else if (shape(x, y, sx) == '!')
3151 /* Add a golden herring */
3153 add_upgrade(((x + sx + 1) / 32) * 32,
3158 /* Empty the box: */
3160 change(x, y, sx, 'a');
3165 /* Try to grab a distro: */
3167 void trygrabdistro(int x, int y, int sx, int bounciness)
3169 if (shape(x, y, sx) == '$')
3171 change(x, y, sx, '.');
3172 playsound(sounds[SND_DISTRO]);
3174 if (bounciness == BOUNCE)
3176 add_bouncy_distro(((x + sx + 1) / 32) * 32,
3180 score = score + SCORE_DISTRO;
3186 /* Add a bouncy distro: */
3188 void add_bouncy_distro(int x, int y)
3194 for (i = 0; i < NUM_BOUNCY_DISTROS && found == -1; i++)
3196 if (!bouncy_distros[i].alive)
3202 bouncy_distros[found].alive = YES;
3203 bouncy_distros[found].x = x;
3204 bouncy_distros[found].y = y;
3205 bouncy_distros[found].ym = -6;
3210 /* Add broken brick pieces: */
3212 void add_broken_brick(int x, int y)
3214 add_broken_brick_piece(x, y, -4, -16);
3215 add_broken_brick_piece(x, y + 16, -6, -12);
3217 add_broken_brick_piece(x + 16, y, 4, -16);
3218 add_broken_brick_piece(x + 16, y + 16, 6, -12);
3222 /* Add a broken brick piece: */
3224 void add_broken_brick_piece(int x, int y, int xm, int ym)
3230 for (i = 0; i < NUM_BROKEN_BRICKS && found == -1; i++)
3232 if (!broken_bricks[i].alive)
3238 broken_bricks[found].alive = YES;
3239 broken_bricks[found].x = x;
3240 broken_bricks[found].y = y;
3241 broken_bricks[found].xm = xm;
3242 broken_bricks[found].ym = ym;
3247 /* Add a bouncy brick piece: */
3249 void add_bouncy_brick(int x, int y)
3255 for (i = 0; i < NUM_BOUNCY_BRICKS && found == -1; i++)
3257 if (!bouncy_bricks[i].alive)
3263 bouncy_bricks[found].alive = YES;
3264 bouncy_bricks[found].x = x;
3265 bouncy_bricks[found].y = y;
3266 bouncy_bricks[found].offset = 0;
3267 bouncy_bricks[found].offset_m = -BOUNCY_BRICK_SPEED;
3268 bouncy_bricks[found].shape = shape(x, y, 0);
3273 /* Add a bad guy: */
3275 void add_bad_guy(int x, int y, int kind)
3281 for (i = 0; i < NUM_BAD_GUYS && found == -1; i++)
3283 if (!bad_guys[i].alive)
3289 bad_guys[found].alive = YES;
3290 bad_guys[found].mode = NORMAL;
3291 bad_guys[found].dying = NO;
3292 bad_guys[found].timer = 0;
3293 bad_guys[found].kind = kind;
3294 bad_guys[found].x = x;
3295 bad_guys[found].y = y;
3296 bad_guys[found].xm = 0;
3297 bad_guys[found].ym = 0;
3298 bad_guys[found].dir = LEFT;
3299 bad_guys[found].seen = NO;
3306 void add_score(int x, int y, int s)
3311 /* Add the score: */
3316 /* Add a floating score thing to the game: */
3320 for (i = 0; i < NUM_FLOATING_SCORES && found == -1; i++)
3322 if (!floating_scores[i].alive)
3329 floating_scores[found].alive = YES;
3330 floating_scores[found].x = x;
3331 floating_scores[found].y = y - 16;
3332 floating_scores[found].timer = 8;
3333 floating_scores[found].value = s;
3338 /* Try to bump a bad guy from below: */
3340 void trybumpbadguy(int x, int y, int sx)
3347 for (i = 0; i < NUM_BAD_GUYS; i++)
3349 if (bad_guys[i].alive &&
3350 bad_guys[i].x >= x + sx - 32 && bad_guys[i].x <= x + sx + 32 &&
3351 bad_guys[i].y >= y - 16 && bad_guys[i].y <= y + 16)
3353 if (bad_guys[i].kind == BAD_BSOD ||
3354 bad_guys[i].kind == BAD_LAPTOP)
3356 bad_guys[i].dying = FALLING;
3357 bad_guys[i].ym = -8;
3358 playsound(sounds[SND_FALL]);
3366 for (i = 0; i < NUM_UPGRADES; i++)
3368 if (upgrades[i].alive && upgrades[i].height == 32 &&
3369 upgrades[i].x >= x + sx - 32 && upgrades[i].x <= x + sx + 32 &&
3370 upgrades[i].y >= y - 16 && upgrades[i].y <= y + 16)
3372 upgrades[i].xm = -upgrades[i].xm;
3373 upgrades[i].ym = -8;
3374 playsound(sounds[SND_BUMP_UPGRADE]);
3380 /* Add an upgrade: */
3382 void add_upgrade(int x, int y, int kind)
3388 for (i = 0; i < NUM_UPGRADES && found == -1; i++)
3390 if (!upgrades[i].alive)
3396 upgrades[found].alive = YES;
3397 upgrades[found].kind = kind;
3398 upgrades[found].x = x;
3399 upgrades[found].y = y;
3400 upgrades[found].xm = 4;
3401 upgrades[found].ym = -4;
3402 upgrades[found].height = 0;
3409 void killtux(int mode)
3413 playsound(sounds[SND_HURT]);
3415 if (tux_dir == RIGHT)
3417 else if (tux_dir == LEFT)
3420 if (mode == SHRINK && tux_size == BIG)
3423 tux_got_coffee = NO;
3427 tux_safe = TUX_SAFE_TIME;
3438 void add_bullet(int x, int y, int dir, int xm)
3444 for (i = 0; i < NUM_BULLETS && found == -1; i++)
3446 if (!bullets[i].alive)
3452 bullets[found].alive = YES;
3456 bullets[found].x = x + 32;
3457 bullets[found].xm = BULLET_XM + xm;
3461 bullets[found].x = x;
3462 bullets[found].xm = -BULLET_XM + xm;
3465 bullets[found].y = y;
3466 bullets[found].ym = BULLET_STARTING_YM;
3468 playsound(sounds[SND_SHOOT]);
3473 void drawendscreen(void)
3477 clearscreen(0, 0, 0);
3479 drawcenteredtext("GAMEOVER", 200, letters_red, NO_UPDATE);
3481 sprintf(str, "SCORE: %d", score);
3482 drawcenteredtext(str, 224, letters_gold, NO_UPDATE);
3484 sprintf(str, "DISTROS: %d", distros);
3485 drawcenteredtext(str, 256, letters_blue, NO_UPDATE);
3491 void drawresultscreen(void)
3495 clearscreen(0, 0, 0);
3497 drawcenteredtext("Result:", 200, letters_red, NO_UPDATE);
3499 sprintf(str, "SCORE: %d", score);
3500 drawcenteredtext(str, 224, letters_gold, NO_UPDATE);
3502 sprintf(str, "DISTROS: %d", distros);
3503 drawcenteredtext(str, 256, letters_blue, NO_UPDATE);