1 /* second part of synchro.
3 * game logic for monsters.
5 * one giant switch statement to process everything.
7 * this whole thing is a major bottleneck. the compiler must use registers.
14 #define RANDOM (random = random << 31 | random >> 1)
16 static void set_nearest_player_xy(int x, int y, int *dx, int *dy)
18 int distance, distance_shortest = EM_MAX_CAVE_WIDTH + EM_MAX_CAVE_HEIGHT;
21 /* default values if no players are alive anymore */
25 for (i = 0; i < MAX_PLAYERS; i++)
30 distance = ABS(ply[i].x - x) + ABS(ply[i].y - y);
32 if (distance < distance_shortest)
37 distance_shortest = distance;
46 unsigned int random = RandomEM;
47 short *cave_cache = Cave[y]; /* might be a win */
50 int temp = 0; /* initialized to make compilers happy */
51 int dx; /* only needed to find closest player */
57 element = cave_cache[++x];
64 /* --------------------------------------------------------------------- */
83 Cave[y][x] = Ystone_eB;
84 Cave[y][x+1] = Ystone_e;
86 Next[y][x+1] = Xstone_pause;
106 Cave[y][x] = Ystone_wB;
107 Cave[y][x-1] = Ystone_w;
109 Next[y][x-1] = Xstone_pause;
114 switch (Cave[y][x+1])
129 Cave[y][x] = Ynut_eB;
130 Cave[y][x+1] = Ynut_e;
132 Next[y][x+1] = Xnut_pause;
137 switch (Cave[y][x-1])
152 Cave[y][x] = Ynut_wB;
153 Cave[y][x-1] = Ynut_w;
155 Next[y][x-1] = Xnut_pause;
159 case Xspring_force_e:
160 switch (Cave[y][x+1])
170 Cave[y][x] = Xspring;
171 Next[y][x] = Xspring;
175 Cave[y][x] = Yspring_eB;
176 Cave[y][x+1] = Yspring_e;
180 Next[y][x+1] = Xspring_e;
182 Next[y][x+1] = Xspring_pause;
188 case Xspring_force_w:
189 switch (Cave[y][x-1])
199 Cave[y][x] = Xspring;
200 Next[y][x] = Xspring;
204 Cave[y][x] = Yspring_wB;
205 Cave[y][x-1] = Yspring_w;
209 Next[y][x-1] = Xspring_w;
211 Next[y][x-1] = Xspring_pause;
216 case Xemerald_force_e:
217 switch (Cave[y][x+1])
227 Cave[y][x] = Xemerald;
228 Next[y][x] = Xemerald;
232 Cave[y][x] = Yemerald_eB;
233 Cave[y][x+1] = Yemerald_e;
235 Next[y][x+1] = Xemerald_pause;
239 case Xemerald_force_w:
240 switch (Cave[y][x-1])
250 Cave[y][x] = Xemerald;
251 Next[y][x] = Xemerald;
255 Cave[y][x] = Yemerald_wB;
256 Cave[y][x-1] = Yemerald_w;
258 Next[y][x-1] = Xemerald_pause;
262 case Xdiamond_force_e:
263 switch (Cave[y][x+1])
273 Cave[y][x] = Xdiamond;
274 Next[y][x] = Xdiamond;
278 Cave[y][x] = Ydiamond_eB;
279 Cave[y][x+1] = Ydiamond_e;
281 Next[y][x+1] = Xdiamond_pause;
285 case Xdiamond_force_w:
286 switch (Cave[y][x-1])
296 Cave[y][x] = Xdiamond;
297 Next[y][x] = Xdiamond;
301 Cave[y][x] = Ydiamond_wB;
302 Cave[y][x-1] = Ydiamond_w;
304 Next[y][x-1] = Xdiamond_pause;
309 switch (Cave[y][x+1])
324 Cave[y][x] = Ybomb_eB;
325 Cave[y][x+1] = Ybomb_e;
327 Next[y][x+1] = Xbomb_pause;
332 switch (Cave[y][x-1])
347 Cave[y][x] = Ybomb_wB;
348 Cave[y][x-1] = Ybomb_w;
350 Next[y][x-1] = Xbomb_pause;
353 #endif /* BAD_ROLL */
355 /* --------------------------------------------------------------------- */
358 switch (Cave[y+1][x])
368 Cave[y][x] = Ystone_sB;
369 if (Cave[y][x+1] == Xblank)
370 Cave[y][x+1] = Yacid_splash_eB;
371 if (Cave[y][x-1] == Xblank)
372 Cave[y][x-1] = Yacid_splash_wB;
374 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
378 case Yacid_splash_eB:
379 case Yacid_splash_wB:
392 Cave[y][x] = Ystone_sB;
393 Cave[y+1][x] = Ystone_s;
395 Next[y+1][x] = Xstone_fall;
399 Cave[y][x] = Xsand_stonein_1;
400 Cave[y+1][x] = Xsand_sandstone_1;
401 Next[y][x] = Xsand_stonein_2;
402 Next[y+1][x] = Xsand_sandstone_2;
453 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
455 Cave[y][x] = Ystone_eB;
456 Cave[y][x+1] = Ystone_e;
458 Next[y][x+1] = Xstone_pause;
462 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
464 Cave[y][x] = Ystone_wB;
465 Cave[y][x-1] = Ystone_w;
467 Next[y][x-1] = Xstone_pause;
473 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
475 Cave[y][x] = Ystone_wB;
476 Cave[y][x-1] = Ystone_w;
478 Next[y][x-1] = Xstone_pause;
482 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
484 Cave[y][x] = Ystone_eB;
485 Cave[y][x+1] = Ystone_e;
487 Next[y][x+1] = Xstone_pause;
496 /* --------------------------------------------------------------------- */
499 switch (Cave[y+1][x])
509 Cave[y][x] = Ystone_sB;
510 if (Cave[y][x+1] == Xblank)
511 Cave[y][x+1] = Yacid_splash_eB;
512 if (Cave[y][x-1] == Xblank)
513 Cave[y][x-1] = Yacid_splash_wB;
515 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
519 case Yacid_splash_eB:
520 case Yacid_splash_wB:
531 Cave[y][x] = Ystone_sB;
532 Cave[y+1][x] = Ystone_s;
534 Next[y+1][x] = Xstone_fall;
543 /* --------------------------------------------------------------------- */
546 switch (Cave[y+1][x])
556 Cave[y][x] = Ystone_sB;
557 if (Cave[y][x+1] == Xblank)
558 Cave[y][x+1] = Yacid_splash_eB;
559 if (Cave[y][x-1] == Xblank)
560 Cave[y][x-1] = Yacid_splash_wB;
562 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
566 case Yacid_splash_eB:
567 case Yacid_splash_wB:
579 Cave[y][x] = Ystone_sB;
580 Cave[y+1][x] = Ystone_s;
582 Next[y+1][x] = Xstone_fall;
587 Cave[y+1][x] = Yemerald_stone;
589 Next[y+1][x] = Xemerald;
590 play_element_sound(x, y, SAMPLE_crack, Xnut);
591 score += lev.nut_score;
602 Cave[y][x] = Ystone_sB;
603 Cave[y+1][x] = Ybug_stone;
604 Next[y+1][x] = Znormal;
605 Boom[y][x-1] = Xemerald;
606 Boom[y][x] = Xemerald;
607 Boom[y][x+1] = Xemerald;
608 Boom[y+1][x-1] = Xemerald;
609 Boom[y+1][x] = Xdiamond;
610 Boom[y+1][x+1] = Xemerald;
611 Boom[y+2][x-1] = Xemerald;
612 Boom[y+2][x] = Xemerald;
613 Boom[y+2][x+1] = Xemerald;
614 #if PLAY_ELEMENT_SOUND
615 play_element_sound(x, y, SAMPLE_boom, element);
617 score += lev.bug_score;
628 Cave[y][x] = Ystone_sB;
629 Cave[y+1][x] = Ytank_stone;
630 Next[y+1][x] = Znormal;
631 Boom[y][x-1] = Xblank;
633 Boom[y][x+1] = Xblank;
634 Boom[y+1][x-1] = Xblank;
635 Boom[y+1][x] = Xblank;
636 Boom[y+1][x+1] = Xblank;
637 Boom[y+2][x-1] = Xblank;
638 Boom[y+2][x] = Xblank;
639 Boom[y+2][x+1] = Xblank;
640 #if PLAY_ELEMENT_SOUND
641 play_element_sound(x, y, SAMPLE_boom, element);
643 score += lev.tank_score;
649 switch (Cave[y+1][x+1])
652 case Yacid_splash_eB:
653 case Yacid_splash_wB:
656 Cave[y+1][x] = Xspring_e;
660 Cave[y+1][x] = Xspring_w;
666 switch (Cave[y+1][x-1])
669 case Yacid_splash_eB:
670 case Yacid_splash_wB:
673 Cave[y+1][x] = Xspring_w;
676 Cave[y+1][x] = Xspring_e;
688 Cave[y][x] = Ystone_sB;
689 Cave[y+1][x] = Yeater_stone;
690 Next[y+1][x] = Znormal;
691 Boom[y][x-1] = lev.eater_array[lev.eater_pos][0];
692 Boom[y][x] = lev.eater_array[lev.eater_pos][1];
693 Boom[y][x+1] = lev.eater_array[lev.eater_pos][2];
694 Boom[y+1][x-1] = lev.eater_array[lev.eater_pos][3];
695 Boom[y+1][x] = lev.eater_array[lev.eater_pos][4];
696 Boom[y+1][x+1] = lev.eater_array[lev.eater_pos][5];
697 Boom[y+2][x-1] = lev.eater_array[lev.eater_pos][6];
698 Boom[y+2][x] = lev.eater_array[lev.eater_pos][7];
699 Boom[y+2][x+1] = lev.eater_array[lev.eater_pos][8];
700 #if PLAY_ELEMENT_SOUND
701 play_element_sound(x, y, SAMPLE_boom, element);
703 lev.eater_pos = (lev.eater_pos + 1) & 7;
704 score += lev.eater_score;
709 Cave[y][x] = Ystone_sB;
710 Cave[y+1][x] = Yalien_stone;
711 Next[y+1][x] = Znormal;
712 Boom[y][x-1] = Xblank;
714 Boom[y][x+1] = Xblank;
715 Boom[y+1][x-1] = Xblank;
716 Boom[y+1][x] = Xblank;
717 Boom[y+1][x+1] = Xblank;
718 Boom[y+2][x-1] = Xblank;
719 Boom[y+2][x] = Xblank;
720 Boom[y+2][x+1] = Xblank;
721 #if PLAY_ELEMENT_SOUND
722 play_element_sound(x, y, SAMPLE_boom, element);
724 score += lev.alien_score;
729 switch (Cave[y+2][x])
732 case Yacid_splash_eB:
733 case Yacid_splash_wB:
778 play_element_sound(x, y, SAMPLE_stone, Xstone);
782 Cave[y][x] = Ystone_sB;
783 Cave[y+1][x] = Ydiamond_stone;
785 Next[y+1][x] = Xstone_pause;
786 play_element_sound(x, y, SAMPLE_squash, Xdiamond);
791 Cave[y+1][x] = Ybomb_eat;
792 Next[y+1][x] = Znormal;
793 Boom[y][x-1] = Xblank;
795 Boom[y][x+1] = Xblank;
796 Boom[y+1][x-1] = Xblank;
797 Boom[y+1][x] = Xblank;
798 Boom[y+1][x+1] = Xblank;
799 Boom[y+2][x-1] = Xblank;
800 Boom[y+2][x] = Xblank;
801 Boom[y+2][x+1] = Xblank;
802 #if PLAY_ELEMENT_SOUND
803 play_element_sound(x, y, SAMPLE_boom, element);
808 if (lev.wonderwall_time)
810 lev.wonderwall_state = 1;
811 Cave[y][x] = Ystone_sB;
813 if (tab_blank[Cave[y+2][x]])
815 Cave[y+2][x] = Yemerald_s;
816 Next[y+2][x] = Xemerald_fall;
820 play_element_sound(x, y, SAMPLE_wonderfall, Xwonderwall);
827 play_element_sound(x, y, SAMPLE_stone, Xstone);
831 /* --------------------------------------------------------------------- */
834 switch (Cave[y+1][x])
844 Cave[y][x] = Ynut_sB;
845 if (Cave[y][x+1] == Xblank)
846 Cave[y][x+1] = Yacid_splash_eB;
847 if (Cave[y][x-1] == Xblank)
848 Cave[y][x-1] = Yacid_splash_wB;
850 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
854 case Yacid_splash_eB:
855 case Yacid_splash_wB:
856 Cave[y][x] = Ynut_sB;
857 Cave[y+1][x] = Ynut_s;
859 Next[y+1][x] = Xnut_fall;
908 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
910 Cave[y][x] = Ynut_eB;
911 Cave[y][x+1] = Ynut_e;
913 Next[y][x+1] = Xnut_pause;
917 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
919 Cave[y][x] = Ynut_wB;
920 Cave[y][x-1] = Ynut_w;
922 Next[y][x-1] = Xnut_pause;
928 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
930 Cave[y][x] = Ynut_wB;
931 Cave[y][x-1] = Ynut_w;
933 Next[y][x-1] = Xnut_pause;
937 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
939 Cave[y][x] = Ynut_eB;
940 Cave[y][x+1] = Ynut_e;
942 Next[y][x+1] = Xnut_pause;
951 /* --------------------------------------------------------------------- */
955 switch (Cave[y+1][x])
965 Cave[y][x] = Ynut_sB;
966 if (Cave[y][x+1] == Xblank)
967 Cave[y][x+1] = Yacid_splash_eB;
968 if (Cave[y][x-1] == Xblank)
969 Cave[y][x-1] = Yacid_splash_wB;
971 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
975 case Yacid_splash_eB:
976 case Yacid_splash_wB:
977 Cave[y][x] = Ynut_sB;
978 Cave[y+1][x] = Ynut_s;
980 Next[y+1][x] = Xnut_fall;
989 /* --------------------------------------------------------------------- */
992 switch (Cave[y+1][x])
1002 Cave[y][x] = Ynut_sB;
1003 if (Cave[y][x+1] == Xblank)
1004 Cave[y][x+1] = Yacid_splash_eB;
1005 if (Cave[y][x-1] == Xblank)
1006 Cave[y][x-1] = Yacid_splash_wB;
1007 Next[y][x] = Xblank;
1008 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
1012 case Yacid_splash_eB:
1013 case Yacid_splash_wB:
1015 Cave[y][x] = Ynut_sB;
1016 Cave[y+1][x] = Ynut_s;
1017 Next[y][x] = Xblank;
1018 Next[y+1][x] = Xnut_fall;
1024 play_element_sound(x, y, SAMPLE_nut, Xnut);
1028 /* --------------------------------------------------------------------- */
1031 if (tab_amoeba[Cave[y-1][x]] ||
1032 tab_amoeba[Cave[y][x+1]] ||
1033 tab_amoeba[Cave[y+1][x]] ||
1034 tab_amoeba[Cave[y][x-1]])
1037 switch (Cave[y][x+1])
1040 case Yacid_splash_eB:
1041 case Yacid_splash_wB:
1053 Cave[y][x] = Ybug_n_e;
1054 Next[y][x] = Xbug_goe;
1055 play_element_sound(x, y, SAMPLE_bug, element);
1063 if (tab_amoeba[Cave[y-1][x]] ||
1064 tab_amoeba[Cave[y][x+1]] ||
1065 tab_amoeba[Cave[y+1][x]] ||
1066 tab_amoeba[Cave[y][x-1]])
1071 switch (Cave[y-1][x])
1081 Cave[y][x] = Ybug_nB;
1082 if (Cave[y-2][x+1] == Xblank)
1083 Cave[y-2][x+1] = Yacid_splash_eB;
1084 if (Cave[y-2][x-1] == Xblank)
1085 Cave[y-2][x-1] = Yacid_splash_wB;
1086 Next[y][x] = Xblank;
1087 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
1091 case Yacid_splash_eB:
1092 case Yacid_splash_wB:
1096 Cave[y][x] = Ybug_nB;
1097 Cave[y-1][x] = Ybug_n;
1098 Next[y][x] = Xblank;
1099 Next[y-1][x] = Xbug_n;
1100 play_element_sound(x, y, SAMPLE_bug, element);
1104 Cave[y][x] = Ybug_n_w;
1105 Next[y][x] = Xbug_gow;
1106 play_element_sound(x, y, SAMPLE_bug, element);
1110 /* --------------------------------------------------------------------- */
1113 if (tab_amoeba[Cave[y-1][x]] ||
1114 tab_amoeba[Cave[y][x+1]] ||
1115 tab_amoeba[Cave[y+1][x]] ||
1116 tab_amoeba[Cave[y][x-1]])
1119 switch (Cave[y+1][x])
1122 case Yacid_splash_eB:
1123 case Yacid_splash_wB:
1135 Cave[y][x] = Ybug_e_s;
1136 Next[y][x] = Xbug_gos;
1137 play_element_sound(x, y, SAMPLE_bug, element);
1145 if (tab_amoeba[Cave[y-1][x]] ||
1146 tab_amoeba[Cave[y][x+1]] ||
1147 tab_amoeba[Cave[y+1][x]] ||
1148 tab_amoeba[Cave[y][x-1]])
1153 switch (Cave[y][x+1])
1163 Cave[y][x] = Ybug_eB;
1164 if (Cave[y-1][x+2] == Xblank)
1165 Cave[y-1][x+2] = Yacid_splash_eB;
1166 if (Cave[y-1][x] == Xblank)
1167 Cave[y-1][x] = Yacid_splash_wB;
1168 Next[y][x] = Xblank;
1169 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
1173 case Yacid_splash_eB:
1174 case Yacid_splash_wB:
1178 Cave[y][x] = Ybug_eB;
1179 Cave[y][x+1] = Ybug_e;
1180 Next[y][x] = Xblank;
1181 Next[y][x+1] = Xbug_e;
1182 play_element_sound(x, y, SAMPLE_bug, element);
1186 Cave[y][x] = Ybug_e_n;
1187 Next[y][x] = Xbug_gon;
1188 play_element_sound(x, y, SAMPLE_bug, element);
1192 /* --------------------------------------------------------------------- */
1195 if (tab_amoeba[Cave[y-1][x]] ||
1196 tab_amoeba[Cave[y][x+1]] ||
1197 tab_amoeba[Cave[y+1][x]] ||
1198 tab_amoeba[Cave[y][x-1]])
1201 switch (Cave[y][x-1])
1204 case Yacid_splash_eB:
1205 case Yacid_splash_wB:
1217 Cave[y][x] = Ybug_s_w;
1218 Next[y][x] = Xbug_gow;
1219 play_element_sound(x, y, SAMPLE_bug, element);
1227 if (tab_amoeba[Cave[y-1][x]] ||
1228 tab_amoeba[Cave[y][x+1]] ||
1229 tab_amoeba[Cave[y+1][x]] ||
1230 tab_amoeba[Cave[y][x-1]])
1235 switch (Cave[y+1][x])
1245 Cave[y][x] = Ybug_sB;
1246 if (Cave[y][x+1] == Xblank)
1247 Cave[y][x+1] = Yacid_splash_eB;
1248 if (Cave[y][x-1] == Xblank)
1249 Cave[y][x-1] = Yacid_splash_wB;
1250 Next[y][x] = Xblank;
1251 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
1255 case Yacid_splash_eB:
1256 case Yacid_splash_wB:
1260 Cave[y][x] = Ybug_sB;
1261 Cave[y+1][x] = Ybug_s;
1262 Next[y][x] = Xblank;
1263 Next[y+1][x] = Xbug_s;
1264 play_element_sound(x, y, SAMPLE_bug, element);
1268 Cave[y][x] = Ybug_s_e;
1269 Next[y][x] = Xbug_goe;
1270 play_element_sound(x, y, SAMPLE_bug, element);
1274 /* --------------------------------------------------------------------- */
1277 if (tab_amoeba[Cave[y-1][x]] ||
1278 tab_amoeba[Cave[y][x+1]] ||
1279 tab_amoeba[Cave[y+1][x]] ||
1280 tab_amoeba[Cave[y][x-1]])
1283 switch (Cave[y-1][x])
1286 case Yacid_splash_eB:
1287 case Yacid_splash_wB:
1299 Cave[y][x] = Ybug_w_n;
1300 Next[y][x] = Xbug_gon;
1301 play_element_sound(x, y, SAMPLE_bug, element);
1309 if (tab_amoeba[Cave[y-1][x]] ||
1310 tab_amoeba[Cave[y][x+1]] ||
1311 tab_amoeba[Cave[y+1][x]] ||
1312 tab_amoeba[Cave[y][x-1]])
1317 switch (Cave[y][x-1])
1327 Cave[y][x] = Ybug_wB;
1328 if (Cave[y-1][x] == Xblank)
1329 Cave[y-1][x] = Yacid_splash_eB;
1330 if (Cave[y-1][x-2] == Xblank)
1331 Cave[y-1][x-2] = Yacid_splash_wB;
1332 Next[y][x] = Xblank;
1333 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
1337 case Yacid_splash_eB:
1338 case Yacid_splash_wB:
1342 Cave[y][x] = Ybug_wB;
1343 Cave[y][x-1] = Ybug_w;
1344 Next[y][x] = Xblank;
1345 Next[y][x-1] = Xbug_w;
1346 play_element_sound(x, y, SAMPLE_bug, element);
1350 Cave[y][x] = Ybug_w_s;
1351 Next[y][x] = Xbug_gos;
1352 play_element_sound(x, y, SAMPLE_bug, element);
1356 /* --------------------------------------------------------------------- */
1359 if (tab_amoeba[Cave[y-1][x]] ||
1360 tab_amoeba[Cave[y][x+1]] ||
1361 tab_amoeba[Cave[y+1][x]] ||
1362 tab_amoeba[Cave[y][x-1]])
1365 switch (Cave[y][x-1])
1368 case Yacid_splash_eB:
1369 case Yacid_splash_wB:
1381 Cave[y][x] = Ytank_n_w;
1382 Next[y][x] = Xtank_gow;
1383 play_element_sound(x, y, SAMPLE_tank, element);
1391 if (tab_amoeba[Cave[y-1][x]] ||
1392 tab_amoeba[Cave[y][x+1]] ||
1393 tab_amoeba[Cave[y+1][x]] ||
1394 tab_amoeba[Cave[y][x-1]])
1399 switch (Cave[y-1][x])
1409 Cave[y][x] = Ytank_nB;
1410 if (Cave[y-2][x+1] == Xblank)
1411 Cave[y-2][x+1] = Yacid_splash_eB;
1412 if (Cave[y-2][x-1] == Xblank)
1413 Cave[y-2][x-1] = Yacid_splash_wB;
1414 Next[y][x] = Xblank;
1415 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
1419 case Yacid_splash_eB:
1420 case Yacid_splash_wB:
1424 Cave[y][x] = Ytank_nB;
1425 Cave[y-1][x] = Ytank_n;
1426 Next[y][x] = Xblank;
1427 Next[y-1][x] = Xtank_n;
1428 play_element_sound(x, y, SAMPLE_tank, element);
1432 Cave[y][x] = Ytank_n_e;
1433 Next[y][x] = Xtank_goe;
1434 play_element_sound(x, y, SAMPLE_tank, element);
1438 /* --------------------------------------------------------------------- */
1441 if (tab_amoeba[Cave[y-1][x]] ||
1442 tab_amoeba[Cave[y][x+1]] ||
1443 tab_amoeba[Cave[y+1][x]] ||
1444 tab_amoeba[Cave[y][x-1]])
1447 switch (Cave[y-1][x])
1450 case Yacid_splash_eB:
1451 case Yacid_splash_wB:
1463 Cave[y][x] = Ytank_e_n;
1464 Next[y][x] = Xtank_gon;
1465 play_element_sound(x, y, SAMPLE_tank, element);
1473 if (tab_amoeba[Cave[y-1][x]] ||
1474 tab_amoeba[Cave[y][x+1]] ||
1475 tab_amoeba[Cave[y+1][x]] ||
1476 tab_amoeba[Cave[y][x-1]])
1481 switch (Cave[y][x+1])
1491 Cave[y][x] = Ytank_eB;
1492 if (Cave[y-1][x+2] == Xblank)
1493 Cave[y-1][x+2] = Yacid_splash_eB;
1494 if (Cave[y-1][x] == Xblank)
1495 Cave[y-1][x] = Yacid_splash_wB;
1496 Next[y][x] = Xblank;
1497 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
1501 case Yacid_splash_eB:
1502 case Yacid_splash_wB:
1506 Cave[y][x] = Ytank_eB;
1507 Cave[y][x+1] = Ytank_e;
1508 Next[y][x] = Xblank;
1509 Next[y][x+1] = Xtank_e;
1510 play_element_sound(x, y, SAMPLE_tank, element);
1514 Cave[y][x] = Ytank_e_s;
1515 Next[y][x] = Xtank_gos;
1516 play_element_sound(x, y, SAMPLE_tank, element);
1520 /* --------------------------------------------------------------------- */
1523 if (tab_amoeba[Cave[y-1][x]] ||
1524 tab_amoeba[Cave[y][x+1]] ||
1525 tab_amoeba[Cave[y+1][x]] ||
1526 tab_amoeba[Cave[y][x-1]])
1529 switch (Cave[y][x+1])
1532 case Yacid_splash_eB:
1533 case Yacid_splash_wB:
1545 Cave[y][x] = Ytank_s_e;
1546 Next[y][x] = Xtank_goe;
1547 play_element_sound(x, y, SAMPLE_tank, element);
1555 if (tab_amoeba[Cave[y-1][x]] ||
1556 tab_amoeba[Cave[y][x+1]] ||
1557 tab_amoeba[Cave[y+1][x]] ||
1558 tab_amoeba[Cave[y][x-1]])
1563 switch (Cave[y+1][x])
1573 Cave[y][x] = Ytank_sB;
1574 if (Cave[y][x+1] == Xblank)
1575 Cave[y][x+1] = Yacid_splash_eB;
1576 if (Cave[y][x-1] == Xblank)
1577 Cave[y][x-1] = Yacid_splash_wB;
1578 Next[y][x] = Xblank;
1579 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
1583 case Yacid_splash_eB:
1584 case Yacid_splash_wB:
1588 Cave[y][x] = Ytank_sB;
1589 Cave[y+1][x] = Ytank_s;
1590 Next[y][x] = Xblank;
1591 Next[y+1][x] = Xtank_s;
1592 play_element_sound(x, y, SAMPLE_tank, element);
1596 Cave[y][x] = Ytank_s_w;
1597 Next[y][x] = Xtank_gow;
1598 play_element_sound(x, y, SAMPLE_tank, element);
1602 /* --------------------------------------------------------------------- */
1605 if (tab_amoeba[Cave[y-1][x]] ||
1606 tab_amoeba[Cave[y][x+1]] ||
1607 tab_amoeba[Cave[y+1][x]] ||
1608 tab_amoeba[Cave[y][x-1]])
1611 switch (Cave[y+1][x])
1614 case Yacid_splash_eB:
1615 case Yacid_splash_wB:
1627 Cave[y][x] = Ytank_w_s;
1628 Next[y][x] = Xtank_gos;
1629 play_element_sound(x, y, SAMPLE_tank, element);
1637 if (tab_amoeba[Cave[y-1][x]] ||
1638 tab_amoeba[Cave[y][x+1]] ||
1639 tab_amoeba[Cave[y+1][x]] ||
1640 tab_amoeba[Cave[y][x-1]])
1645 switch (Cave[y][x-1])
1655 Cave[y][x] = Ytank_wB;
1656 if (Cave[y-1][x] == Xblank)
1657 Cave[y-1][x] = Yacid_splash_eB;
1658 if (Cave[y-1][x-2] == Xblank)
1659 Cave[y-1][x-2] = Yacid_splash_wB;
1660 Next[y][x] = Xblank;
1661 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
1665 case Yacid_splash_eB:
1666 case Yacid_splash_wB:
1670 Cave[y][x] = Ytank_wB;
1671 Cave[y][x-1] = Ytank_w;
1672 Next[y][x] = Xblank;
1673 Next[y][x-1] = Xtank_w;
1674 play_element_sound(x, y, SAMPLE_tank, element);
1678 Cave[y][x] = Ytank_w_n;
1679 Next[y][x] = Xtank_gon;
1680 play_element_sound(x, y, SAMPLE_tank, element);
1684 /* --------------------------------------------------------------------- */
1690 if (lev.android_clone_cnt == 0)
1692 if (Cave[y-1][x-1] != Xblank &&
1693 Cave[y-1][x] != Xblank &&
1694 Cave[y-1][x+1] != Xblank &&
1695 Cave[y][x-1] != Xblank &&
1696 Cave[y][x+1] != Xblank &&
1697 Cave[y+1][x-1] != Xblank &&
1698 Cave[y+1][x] != Xblank &&
1699 Cave[y+1][x+1] != Xblank)
1704 /* randomly find an object to clone */
1706 case 0: /* S,NE,W,NW,SE,E,SW,N */
1707 temp= lev.android_array[Cave[y+1][x]]; if (temp != Xblank) break;
1708 temp= lev.android_array[Cave[y-1][x+1]]; if (temp != Xblank) break;
1709 temp= lev.android_array[Cave[y][x-1]]; if (temp != Xblank) break;
1710 temp= lev.android_array[Cave[y-1][x-1]]; if (temp != Xblank) break;
1711 temp= lev.android_array[Cave[y+1][x+1]]; if (temp != Xblank) break;
1712 temp= lev.android_array[Cave[y][x+1]]; if (temp != Xblank) break;
1713 temp= lev.android_array[Cave[y+1][x-1]]; if (temp != Xblank) break;
1714 temp= lev.android_array[Cave[y-1][x]]; if (temp != Xblank) break;
1717 case 1: /* NW,SE,N,S,NE,SW,E,W */
1718 temp= lev.android_array[Cave[y-1][x-1]]; if (temp != Xblank) break;
1719 temp= lev.android_array[Cave[y+1][x+1]]; if (temp != Xblank) break;
1720 temp= lev.android_array[Cave[y-1][x]]; if (temp != Xblank) break;
1721 temp= lev.android_array[Cave[y+1][x]]; if (temp != Xblank) break;
1722 temp= lev.android_array[Cave[y-1][x+1]]; if (temp != Xblank) break;
1723 temp= lev.android_array[Cave[y+1][x-1]]; if (temp != Xblank) break;
1724 temp= lev.android_array[Cave[y][x+1]]; if (temp != Xblank) break;
1725 temp= lev.android_array[Cave[y][x-1]]; if (temp != Xblank) break;
1728 case 2: /* SW,E,S,W,N,NW,SE,NE */
1729 temp= lev.android_array[Cave[y+1][x-1]]; if (temp != Xblank) break;
1730 temp= lev.android_array[Cave[y][x+1]]; if (temp != Xblank) break;
1731 temp= lev.android_array[Cave[y+1][x]]; if (temp != Xblank) break;
1732 temp= lev.android_array[Cave[y][x-1]]; if (temp != Xblank) break;
1733 temp= lev.android_array[Cave[y-1][x]]; if (temp != Xblank) break;
1734 temp= lev.android_array[Cave[y-1][x-1]]; if (temp != Xblank) break;
1735 temp= lev.android_array[Cave[y+1][x+1]]; if (temp != Xblank) break;
1736 temp= lev.android_array[Cave[y-1][x+1]]; if (temp != Xblank) break;
1739 case 3: /* N,SE,NE,E,W,S,NW,SW */
1740 temp= lev.android_array[Cave[y-1][x]]; if (temp != Xblank) break;
1741 temp= lev.android_array[Cave[y+1][x+1]]; if (temp != Xblank) break;
1742 temp= lev.android_array[Cave[y-1][x+1]]; if (temp != Xblank) break;
1743 temp= lev.android_array[Cave[y][x+1]]; if (temp != Xblank) break;
1744 temp= lev.android_array[Cave[y][x-1]]; if (temp != Xblank) break;
1745 temp= lev.android_array[Cave[y+1][x]]; if (temp != Xblank) break;
1746 temp= lev.android_array[Cave[y-1][x-1]]; if (temp != Xblank) break;
1747 temp= lev.android_array[Cave[y+1][x-1]]; if (temp != Xblank) break;
1750 case 4: /* SE,NW,E,NE,SW,W,N,S */
1751 temp= lev.android_array[Cave[y+1][x+1]]; if (temp != Xblank) break;
1752 temp= lev.android_array[Cave[y-1][x-1]]; if (temp != Xblank) break;
1753 temp= lev.android_array[Cave[y][x+1]]; if (temp != Xblank) break;
1754 temp= lev.android_array[Cave[y-1][x+1]]; if (temp != Xblank) break;
1755 temp= lev.android_array[Cave[y+1][x-1]]; if (temp != Xblank) break;
1756 temp= lev.android_array[Cave[y][x-1]]; if (temp != Xblank) break;
1757 temp= lev.android_array[Cave[y-1][x]]; if (temp != Xblank) break;
1758 temp= lev.android_array[Cave[y+1][x]]; if (temp != Xblank) break;
1761 case 5: /* NE,W,SE,SW,S,N,E,NW */
1762 temp= lev.android_array[Cave[y-1][x+1]]; if (temp != Xblank) break;
1763 temp= lev.android_array[Cave[y][x-1]]; if (temp != Xblank) break;
1764 temp= lev.android_array[Cave[y+1][x+1]]; if (temp != Xblank) break;
1765 temp= lev.android_array[Cave[y+1][x-1]]; if (temp != Xblank) break;
1766 temp= lev.android_array[Cave[y+1][x]]; if (temp != Xblank) break;
1767 temp= lev.android_array[Cave[y-1][x]]; if (temp != Xblank) break;
1768 temp= lev.android_array[Cave[y][x+1]]; if (temp != Xblank) break;
1769 temp= lev.android_array[Cave[y-1][x-1]]; if (temp != Xblank) break;
1772 case 6: /* E,N,SW,S,NW,NE,SE,W */
1773 temp= lev.android_array[Cave[y][x+1]]; if (temp != Xblank) break;
1774 temp= lev.android_array[Cave[y-1][x]]; if (temp != Xblank) break;
1775 temp= lev.android_array[Cave[y+1][x-1]]; if (temp != Xblank) break;
1776 temp= lev.android_array[Cave[y+1][x]]; if (temp != Xblank) break;
1777 temp= lev.android_array[Cave[y-1][x-1]]; if (temp != Xblank) break;
1778 temp= lev.android_array[Cave[y-1][x+1]]; if (temp != Xblank) break;
1779 temp= lev.android_array[Cave[y+1][x+1]]; if (temp != Xblank) break;
1780 temp= lev.android_array[Cave[y][x-1]]; if (temp != Xblank) break;
1783 case 7: /* W,SW,NW,N,E,SE,NE,S */
1784 temp= lev.android_array[Cave[y][x-1]]; if (temp != Xblank) break;
1785 temp= lev.android_array[Cave[y+1][x-1]]; if (temp != Xblank) break;
1786 temp= lev.android_array[Cave[y-1][x-1]]; if (temp != Xblank) break;
1787 temp= lev.android_array[Cave[y-1][x]]; if (temp != Xblank) break;
1788 temp= lev.android_array[Cave[y][x+1]]; if (temp != Xblank) break;
1789 temp= lev.android_array[Cave[y+1][x+1]]; if (temp != Xblank) break;
1790 temp= lev.android_array[Cave[y-1][x+1]]; if (temp != Xblank) break;
1791 temp= lev.android_array[Cave[y+1][x]]; if (temp != Xblank) break;
1795 Next[y][x] = temp; /* the item we chose to clone */
1796 play_element_sound(x, y, SAMPLE_android_clone, temp);
1800 /* randomly find a direction to move */
1802 case 0: /* S,NE,W,NW,SE,E,SW,N */
1803 if (Cave[y+1][x] == Xblank) goto android_s;
1804 if (Cave[y-1][x+1] == Xblank) goto android_ne;
1805 if (Cave[y][x-1] == Xblank) goto android_w;
1806 if (Cave[y-1][x-1] == Xblank) goto android_nw;
1807 if (Cave[y+1][x+1] == Xblank) goto android_se;
1808 if (Cave[y][x+1] == Xblank) goto android_e;
1809 if (Cave[y+1][x-1] == Xblank) goto android_sw;
1810 if (Cave[y-1][x] == Xblank) goto android_n;
1813 case 1: /* NW,SE,N,S,NE,SW,E,W */
1814 if (Cave[y-1][x-1] == Xblank) goto android_nw;
1815 if (Cave[y+1][x+1] == Xblank) goto android_se;
1816 if (Cave[y-1][x] == Xblank) goto android_n;
1817 if (Cave[y+1][x] == Xblank) goto android_s;
1818 if (Cave[y-1][x+1] == Xblank) goto android_ne;
1819 if (Cave[y+1][x-1] == Xblank) goto android_sw;
1820 if (Cave[y][x+1] == Xblank) goto android_e;
1821 if (Cave[y][x-1] == Xblank) goto android_w;
1824 case 2: /* SW,E,S,W,N,NW,SE,NE */
1825 if (Cave[y+1][x-1] == Xblank) goto android_sw;
1826 if (Cave[y][x+1] == Xblank) goto android_e;
1827 if (Cave[y+1][x] == Xblank) goto android_s;
1828 if (Cave[y][x-1] == Xblank) goto android_w;
1829 if (Cave[y-1][x] == Xblank) goto android_n;
1830 if (Cave[y-1][x-1] == Xblank) goto android_nw;
1831 if (Cave[y+1][x+1] == Xblank) goto android_se;
1832 if (Cave[y-1][x+1] == Xblank) goto android_ne;
1835 case 3: /* N,SE,NE,E,W,S,NW,SW */
1836 if (Cave[y-1][x] == Xblank) goto android_n;
1837 if (Cave[y+1][x+1] == Xblank) goto android_se;
1838 if (Cave[y-1][x+1] == Xblank) goto android_ne;
1839 if (Cave[y][x+1] == Xblank) goto android_e;
1840 if (Cave[y][x-1] == Xblank) goto android_w;
1841 if (Cave[y+1][x] == Xblank) goto android_s;
1842 if (Cave[y-1][x-1] == Xblank) goto android_nw;
1843 if (Cave[y+1][x-1] == Xblank) goto android_sw;
1846 case 4: /* SE,NW,E,NE,SW,W,N,S */
1847 if (Cave[y+1][x+1] == Xblank) goto android_se;
1848 if (Cave[y-1][x-1] == Xblank) goto android_nw;
1849 if (Cave[y][x+1] == Xblank) goto android_e;
1850 if (Cave[y-1][x+1] == Xblank) goto android_ne;
1851 if (Cave[y+1][x-1] == Xblank) goto android_sw;
1852 if (Cave[y][x-1] == Xblank) goto android_w;
1853 if (Cave[y-1][x] == Xblank) goto android_n;
1854 if (Cave[y+1][x] == Xblank) goto android_s;
1857 case 5: /* NE,W,SE,SW,S,N,E,NW */
1858 if (Cave[y-1][x+1] == Xblank) goto android_ne;
1859 if (Cave[y][x-1] == Xblank) goto android_w;
1860 if (Cave[y+1][x+1] == Xblank) goto android_se;
1861 if (Cave[y+1][x-1] == Xblank) goto android_sw;
1862 if (Cave[y+1][x] == Xblank) goto android_s;
1863 if (Cave[y-1][x] == Xblank) goto android_n;
1864 if (Cave[y][x+1] == Xblank) goto android_e;
1865 if (Cave[y-1][x-1] == Xblank) goto android_nw;
1868 case 6: /* E,N,SW,S,NW,NE,SE,W */
1869 if (Cave[y][x+1] == Xblank) goto android_e;
1870 if (Cave[y-1][x] == Xblank) goto android_n;
1871 if (Cave[y+1][x-1] == Xblank) goto android_sw;
1872 if (Cave[y+1][x] == Xblank) goto android_s;
1873 if (Cave[y-1][x-1] == Xblank) goto android_nw;
1874 if (Cave[y-1][x+1] == Xblank) goto android_ne;
1875 if (Cave[y+1][x+1] == Xblank) goto android_se;
1876 if (Cave[y][x-1] == Xblank) goto android_w;
1879 case 7: /* W,SW,NW,N,E,SE,NE,S */
1880 if (Cave[y][x-1] == Xblank) goto android_w;
1881 if (Cave[y+1][x-1] == Xblank) goto android_sw;
1882 if (Cave[y-1][x-1] == Xblank) goto android_nw;
1883 if (Cave[y-1][x] == Xblank) goto android_n;
1884 if (Cave[y][x+1] == Xblank) goto android_e;
1885 if (Cave[y+1][x+1] == Xblank) goto android_se;
1886 if (Cave[y-1][x+1] == Xblank) goto android_ne;
1887 if (Cave[y+1][x] == Xblank) goto android_s;
1893 if (lev.android_move_cnt == 0)
1895 if (Cave[y-1][x-1] == Zplayer ||
1896 Cave[y-1][x] == Zplayer ||
1897 Cave[y-1][x+1] == Zplayer ||
1898 Cave[y][x-1] == Zplayer ||
1899 Cave[y][x+1] == Zplayer ||
1900 Cave[y+1][x-1] == Zplayer ||
1901 Cave[y+1][x] == Zplayer ||
1902 Cave[y+1][x+1] == Zplayer)
1905 set_nearest_player_xy(x, y, &dx, &dy);
1907 Next[y][x] = Xblank; /* assume we will move */
1908 temp = ((x < dx) + 1 - (x > dx)) + ((y < dy) + 1 - (y > dy)) * 3;
1914 /* attempt clockwise move first if direct path is blocked */
1916 case 0: /* north west */
1917 if (tab_android_move[Cave[y-1][x-1]]) goto android_nw;
1918 if (tab_android_move[Cave[y-1][x]]) goto android_n;
1919 if (tab_android_move[Cave[y][x-1]]) goto android_w;
1923 if (tab_android_move[Cave[y-1][x]]) goto android_n;
1924 if (tab_android_move[Cave[y-1][x+1]]) goto android_ne;
1925 if (tab_android_move[Cave[y-1][x-1]]) goto android_nw;
1928 case 2: /* north east */
1929 if (tab_android_move[Cave[y-1][x+1]]) goto android_ne;
1930 if (tab_android_move[Cave[y][x+1]]) goto android_e;
1931 if (tab_android_move[Cave[y-1][x]]) goto android_n;
1935 if (tab_android_move[Cave[y][x-1]]) goto android_w;
1936 if (tab_android_move[Cave[y-1][x-1]]) goto android_nw;
1937 if (tab_android_move[Cave[y+1][x-1]]) goto android_sw;
1940 case 4: /* nowhere */
1944 if (tab_android_move[Cave[y][x+1]]) goto android_e;
1945 if (tab_android_move[Cave[y+1][x+1]]) goto android_se;
1946 if (tab_android_move[Cave[y-1][x+1]]) goto android_ne;
1949 case 6: /* south west */
1950 if (tab_android_move[Cave[y+1][x-1]]) goto android_sw;
1951 if (tab_android_move[Cave[y][x-1]]) goto android_w;
1952 if (tab_android_move[Cave[y+1][x]]) goto android_s;
1956 if (tab_android_move[Cave[y+1][x]]) goto android_s;
1957 if (tab_android_move[Cave[y+1][x-1]]) goto android_sw;
1958 if (tab_android_move[Cave[y+1][x+1]]) goto android_se;
1961 case 8: /* south east */
1962 if (tab_android_move[Cave[y+1][x+1]]) goto android_se;
1963 if (tab_android_move[Cave[y+1][x]]) goto android_s;
1964 if (tab_android_move[Cave[y][x+1]]) goto android_e;
1972 /* attempt counterclockwise move first if direct path is blocked */
1974 case 0: /* north west */
1975 if (tab_android_move[Cave[y-1][x-1]]) goto android_nw;
1976 if (tab_android_move[Cave[y][x-1]]) goto android_w;
1977 if (tab_android_move[Cave[y-1][x]]) goto android_n;
1981 if (tab_android_move[Cave[y-1][x]]) goto android_n;
1982 if (tab_android_move[Cave[y-1][x-1]]) goto android_nw;
1983 if (tab_android_move[Cave[y-1][x+1]]) goto android_ne;
1986 case 2: /* north east */
1987 if (tab_android_move[Cave[y-1][x+1]]) goto android_ne;
1988 if (tab_android_move[Cave[y-1][x]]) goto android_n;
1989 if (tab_android_move[Cave[y][x+1]]) goto android_e;
1993 if (tab_android_move[Cave[y][x-1]]) goto android_w;
1994 if (tab_android_move[Cave[y+1][x-1]]) goto android_sw;
1995 if (tab_android_move[Cave[y-1][x-1]]) goto android_nw;
1998 case 4: /* nowhere */
2002 if (tab_android_move[Cave[y][x+1]]) goto android_e;
2003 if (tab_android_move[Cave[y-1][x+1]]) goto android_ne;
2004 if (tab_android_move[Cave[y+1][x+1]]) goto android_se;
2007 case 6: /* south west */
2008 if (tab_android_move[Cave[y+1][x-1]]) goto android_sw;
2009 if (tab_android_move[Cave[y+1][x]]) goto android_s;
2010 if (tab_android_move[Cave[y][x-1]]) goto android_w;
2014 if (tab_android_move[Cave[y+1][x]]) goto android_s;
2015 if (tab_android_move[Cave[y+1][x+1]]) goto android_se;
2016 if (tab_android_move[Cave[y+1][x-1]]) goto android_sw;
2019 case 8: /* south east */
2020 if (tab_android_move[Cave[y+1][x+1]]) goto android_se;
2021 if (tab_android_move[Cave[y][x+1]]) goto android_e;
2022 if (tab_android_move[Cave[y+1][x]]) goto android_s;
2030 Next[y][x] = Xandroid;
2035 Cave[y][x] = Yandroid_nB;
2036 Cave[y-1][x] = Yandroid_n;
2037 Next[y-1][x] = Xandroid;
2038 play_element_sound(x, y, SAMPLE_android_move, element);
2043 Cave[y][x] = Yandroid_neB;
2044 Cave[y-1][x+1] = Yandroid_ne;
2045 Next[y-1][x+1] = Xandroid;
2046 play_element_sound(x, y, SAMPLE_android_move, element);
2051 Cave[y][x] = Yandroid_eB;
2052 Cave[y][x+1] = Yandroid_e;
2053 Next[y][x+1] = Xandroid;
2054 play_element_sound(x, y, SAMPLE_android_move, element);
2059 Cave[y][x] = Yandroid_seB;
2060 Cave[y+1][x+1] = Yandroid_se;
2061 Next[y+1][x+1] = Xandroid;
2062 play_element_sound(x, y, SAMPLE_android_move, element);
2067 Cave[y][x] = Yandroid_sB;
2068 Cave[y+1][x] = Yandroid_s;
2069 Next[y+1][x] = Xandroid;
2070 play_element_sound(x, y, SAMPLE_android_move, element);
2075 Cave[y][x] = Yandroid_swB;
2076 Cave[y+1][x-1] = Yandroid_sw;
2077 Next[y+1][x-1] = Xandroid;
2078 play_element_sound(x, y, SAMPLE_android_move, element);
2083 Cave[y][x] = Yandroid_wB;
2084 Cave[y][x-1] = Yandroid_w;
2085 Next[y][x-1] = Xandroid;
2086 play_element_sound(x, y, SAMPLE_android_move, element);
2091 Cave[y][x] = Yandroid_nwB;
2092 Cave[y-1][x-1] = Yandroid_nw;
2093 Next[y-1][x-1] = Xandroid;
2094 play_element_sound(x, y, SAMPLE_android_move, element);
2097 /* --------------------------------------------------------------------- */
2100 switch (Cave[y-1][x])
2110 Cave[y][x] = Yandroid_nB;
2111 if (Cave[y-2][x+1] == Xblank)
2112 Cave[y-2][x+1] = Yacid_splash_eB;
2113 if (Cave[y-2][x-1] == Xblank)
2114 Cave[y-2][x-1] = Yacid_splash_wB;
2115 Next[y][x] = Xblank;
2116 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
2120 case Yacid_splash_eB:
2121 case Yacid_splash_wB:
2122 Cave[y][x] = Yandroid_nB;
2123 Cave[y-1][x] = Yandroid_n;
2124 Next[y][x] = Xblank;
2125 Next[y-1][x] = Xandroid;
2126 play_element_sound(x, y, SAMPLE_android_move, element);
2134 switch (Cave[y-1][x])
2144 Cave[y][x] = Yandroid_nB;
2145 if (Cave[y-2][x+1] == Xblank)
2146 Cave[y-2][x+1] = Yacid_splash_eB;
2147 if (Cave[y-2][x-1] == Xblank)
2148 Cave[y-2][x-1] = Yacid_splash_wB;
2149 Next[y][x] = Xblank;
2150 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
2154 case Yacid_splash_eB:
2155 case Yacid_splash_wB:
2156 Cave[y][x] = Yandroid_nB;
2157 Cave[y-1][x] = Yandroid_n;
2158 Next[y][x] = Xblank;
2159 Next[y-1][x] = Xandroid_1_n;
2160 play_element_sound(x, y, SAMPLE_android_move, element);
2167 /* --------------------------------------------------------------------- */
2170 switch (Cave[y][x+1])
2180 Cave[y][x] = Yandroid_eB;
2181 if (Cave[y-1][x+2] == Xblank)
2182 Cave[y-1][x+2] = Yacid_splash_eB;
2183 if (Cave[y-1][x] == Xblank)
2184 Cave[y-1][x] = Yacid_splash_wB;
2185 Next[y][x] = Xblank;
2186 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
2190 case Yacid_splash_eB:
2191 case Yacid_splash_wB:
2192 Cave[y][x] = Yandroid_eB;
2193 Cave[y][x+1] = Yandroid_e;
2194 Next[y][x] = Xblank;
2195 Next[y][x+1] = Xandroid;
2196 play_element_sound(x, y, SAMPLE_android_move, element);
2204 switch (Cave[y][x+1])
2214 Cave[y][x] = Yandroid_eB;
2215 if (Cave[y-1][x+2] == Xblank)
2216 Cave[y-1][x+2] = Yacid_splash_eB;
2217 if (Cave[y-1][x] == Xblank)
2218 Cave[y-1][x] = Yacid_splash_wB;
2219 Next[y][x] = Xblank;
2220 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
2224 case Yacid_splash_eB:
2225 case Yacid_splash_wB:
2226 Cave[y][x] = Yandroid_eB;
2227 Cave[y][x+1] = Yandroid_e;
2228 Next[y][x] = Xblank;
2229 Next[y][x+1] = Xandroid_1_e;
2230 play_element_sound(x, y, SAMPLE_android_move, element);
2237 /* --------------------------------------------------------------------- */
2240 switch (Cave[y+1][x])
2250 Cave[y][x] = Yandroid_sB;
2251 if (Cave[y][x+1] == Xblank)
2252 Cave[y][x+1] = Yacid_splash_eB;
2253 if (Cave[y][x-1] == Xblank)
2254 Cave[y][x-1] = Yacid_splash_wB;
2255 Next[y][x] = Xblank;
2256 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
2260 case Yacid_splash_eB:
2261 case Yacid_splash_wB:
2262 Cave[y][x] = Yandroid_sB;
2263 Cave[y+1][x] = Yandroid_s;
2264 Next[y][x] = Xblank;
2265 Next[y+1][x] = Xandroid;
2266 play_element_sound(x, y, SAMPLE_android_move, element);
2274 switch (Cave[y+1][x])
2284 Cave[y][x] = Yandroid_sB;
2285 if (Cave[y][x+1] == Xblank)
2286 Cave[y][x+1] = Yacid_splash_eB;
2287 if (Cave[y][x-1] == Xblank)
2288 Cave[y][x-1] = Yacid_splash_wB;
2289 Next[y][x] = Xblank;
2290 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
2294 case Yacid_splash_eB:
2295 case Yacid_splash_wB:
2296 Cave[y][x] = Yandroid_sB;
2297 Cave[y+1][x] = Yandroid_s;
2298 Next[y][x] = Xblank;
2299 Next[y+1][x] = Xandroid_1_s;
2300 play_element_sound(x, y, SAMPLE_android_move, element);
2307 /* --------------------------------------------------------------------- */
2310 switch (Cave[y][x-1])
2320 Cave[y][x] = Yandroid_wB;
2321 if (Cave[y-1][x] == Xblank)
2322 Cave[y-1][x] = Yacid_splash_eB;
2323 if (Cave[y-1][x-2] == Xblank)
2324 Cave[y-1][x-2] = Yacid_splash_wB;
2325 Next[y][x] = Xblank;
2326 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
2330 case Yacid_splash_eB:
2331 case Yacid_splash_wB:
2332 Cave[y][x] = Yandroid_wB;
2333 Cave[y][x-1] = Yandroid_w;
2334 Next[y][x] = Xblank;
2335 Next[y][x-1] = Xandroid;
2336 play_element_sound(x, y, SAMPLE_android_move, element);
2344 switch (Cave[y][x-1])
2354 Cave[y][x] = Yandroid_wB;
2355 if (Cave[y-1][x] == Xblank)
2356 Cave[y-1][x] = Yacid_splash_eB;
2357 if (Cave[y-1][x-2] == Xblank)
2358 Cave[y-1][x-2] = Yacid_splash_wB;
2359 Next[y][x] = Xblank;
2360 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
2364 case Yacid_splash_eB:
2365 case Yacid_splash_wB:
2366 Cave[y][x] = Yandroid_wB;
2367 Cave[y][x-1] = Yandroid_w;
2368 Next[y][x] = Xblank;
2369 Next[y][x-1] = Xandroid_1_w;
2370 play_element_sound(x, y, SAMPLE_android_move, element);
2377 /* --------------------------------------------------------------------- */
2380 switch (Cave[y+1][x])
2390 Cave[y][x] = Yspring_sB;
2391 if (Cave[y][x+1] == Xblank)
2392 Cave[y][x+1] = Yacid_splash_eB;
2393 if (Cave[y][x-1] == Xblank)
2394 Cave[y][x-1] = Yacid_splash_wB;
2395 Next[y][x] = Xblank;
2396 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
2400 case Yacid_splash_eB:
2401 case Yacid_splash_wB:
2404 Cave[y][x] = Yspring_sB;
2405 Cave[y+1][x] = Yspring_s;
2406 Next[y][x] = Xblank;
2407 Next[y+1][x] = Xspring_fall;
2426 case Xemerald_pause:
2428 case Xdiamond_pause:
2456 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
2458 Cave[y][x] = Yspring_eB;
2459 Cave[y][x+1] = Yspring_e;
2460 if (Cave[y+1][x] == Xbumper)
2461 Cave[y+1][x] = XbumperB;
2462 Next[y][x] = Xblank;
2465 Next[y][x+1] = Xspring_e;
2467 Next[y][x+1] = Xspring_pause;
2473 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
2475 Cave[y][x] = Yspring_wB;
2476 Cave[y][x-1] = Yspring_w;
2477 if (Cave[y+1][x] == Xbumper)
2478 Cave[y+1][x] = XbumperB;
2479 Next[y][x] = Xblank;
2482 Next[y][x-1] = Xspring_w;
2484 Next[y][x-1] = Xspring_pause;
2492 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
2494 Cave[y][x] = Yspring_wB;
2495 Cave[y][x-1] = Yspring_w;
2496 if (Cave[y+1][x] == Xbumper)
2497 Cave[y+1][x] = XbumperB;
2498 Next[y][x] = Xblank;
2501 Next[y][x-1] = Xspring_w;
2503 Next[y][x-1] = Xspring_pause;
2509 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
2511 Cave[y][x] = Yspring_eB;
2512 Cave[y][x+1] = Yspring_e;
2513 if (Cave[y+1][x] == Xbumper)
2514 Cave[y+1][x] = XbumperB;
2515 Next[y][x] = Xblank;
2518 Next[y][x+1] = Xspring_e;
2520 Next[y][x+1] = Xspring_pause;
2531 /* --------------------------------------------------------------------- */
2534 switch (Cave[y+1][x])
2544 Cave[y][x] = Yspring_sB;
2545 if (Cave[y][x+1] == Xblank)
2546 Cave[y][x+1] = Yacid_splash_eB;
2547 if (Cave[y][x-1] == Xblank)
2548 Cave[y][x-1] = Yacid_splash_wB;
2549 Next[y][x] = Xblank;
2550 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
2554 case Yacid_splash_eB:
2555 case Yacid_splash_wB:
2556 Cave[y][x] = Yspring_sB;
2557 Cave[y+1][x] = Yspring_s;
2558 Next[y][x] = Xblank;
2559 Next[y+1][x] = Xspring_fall;
2563 Cave[y][x] = Xspring;
2564 Next[y][x] = Xspring;
2568 /* --------------------------------------------------------------------- */
2571 switch (Cave[y+1][x])
2581 Cave[y][x] = Yspring_sB;
2582 if (Cave[y][x+1] == Xblank)
2583 Cave[y][x+1] = Yacid_splash_eB;
2584 if (Cave[y][x-1] == Xblank)
2585 Cave[y][x-1] = Yacid_splash_wB;
2586 Next[y][x] = Xblank;
2587 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
2591 case Yacid_splash_eB:
2592 case Yacid_splash_wB:
2593 Cave[y][x] = Yspring_sB;
2594 Cave[y+1][x] = Yspring_s;
2595 Next[y][x] = Xblank;
2596 Next[y+1][x] = Xspring_fall;
2600 Cave[y+1][x] = XbumperB;
2603 switch (Cave[y][x+1])
2613 Cave[y][x] = Yspring_eB;
2614 if (Cave[y-1][x+2] == Xblank)
2615 Cave[y-1][x+2] = Yacid_splash_eB;
2616 if (Cave[y-1][x] == Xblank)
2617 Cave[y-1][x] = Yacid_splash_wB;
2618 Next[y][x] = Xblank;
2619 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
2623 case Yacid_splash_eB:
2624 case Yacid_splash_wB:
2629 Cave[y][x] = Yspring_eB;
2630 Cave[y][x+1] = Yspring_e;
2631 Next[y][x] = Xblank;
2632 Next[y][x+1] = Xspring_e;
2641 Cave[y][x] = Yspring_kill_eB;
2642 Cave[y][x+1] = Yspring_kill_e;
2643 Next[y][x] = Xblank;
2644 Next[y][x+1] = Xspring_e;
2645 play_element_sound(x, y, SAMPLE_slurp, Xalien);
2646 score += lev.slurp_score;
2651 Cave[y][x+1] = XbumperB;
2652 Next[y][x] = Xspring_w;
2653 play_element_sound(x, y, SAMPLE_spring, Xspring);
2657 Cave[y][x] = Xspring;
2658 Next[y][x] = Xspring;
2659 play_element_sound(x, y, SAMPLE_spring, Xspring);
2663 /* --------------------------------------------------------------------- */
2666 switch (Cave[y+1][x])
2676 Cave[y][x] = Yspring_sB;
2677 if (Cave[y][x+1] == Xblank)
2678 Cave[y][x+1] = Yacid_splash_eB;
2679 if (Cave[y][x-1] == Xblank)
2680 Cave[y][x-1] = Yacid_splash_wB;
2681 Next[y][x] = Xblank;
2682 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
2686 case Yacid_splash_eB:
2687 case Yacid_splash_wB:
2688 Cave[y][x] = Yspring_sB;
2689 Cave[y+1][x] = Yspring_s;
2690 Next[y][x] = Xblank;
2691 Next[y+1][x] = Xspring_fall;
2695 Cave[y+1][x] = XbumperB;
2698 switch (Cave[y][x-1])
2708 Cave[y][x] = Yspring_wB;
2709 if (Cave[y-1][x] == Xblank)
2710 Cave[y-1][x] = Yacid_splash_eB;
2711 if (Cave[y-1][x-2] == Xblank)
2712 Cave[y-1][x-2] = Yacid_splash_wB;
2713 Next[y][x] = Xblank;
2714 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
2718 case Yacid_splash_eB:
2719 case Yacid_splash_wB:
2724 Cave[y][x] = Yspring_wB;
2725 Cave[y][x-1] = Yspring_w;
2726 Next[y][x] = Xblank;
2727 Next[y][x-1] = Xspring_w;
2736 Cave[y][x] = Yspring_kill_wB;
2737 Cave[y][x-1] = Yspring_kill_w;
2738 Next[y][x] = Xblank;
2739 Next[y][x-1] = Xspring_w;
2740 play_element_sound(x, y, SAMPLE_slurp, Xalien);
2741 score += lev.slurp_score;
2746 Cave[y][x-1] = XbumperB;
2747 Next[y][x] = Xspring_e;
2748 play_element_sound(x, y, SAMPLE_spring, Xspring);
2752 Cave[y][x] = Xspring;
2753 Next[y][x] = Xspring;
2754 play_element_sound(x, y, SAMPLE_spring, Xspring);
2758 /* --------------------------------------------------------------------- */
2761 switch (Cave[y+1][x])
2771 Cave[y][x] = Yspring_sB;
2772 if (Cave[y][x+1] == Xblank)
2773 Cave[y][x+1] = Yacid_splash_eB;
2774 if (Cave[y][x-1] == Xblank)
2775 Cave[y][x-1] = Yacid_splash_wB;
2776 Next[y][x] = Xblank;
2777 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
2781 case Yacid_splash_eB:
2782 case Yacid_splash_wB:
2784 Cave[y][x] = Yspring_sB;
2785 Cave[y+1][x] = Yspring_s;
2786 Next[y][x] = Xblank;
2787 Next[y+1][x] = Xspring_fall;
2792 Cave[y+1][x] = Ybomb_eat;
2793 Next[y+1][x] = Znormal;
2794 Boom[y][x-1] = Xblank;
2795 Boom[y][x] = Xblank;
2796 Boom[y][x+1] = Xblank;
2797 Boom[y+1][x-1] = Xblank;
2798 Boom[y+1][x] = Xblank;
2799 Boom[y+1][x+1] = Xblank;
2800 Boom[y+2][x-1] = Xblank;
2801 Boom[y+2][x] = Xblank;
2802 Boom[y+2][x+1] = Xblank;
2803 #if PLAY_ELEMENT_SOUND
2804 play_element_sound(x, y, SAMPLE_boom, element);
2816 Cave[y][x] = Yspring_sB;
2817 Cave[y+1][x] = Ybug_spring;
2818 Next[y+1][x] = Znormal;
2819 Boom[y][x-1] = Xemerald;
2820 Boom[y][x] = Xemerald;
2821 Boom[y][x+1] = Xemerald;
2822 Boom[y+1][x-1] = Xemerald;
2823 Boom[y+1][x] = Xdiamond;
2824 Boom[y+1][x+1] = Xemerald;
2825 Boom[y+2][x-1] = Xemerald;
2826 Boom[y+2][x] = Xemerald;
2827 Boom[y+2][x+1] = Xemerald;
2828 #if PLAY_ELEMENT_SOUND
2829 play_element_sound(x, y, SAMPLE_boom, element);
2831 score += lev.bug_score;
2842 Cave[y][x] = Yspring_sB;
2843 Cave[y+1][x] = Ytank_spring;
2844 Next[y+1][x] = Znormal;
2845 Boom[y][x-1] = Xblank;
2846 Boom[y][x] = Xblank;
2847 Boom[y][x+1] = Xblank;
2848 Boom[y+1][x-1] = Xblank;
2849 Boom[y+1][x] = Xblank;
2850 Boom[y+1][x+1] = Xblank;
2851 Boom[y+2][x-1] = Xblank;
2852 Boom[y+2][x] = Xblank;
2853 Boom[y+2][x+1] = Xblank;
2854 #if PLAY_ELEMENT_SOUND
2855 play_element_sound(x, y, SAMPLE_boom, element);
2857 score += lev.tank_score;
2864 Cave[y][x] = Yspring_sB;
2865 Cave[y+1][x] = Yeater_spring;
2866 Next[y+1][x] = Znormal;
2867 Boom[y][x-1] = lev.eater_array[lev.eater_pos][0];
2868 Boom[y][x] = lev.eater_array[lev.eater_pos][1];
2869 Boom[y][x+1] = lev.eater_array[lev.eater_pos][2];
2870 Boom[y+1][x-1] = lev.eater_array[lev.eater_pos][3];
2871 Boom[y+1][x] = lev.eater_array[lev.eater_pos][4];
2872 Boom[y+1][x+1] = lev.eater_array[lev.eater_pos][5];
2873 Boom[y+2][x-1] = lev.eater_array[lev.eater_pos][6];
2874 Boom[y+2][x] = lev.eater_array[lev.eater_pos][7];
2875 Boom[y+2][x+1] = lev.eater_array[lev.eater_pos][8];
2876 #if PLAY_ELEMENT_SOUND
2877 play_element_sound(x, y, SAMPLE_boom, element);
2879 lev.eater_pos = (lev.eater_pos + 1) & 7;
2880 score += lev.eater_score;
2885 Cave[y][x] = Yspring_sB;
2886 Cave[y+1][x] = Yalien_spring;
2887 Next[y+1][x] = Znormal;
2888 Boom[y][x-1] = Xblank;
2889 Boom[y][x] = Xblank;
2890 Boom[y][x+1] = Xblank;
2891 Boom[y+1][x-1] = Xblank;
2892 Boom[y+1][x] = Xblank;
2893 Boom[y+1][x+1] = Xblank;
2894 Boom[y+2][x-1] = Xblank;
2895 Boom[y+2][x] = Xblank;
2896 Boom[y+2][x+1] = Xblank;
2897 #if PLAY_ELEMENT_SOUND
2898 play_element_sound(x, y, SAMPLE_boom, element);
2900 score += lev.alien_score;
2904 Cave[y][x] = Xspring;
2905 Next[y][x] = Xspring;
2906 play_element_sound(x, y, SAMPLE_spring, Xspring);
2910 /* --------------------------------------------------------------------- */
2913 if (Cave[y][x+1] == Xdiamond)
2915 Cave[y][x+1] = Ydiamond_eat;
2916 Next[y][x+1] = Xblank;
2917 play_element_sound(x, y, SAMPLE_eater_eat, element);
2921 if (Cave[y+1][x] == Xdiamond)
2923 Cave[y+1][x] = Ydiamond_eat;
2924 Next[y+1][x] = Xblank;
2925 play_element_sound(x, y, SAMPLE_eater_eat, element);
2929 if (Cave[y][x-1] == Xdiamond)
2931 Cave[y][x-1] = Ydiamond_eat;
2932 Next[y][x-1] = Xblank;
2933 play_element_sound(x, y, SAMPLE_eater_eat, element);
2937 if (Cave[y-1][x] == Xdiamond)
2939 Cave[y-1][x] = Ydiamond_eat;
2940 Next[y-1][x] = Xblank;
2941 play_element_sound(x, y, SAMPLE_eater_eat, element);
2945 switch (Cave[y-1][x])
2955 Cave[y][x] = Yeater_nB;
2956 if (Cave[y-2][x+1] == Xblank)
2957 Cave[y-2][x+1] = Yacid_splash_eB;
2958 if (Cave[y-2][x-1] == Xblank)
2959 Cave[y-2][x-1] = Yacid_splash_wB;
2960 Next[y][x] = Xblank;
2961 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
2965 case Yacid_splash_eB:
2966 case Yacid_splash_wB:
2970 Cave[y][x] = Yeater_nB;
2971 Cave[y-1][x] = Yeater_n;
2972 Next[y][x] = Xblank;
2973 Next[y-1][x] = Xeater_n;
2977 Next[y][x] = RANDOM & 1 ? Xeater_e : Xeater_w;
2978 play_element_sound(x, y, SAMPLE_eater, element);
2982 /* --------------------------------------------------------------------- */
2985 if (Cave[y+1][x] == Xdiamond)
2987 Cave[y+1][x] = Ydiamond_eat;
2988 Next[y+1][x] = Xblank;
2989 play_element_sound(x, y, SAMPLE_eater_eat, element);
2993 if (Cave[y][x-1] == Xdiamond)
2995 Cave[y][x-1] = Ydiamond_eat;
2996 Next[y][x-1] = Xblank;
2997 play_element_sound(x, y, SAMPLE_eater_eat, element);
3001 if (Cave[y-1][x] == Xdiamond)
3003 Cave[y-1][x] = Ydiamond_eat;
3004 Next[y-1][x] = Xblank;
3005 play_element_sound(x, y, SAMPLE_eater_eat, element);
3009 if (Cave[y][x+1] == Xdiamond)
3011 Cave[y][x+1] = Ydiamond_eat;
3012 Next[y][x+1] = Xblank;
3013 play_element_sound(x, y, SAMPLE_eater_eat, element);
3017 switch (Cave[y][x+1])
3027 Cave[y][x] = Yeater_eB;
3028 if (Cave[y-1][x+2] == Xblank)
3029 Cave[y-1][x+2] = Yacid_splash_eB;
3030 if (Cave[y-1][x] == Xblank)
3031 Cave[y-1][x] = Yacid_splash_wB;
3032 Next[y][x] = Xblank;
3033 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
3037 case Yacid_splash_eB:
3038 case Yacid_splash_wB:
3042 Cave[y][x] = Yeater_eB;
3043 Cave[y][x+1] = Yeater_e;
3044 Next[y][x] = Xblank;
3045 Next[y][x+1] = Xeater_e;
3049 Next[y][x] = RANDOM & 1 ? Xeater_n : Xeater_s;
3050 play_element_sound(x, y, SAMPLE_eater, element);
3054 /* --------------------------------------------------------------------- */
3057 if (Cave[y][x-1] == Xdiamond)
3059 Cave[y][x-1] = Ydiamond_eat;
3060 Next[y][x-1] = Xblank;
3061 play_element_sound(x, y, SAMPLE_eater_eat, element);
3065 if (Cave[y-1][x] == Xdiamond)
3067 Cave[y-1][x] = Ydiamond_eat;
3068 Next[y-1][x] = Xblank;
3069 play_element_sound(x, y, SAMPLE_eater_eat, element);
3073 if (Cave[y][x+1] == Xdiamond)
3075 Cave[y][x+1] = Ydiamond_eat;
3076 Next[y][x+1] = Xblank;
3077 play_element_sound(x, y, SAMPLE_eater_eat, element);
3081 if (Cave[y+1][x] == Xdiamond)
3083 Cave[y+1][x] = Ydiamond_eat;
3084 Next[y+1][x] = Xblank;
3085 play_element_sound(x, y, SAMPLE_eater_eat, element);
3089 switch (Cave[y+1][x])
3099 Cave[y][x] = Yeater_sB;
3100 if (Cave[y][x+1] == Xblank)
3101 Cave[y][x+1] = Yacid_splash_eB;
3102 if (Cave[y][x-1] == Xblank)
3103 Cave[y][x-1] = Yacid_splash_wB;
3104 Next[y][x] = Xblank;
3105 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
3109 case Yacid_splash_eB:
3110 case Yacid_splash_wB:
3114 Cave[y][x] = Yeater_sB;
3115 Cave[y+1][x] = Yeater_s;
3116 Next[y][x] = Xblank;
3117 Next[y+1][x] = Xeater_s;
3121 Next[y][x] = RANDOM & 1 ? Xeater_e : Xeater_w;
3122 play_element_sound(x, y, SAMPLE_eater, element);
3126 /* --------------------------------------------------------------------- */
3129 if (Cave[y-1][x] == Xdiamond)
3131 Cave[y-1][x] = Ydiamond_eat;
3132 Next[y-1][x] = Xblank;
3133 play_element_sound(x, y, SAMPLE_eater_eat, element);
3137 if (Cave[y][x+1] == Xdiamond)
3139 Cave[y][x+1] = Ydiamond_eat;
3140 Next[y][x+1] = Xblank;
3141 play_element_sound(x, y, SAMPLE_eater_eat, element);
3145 if (Cave[y+1][x] == Xdiamond)
3147 Cave[y+1][x] = Ydiamond_eat;
3148 Next[y+1][x] = Xblank;
3149 play_element_sound(x, y, SAMPLE_eater_eat, element);
3153 if (Cave[y][x-1] == Xdiamond)
3155 Cave[y][x-1] = Ydiamond_eat;
3156 Next[y][x-1] = Xblank;
3157 play_element_sound(x, y, SAMPLE_eater_eat, element);
3161 switch (Cave[y][x-1])
3171 Cave[y][x] = Yeater_wB;
3172 if (Cave[y-1][x] == Xblank)
3173 Cave[y-1][x] = Yacid_splash_eB;
3174 if (Cave[y-1][x-2] == Xblank)
3175 Cave[y-1][x-2] = Yacid_splash_wB;
3176 Next[y][x] = Xblank;
3177 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
3181 case Yacid_splash_eB:
3182 case Yacid_splash_wB:
3186 Cave[y][x] = Yeater_wB;
3187 Cave[y][x-1] = Yeater_w;
3188 Next[y][x] = Xblank;
3189 Next[y][x-1] = Xeater_w;
3193 Next[y][x] = RANDOM & 1 ? Xeater_n : Xeater_s;
3194 play_element_sound(x, y, SAMPLE_eater, element);
3198 /* --------------------------------------------------------------------- */
3209 set_nearest_player_xy(x, y, &dx, &dy);
3216 switch (Cave[y-1][x])
3226 Cave[y][x] = Yalien_nB;
3227 if (Cave[y-2][x+1] == Xblank)
3228 Cave[y-2][x+1] = Yacid_splash_eB;
3229 if (Cave[y-2][x-1] == Xblank)
3230 Cave[y-2][x-1] = Yacid_splash_wB;
3231 Next[y][x] = Xblank;
3232 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
3236 case Yacid_splash_eB:
3237 case Yacid_splash_wB:
3241 Cave[y][x] = Yalien_nB;
3242 Cave[y-1][x] = Yalien_n;
3243 Next[y][x] = Xblank;
3244 Next[y-1][x] = Xalien_pause;
3245 play_element_sound(x, y, SAMPLE_alien, Xalien);
3251 switch (Cave[y+1][x])
3261 Cave[y][x] = Yalien_sB;
3262 Next[y][x] = Xblank;
3263 if (Cave[y][x+1] == Xblank)
3264 Cave[y][x+1] = Yacid_splash_eB;
3265 if (Cave[y][x-1] == Xblank)
3266 Cave[y][x-1] = Yacid_splash_wB;
3267 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
3271 case Yacid_splash_eB:
3272 case Yacid_splash_wB:
3276 Cave[y][x] = Yalien_sB;
3277 Cave[y+1][x] = Yalien_s;
3278 Next[y][x] = Xblank;
3279 Next[y+1][x] = Xalien_pause;
3280 play_element_sound(x, y, SAMPLE_alien, Xalien);
3289 switch (Cave[y][x+1])
3299 Cave[y][x] = Yalien_eB;
3300 if (Cave[y-1][x+2] == Xblank)
3301 Cave[y-1][x+2] = Yacid_splash_eB;
3302 if (Cave[y-1][x] == Xblank)
3303 Cave[y-1][x] = Yacid_splash_wB;
3304 Next[y][x] = Xblank;
3305 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
3309 case Yacid_splash_eB:
3310 case Yacid_splash_wB:
3314 Cave[y][x] = Yalien_eB;
3315 Cave[y][x+1] = Yalien_e;
3316 Next[y][x] = Xblank;
3317 Next[y][x+1] = Xalien_pause;
3318 play_element_sound(x, y, SAMPLE_alien, Xalien);
3324 switch (Cave[y][x-1])
3334 Cave[y][x] = Yalien_wB;
3335 if (Cave[y-1][x] == Xblank)
3336 Cave[y-1][x] = Yacid_splash_eB;
3337 if (Cave[y-1][x-2] == Xblank)
3338 Cave[y-1][x-2] = Yacid_splash_wB;
3339 Next[y][x] = Xblank;
3340 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
3344 case Yacid_splash_eB:
3345 case Yacid_splash_wB:
3349 Cave[y][x] = Yalien_wB;
3350 Cave[y][x-1] = Yalien_w;
3351 Next[y][x] = Xblank;
3352 Next[y][x-1] = Xalien_pause;
3353 play_element_sound(x, y, SAMPLE_alien, Xalien);
3362 Next[y][x] = Xalien;
3365 /* --------------------------------------------------------------------- */
3368 switch (Cave[y+1][x])
3378 Cave[y][x] = Yemerald_sB;
3379 if (Cave[y][x+1] == Xblank)
3380 Cave[y][x+1] = Yacid_splash_eB;
3381 if (Cave[y][x-1] == Xblank)
3382 Cave[y][x-1] = Yacid_splash_wB;
3383 Next[y][x] = Xblank;
3384 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
3388 case Yacid_splash_eB:
3389 case Yacid_splash_wB:
3390 Cave[y][x] = Yemerald_sB;
3391 Cave[y+1][x] = Yemerald_s;
3392 Next[y][x] = Xblank;
3393 Next[y+1][x] = Xemerald_fall;
3412 case Xemerald_pause:
3414 case Xdiamond_pause:
3451 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
3453 Cave[y][x] = Yemerald_eB;
3454 Cave[y][x+1] = Yemerald_e;
3455 Next[y][x] = Xblank;
3456 Next[y][x+1] = Xemerald_pause;
3460 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
3462 Cave[y][x] = Yemerald_wB;
3463 Cave[y][x-1] = Yemerald_w;
3464 Next[y][x] = Xblank;
3465 Next[y][x-1] = Xemerald_pause;
3471 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
3473 Cave[y][x] = Yemerald_wB;
3474 Cave[y][x-1] = Yemerald_w;
3475 Next[y][x] = Xblank;
3476 Next[y][x-1] = Xemerald_pause;
3480 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
3482 Cave[y][x] = Yemerald_eB;
3483 Cave[y][x+1] = Yemerald_e;
3484 Next[y][x] = Xblank;
3485 Next[y][x+1] = Xemerald_pause;
3491 if (++lev.shine_cnt > 50)
3493 lev.shine_cnt = RANDOM & 7;
3494 Cave[y][x] = Xemerald_shine;
3500 /* --------------------------------------------------------------------- */
3502 case Xemerald_pause:
3503 switch (Cave[y+1][x])
3513 Cave[y][x] = Yemerald_sB;
3514 if (Cave[y][x+1] == Xblank)
3515 Cave[y][x+1] = Yacid_splash_eB;
3516 if (Cave[y][x-1] == Xblank)
3517 Cave[y][x-1] = Yacid_splash_wB;
3518 Next[y][x] = Xblank;
3519 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
3523 case Yacid_splash_eB:
3524 case Yacid_splash_wB:
3525 Cave[y][x] = Yemerald_sB;
3526 Cave[y+1][x] = Yemerald_s;
3527 Next[y][x] = Xblank;
3528 Next[y+1][x] = Xemerald_fall;
3532 Cave[y][x] = Xemerald;
3533 Next[y][x] = Xemerald;
3537 /* --------------------------------------------------------------------- */
3540 switch (Cave[y+1][x])
3550 Cave[y][x] = Yemerald_sB;
3551 if (Cave[y][x+1] == Xblank)
3552 Cave[y][x+1] = Yacid_splash_eB;
3553 if (Cave[y][x-1] == Xblank)
3554 Cave[y][x-1] = Yacid_splash_wB;
3555 Next[y][x] = Xblank;
3556 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
3560 case Yacid_splash_eB:
3561 case Yacid_splash_wB:
3563 Cave[y][x] = Yemerald_sB;
3564 Cave[y+1][x] = Yemerald_s;
3565 Next[y][x] = Xblank;
3566 Next[y+1][x] = Xemerald_fall;
3570 if (lev.wonderwall_time)
3572 lev.wonderwall_state = 1;
3573 Cave[y][x] = Yemerald_sB;
3574 if (tab_blank[Cave[y+2][x]])
3576 Cave[y+2][x] = Ydiamond_s;
3577 Next[y+2][x] = Xdiamond_fall;
3580 Next[y][x] = Xblank;
3581 play_element_sound(x, y, SAMPLE_wonderfall, Xwonderwall);
3586 Cave[y][x] = Xemerald;
3587 Next[y][x] = Xemerald;
3588 play_element_sound(x, y, SAMPLE_diamond, Xemerald);
3592 /* --------------------------------------------------------------------- */
3595 switch (Cave[y+1][x])
3605 Cave[y][x] = Ydiamond_sB;
3606 if (Cave[y][x+1] == Xblank)
3607 Cave[y][x+1] = Yacid_splash_eB;
3608 if (Cave[y][x-1] == Xblank)
3609 Cave[y][x-1] = Yacid_splash_wB;
3610 Next[y][x] = Xblank;
3611 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
3615 case Yacid_splash_eB:
3616 case Yacid_splash_wB:
3617 Cave[y][x] = Ydiamond_sB;
3618 Cave[y+1][x] = Ydiamond_s;
3619 Next[y][x] = Xblank;
3620 Next[y+1][x] = Xdiamond_fall;
3639 case Xemerald_pause:
3641 case Xdiamond_pause:
3678 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
3680 Cave[y][x] = Ydiamond_eB;
3681 Cave[y][x+1] = Ydiamond_e;
3682 Next[y][x] = Xblank;
3683 Next[y][x+1] = Xdiamond_pause;
3687 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
3689 Cave[y][x] = Ydiamond_wB;
3690 Cave[y][x-1] = Ydiamond_w;
3691 Next[y][x] = Xblank;
3692 Next[y][x-1] = Xdiamond_pause;
3698 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
3700 Cave[y][x] = Ydiamond_wB;
3701 Cave[y][x-1] = Ydiamond_w;
3702 Next[y][x] = Xblank;
3703 Next[y][x-1] = Xdiamond_pause;
3707 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
3709 Cave[y][x] = Ydiamond_eB;
3710 Cave[y][x+1] = Ydiamond_e;
3711 Next[y][x] = Xblank;
3712 Next[y][x+1] = Xdiamond_pause;
3718 if (++lev.shine_cnt > 50)
3720 lev.shine_cnt = RANDOM & 7;
3721 Cave[y][x] = Xdiamond_shine;
3727 /* --------------------------------------------------------------------- */
3729 case Xdiamond_pause:
3730 switch (Cave[y+1][x])
3740 Cave[y][x] = Ydiamond_sB;
3741 if (Cave[y][x+1] == Xblank)
3742 Cave[y][x+1] = Yacid_splash_eB;
3743 if (Cave[y][x-1] == Xblank)
3744 Cave[y][x-1] = Yacid_splash_wB;
3745 Next[y][x] = Xblank;
3746 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
3750 case Yacid_splash_eB:
3751 case Yacid_splash_wB:
3752 Cave[y][x] = Ydiamond_sB;
3753 Cave[y+1][x] = Ydiamond_s;
3754 Next[y][x] = Xblank;
3755 Next[y+1][x] = Xdiamond_fall;
3759 Cave[y][x] = Xdiamond;
3760 Next[y][x] = Xdiamond;
3764 /* --------------------------------------------------------------------- */
3767 switch (Cave[y+1][x])
3777 Cave[y][x] = Ydiamond_sB;
3778 if (Cave[y][x+1] == Xblank)
3779 Cave[y][x+1] = Yacid_splash_eB;
3780 if (Cave[y][x-1] == Xblank)
3781 Cave[y][x-1] = Yacid_splash_wB;
3782 Next[y][x] = Xblank;
3783 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
3787 case Yacid_splash_eB:
3788 case Yacid_splash_wB:
3790 Cave[y][x] = Ydiamond_sB;
3791 Cave[y+1][x] = Ydiamond_s;
3792 Next[y][x] = Xblank;
3793 Next[y+1][x] = Xdiamond_fall;
3797 if (lev.wonderwall_time)
3799 lev.wonderwall_state = 1;
3800 Cave[y][x] = Ydiamond_sB;
3801 if (tab_blank[Cave[y+2][x]])
3803 Cave[y+2][x] = Ystone_s;
3804 Next[y+2][x] = Xstone_fall;
3807 Next[y][x] = Xblank;
3808 play_element_sound(x, y, SAMPLE_wonderfall, Xwonderwall);
3813 Cave[y][x] = Xdiamond;
3814 Next[y][x] = Xdiamond;
3815 play_element_sound(x, y, SAMPLE_diamond, Xdiamond);
3819 /* --------------------------------------------------------------------- */
3822 switch (Cave[y+1][x])
3832 Cave[y][x] = Ydrip_s1B;
3833 if (Cave[y][x+1] == Xblank)
3834 Cave[y][x+1] = Yacid_splash_eB;
3835 if (Cave[y][x-1] == Xblank)
3836 Cave[y][x-1] = Yacid_splash_wB;
3837 Next[y][x] = Xdrip_stretchB;
3838 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
3842 case Yacid_splash_eB:
3843 case Yacid_splash_wB:
3847 Cave[y][x] = Ydrip_s1B;
3848 Cave[y+1][x] = Ydrip_s1;
3849 Next[y][x] = Xdrip_stretchB;
3850 Next[y+1][x] = Xdrip_stretch;
3891 play_element_sound(x, y, SAMPLE_drip, Xdrip_fall);
3895 /* --------------------------------------------------------------------- */
3898 Cave[y][x] = Ydrip_s2;
3899 Next[y][x] = Xdrip_fall;
3902 case Xdrip_stretchB:
3903 Cave[y][x] = Ydrip_s2B;
3904 Next[y][x] = Xblank;
3908 Next[y][x] = Xdrip_fall;
3911 /* --------------------------------------------------------------------- */
3914 switch (Cave[y+1][x])
3924 Cave[y][x] = Ybomb_sB;
3925 if (Cave[y][x+1] == Xblank)
3926 Cave[y][x+1] = Yacid_splash_eB;
3927 if (Cave[y][x-1] == Xblank)
3928 Cave[y][x-1] = Yacid_splash_wB;
3929 Next[y][x] = Xblank;
3930 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
3934 case Yacid_splash_eB:
3935 case Yacid_splash_wB:
3936 Cave[y][x] = Ybomb_sB;
3937 Cave[y+1][x] = Ybomb_s;
3938 Next[y][x] = Xblank;
3939 Next[y+1][x] = Xbomb_fall;
3958 case Xemerald_pause:
3960 case Xdiamond_pause:
3988 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
3990 Cave[y][x] = Ybomb_eB;
3991 Cave[y][x+1] = Ybomb_e;
3992 Next[y][x] = Xblank;
3993 Next[y][x+1] = Xbomb_pause;
3997 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
3999 Cave[y][x] = Ybomb_wB;
4000 Cave[y][x-1] = Ybomb_w;
4001 Next[y][x] = Xblank;
4002 Next[y][x-1] = Xbomb_pause;
4008 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
4010 Cave[y][x] = Ybomb_wB;
4011 Cave[y][x-1] = Ybomb_w;
4012 Next[y][x] = Xblank;
4013 Next[y][x-1] = Xbomb_pause;
4017 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
4019 Cave[y][x] = Ybomb_eB;
4020 Cave[y][x+1] = Ybomb_e;
4021 Next[y][x] = Xblank;
4022 Next[y][x+1] = Xbomb_pause;
4031 /* --------------------------------------------------------------------- */
4034 switch (Cave[y+1][x])
4044 Cave[y][x] = Ybomb_sB;
4045 if (Cave[y][x+1] == Xblank)
4046 Cave[y][x+1] = Yacid_splash_eB;
4047 if (Cave[y][x-1] == Xblank)
4048 Cave[y][x-1] = Yacid_splash_wB;
4049 Next[y][x] = Xblank;
4050 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
4054 case Yacid_splash_eB:
4055 case Yacid_splash_wB:
4056 Cave[y][x] = Ybomb_sB;
4057 Cave[y+1][x] = Ybomb_s;
4058 Next[y][x] = Xblank;
4059 Next[y+1][x] = Xbomb_fall;
4068 /* --------------------------------------------------------------------- */
4071 switch (Cave[y+1][x])
4081 Cave[y][x] = Ybomb_sB;
4082 if (Cave[y][x+1] == Xblank)
4083 Cave[y][x+1] = Yacid_splash_eB;
4084 if (Cave[y][x-1] == Xblank)
4085 Cave[y][x-1] = Yacid_splash_wB;
4086 Next[y][x] = Xblank;
4087 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
4091 case Yacid_splash_eB:
4092 case Yacid_splash_wB:
4093 Cave[y][x] = Ybomb_sB;
4094 Cave[y+1][x] = Ybomb_s;
4095 Next[y][x] = Xblank;
4096 Next[y+1][x] = Xbomb_fall;
4100 Cave[y][x] = Ybomb_eat;
4101 Next[y][x] = Znormal;
4102 Boom[y-1][x-1] = Xblank;
4103 Boom[y-1][x] = Xblank;
4104 Boom[y-1][x+1] = Xblank;
4105 Boom[y][x-1] = Xblank;
4106 Boom[y][x] = Xblank;
4107 Boom[y][x+1] = Xblank;
4108 Boom[y+1][x-1] = Xblank;
4109 Boom[y+1][x] = Xblank;
4110 Boom[y+1][x+1] = Xblank;
4111 #if PLAY_ELEMENT_SOUND
4112 play_element_sound(x, y, SAMPLE_boom, element);
4117 /* --------------------------------------------------------------------- */
4120 if (lev.wind_cnt == 0)
4123 switch (lev.wind_direction)
4126 switch (Cave[y-1][x])
4136 Cave[y][x] = Yballoon_nB;
4137 if (Cave[y-2][x+1] == Xblank)
4138 Cave[y-2][x+1] = Yacid_splash_eB;
4139 if (Cave[y-2][x-1] == Xblank)
4140 Cave[y-2][x-1] = Yacid_splash_wB;
4141 Next[y][x] = Xblank;
4142 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
4146 case Yacid_splash_eB:
4147 case Yacid_splash_wB:
4148 Cave[y][x] = Yballoon_nB;
4149 Cave[y-1][x] = Yballoon_n;
4150 Next[y][x] = Xblank;
4151 Next[y-1][x] = Xballoon;
4159 switch (Cave[y][x+1])
4169 Cave[y][x] = Yballoon_eB;
4170 if (Cave[y-1][x+2] == Xblank)
4171 Cave[y-1][x+2] = Yacid_splash_eB;
4172 if (Cave[y-1][x] == Xblank)
4173 Cave[y-1][x] = Yacid_splash_wB;
4174 Next[y][x] = Xblank;
4175 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
4179 case Yacid_splash_eB:
4180 case Yacid_splash_wB:
4181 Cave[y][x] = Yballoon_eB;
4182 Cave[y][x+1] = Yballoon_e;
4183 Next[y][x] = Xblank;
4184 Next[y][x+1] = Xballoon;
4192 switch (Cave[y+1][x])
4202 Cave[y][x] = Yballoon_sB;
4203 if (Cave[y][x+1] == Xblank)
4204 Cave[y][x+1] = Yacid_splash_eB;
4205 if (Cave[y][x-1] == Xblank)
4206 Cave[y][x-1] = Yacid_splash_wB;
4207 Next[y][x] = Xblank;
4208 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
4212 case Yacid_splash_eB:
4213 case Yacid_splash_wB:
4214 Cave[y][x] = Yballoon_sB;
4215 Cave[y+1][x] = Yballoon_s;
4216 Next[y][x] = Xblank;
4217 Next[y+1][x] = Xballoon;
4225 switch (Cave[y][x-1])
4235 Cave[y][x] = Yballoon_wB;
4236 if (Cave[y-1][x] == Xblank)
4237 Cave[y-1][x] = Yacid_splash_eB;
4238 if (Cave[y-1][x-2] == Xblank)
4239 Cave[y-1][x-2] = Yacid_splash_wB;
4240 Next[y][x] = Xblank;
4241 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
4245 case Yacid_splash_eB:
4246 case Yacid_splash_wB:
4247 Cave[y][x] = Yballoon_wB;
4248 Cave[y][x-1] = Yballoon_w;
4249 Next[y][x] = Xblank;
4250 Next[y][x-1] = Xballoon;
4258 /* --------------------------------------------------------------------- */
4261 Next[y][x] = Xacid_2;
4265 Next[y][x] = Xacid_3;
4269 Next[y][x] = Xacid_4;
4273 Next[y][x] = Xacid_5;
4277 Next[y][x] = Xacid_6;
4281 Next[y][x] = Xacid_7;
4285 Next[y][x] = Xacid_8;
4289 Next[y][x] = Xacid_1;
4293 Next[y][x] = Xfake_acid_2;
4297 Next[y][x] = Xfake_acid_3;
4301 Next[y][x] = Xfake_acid_4;
4305 Next[y][x] = Xfake_acid_5;
4309 Next[y][x] = Xfake_acid_6;
4313 Next[y][x] = Xfake_acid_7;
4317 Next[y][x] = Xfake_acid_8;
4321 Next[y][x] = Xfake_acid_1;
4324 /* --------------------------------------------------------------------- */
4327 if (lev.ball_state == 0)
4330 Cave[y][x] = Xball_1B;
4331 Next[y][x] = Xball_2;
4338 if (lev.ball_state == 0)
4341 Cave[y][x] = Xball_2B;
4342 Next[y][x] = Xball_1;
4350 play_element_sound(x, y, SAMPLE_ball, element);
4351 if (lev.ball_random)
4356 if (lev.ball_array[lev.ball_pos][0] != Xblank &&
4357 tab_blank[Cave[y-1][x-1]])
4359 Cave[y-1][x-1] = Yball_eat;
4360 Next[y-1][x-1] = lev.ball_array[lev.ball_pos][0];
4365 if (lev.ball_array[lev.ball_pos][1] != Xblank &&
4366 tab_blank[Cave[y-1][x]])
4368 Cave[y-1][x] = Yball_eat;
4369 Next[y-1][x] = lev.ball_array[lev.ball_pos][1];
4374 if (lev.ball_array[lev.ball_pos][2] != Xblank &&
4375 tab_blank[Cave[y-1][x+1]])
4377 Cave[y-1][x+1] = Yball_eat;
4378 Next[y-1][x+1] = lev.ball_array[lev.ball_pos][2];
4383 if (lev.ball_array[lev.ball_pos][3] != Xblank &&
4384 tab_blank[Cave[y][x-1]])
4386 Cave[y][x-1] = Yball_eat;
4387 Next[y][x-1] = lev.ball_array[lev.ball_pos][3];
4392 if (lev.ball_array[lev.ball_pos][4] != Xblank &&
4393 tab_blank[Cave[y][x+1]])
4395 Cave[y][x+1] = Yball_eat;
4396 Next[y][x+1] = lev.ball_array[lev.ball_pos][4];
4401 if (lev.ball_array[lev.ball_pos][5] != Xblank &&
4402 tab_blank[Cave[y+1][x-1]])
4404 Cave[y+1][x-1] = Yball_eat;
4405 Next[y+1][x-1] = lev.ball_array[lev.ball_pos][5];
4410 if (lev.ball_array[lev.ball_pos][6] != Xblank &&
4411 tab_blank[Cave[y+1][x]])
4413 Cave[y+1][x] = Yball_eat;
4414 Next[y+1][x] = lev.ball_array[lev.ball_pos][6];
4419 if (lev.ball_array[lev.ball_pos][7] != Xblank &&
4420 tab_blank[Cave[y+1][x+1]])
4422 Cave[y+1][x+1] = Yball_eat;
4423 Next[y+1][x+1] = lev.ball_array[lev.ball_pos][7];
4430 if (lev.ball_array[lev.ball_pos][0] != Xblank &&
4431 tab_blank[Cave[y-1][x-1]])
4433 Cave[y-1][x-1] = Yball_eat;
4434 Next[y-1][x-1] = lev.ball_array[lev.ball_pos][0];
4437 if (lev.ball_array[lev.ball_pos][1] != Xblank &&
4438 tab_blank[Cave[y-1][x]])
4440 Cave[y-1][x] = Yball_eat;
4441 Next[y-1][x] = lev.ball_array[lev.ball_pos][1];
4444 if (lev.ball_array[lev.ball_pos][2] != Xblank &&
4445 tab_blank[Cave[y-1][x+1]])
4447 Cave[y-1][x+1] = Yball_eat;
4448 Next[y-1][x+1] = lev.ball_array[lev.ball_pos][2];
4451 if (lev.ball_array[lev.ball_pos][3] != Xblank &&
4452 tab_blank[Cave[y][x-1]])
4454 Cave[y][x-1] = Yball_eat;
4455 Next[y][x-1] = lev.ball_array[lev.ball_pos][3];
4458 if (lev.ball_array[lev.ball_pos][4] != Xblank &&
4459 tab_blank[Cave[y][x+1]])
4461 Cave[y][x+1] = Yball_eat;
4462 Next[y][x+1] = lev.ball_array[lev.ball_pos][4];
4465 if (lev.ball_array[lev.ball_pos][5] != Xblank &&
4466 tab_blank[Cave[y+1][x-1]])
4468 Cave[y+1][x-1] = Yball_eat;
4469 Next[y+1][x-1] = lev.ball_array[lev.ball_pos][5];
4472 if (lev.ball_array[lev.ball_pos][6] != Xblank &&
4473 tab_blank[Cave[y+1][x]])
4475 Cave[y+1][x] = Yball_eat;
4476 Next[y+1][x] = lev.ball_array[lev.ball_pos][6];
4479 if (lev.ball_array[lev.ball_pos][7] != Xblank &&
4480 tab_blank[Cave[y+1][x+1]])
4482 Cave[y+1][x+1] = Yball_eat;
4483 Next[y+1][x+1] = lev.ball_array[lev.ball_pos][7];
4487 lev.ball_pos = (lev.ball_pos + 1) % lev.num_ball_arrays;
4491 /* --------------------------------------------------------------------- */
4494 if (tab_blank[Cave[y-1][x]])
4496 Cave[y-1][x] = Ygrow_ns_eat;
4497 Next[y-1][x] = Xgrow_ns;
4498 play_element_sound(x, y, SAMPLE_grow, Xgrow_ns);
4501 if (tab_blank[Cave[y+1][x]])
4503 Cave[y+1][x] = Ygrow_ns_eat;
4504 Next[y+1][x] = Xgrow_ns;
4505 play_element_sound(x, y, SAMPLE_grow, Xgrow_ns);
4511 if (tab_blank[Cave[y][x+1]])
4513 Cave[y][x+1] = Ygrow_ew_eat;
4514 Next[y][x+1] = Xgrow_ew;
4515 play_element_sound(x, y, SAMPLE_grow, Xgrow_ew);
4518 if (tab_blank[Cave[y][x-1]])
4520 Cave[y][x-1] = Ygrow_ew_eat;
4521 Next[y][x-1] = Xgrow_ew;
4522 play_element_sound(x, y, SAMPLE_grow, Xgrow_ew);
4527 /* --------------------------------------------------------------------- */
4530 if (lev.wonderwall_time && lev.wonderwall_state)
4532 Cave[y][x] = XwonderwallB;
4533 play_element_sound(x, y, SAMPLE_wonder, Xwonderwall);
4538 /* --------------------------------------------------------------------- */
4541 if (lev.required > 0)
4547 Cave[y][x] = Xexit_1;
4548 Next[y][x] = Xexit_2;
4552 Cave[y][x] = Xexit_2;
4553 Next[y][x] = Xexit_3;
4557 Cave[y][x] = Xexit_3;
4558 Next[y][x] = Xexit_1;
4561 play_element_sound(x, y, SAMPLE_exit_open, Xexit);
4566 Next[y][x] = Xexit_2;
4570 Next[y][x] = Xexit_3;
4574 Next[y][x] = Xexit_1;
4577 /* --------------------------------------------------------------------- */
4580 play_element_sound(x, y, SAMPLE_tick, Xdynamite_1);
4581 Next[y][x] = Xdynamite_2;
4585 play_element_sound(x, y, SAMPLE_tick, Xdynamite_2);
4586 Next[y][x] = Xdynamite_3;
4590 play_element_sound(x, y, SAMPLE_tick, Xdynamite_3);
4591 Next[y][x] = Xdynamite_4;
4595 play_element_sound(x, y, SAMPLE_tick, Xdynamite_4);
4596 Next[y][x] = Zdynamite;
4597 Boom[y-1][x-1] = Xblank;
4598 Boom[y-1][x] = Xblank;
4599 Boom[y-1][x+1] = Xblank;
4600 Boom[y][x-1] = Xblank;
4601 Boom[y][x] = Xblank;
4602 Boom[y][x+1] = Xblank;
4603 Boom[y+1][x-1] = Xblank;
4604 Boom[y+1][x] = Xblank;
4605 Boom[y+1][x+1] = Xblank;
4608 /* --------------------------------------------------------------------- */
4611 if (lev.wheel_cnt && x == lev.wheel_x && y == lev.wheel_y)
4612 Cave[y][x] = XwheelB;
4615 /* --------------------------------------------------------------------- */
4619 Cave[y][x] = XswitchB;
4622 /* --------------------------------------------------------------------- */
4625 switch (Cave[y+1][x])
4635 Cave[y][x] = Xsand_stonesand_quickout_1;
4636 if (Cave[y][x+1] == Xblank)
4637 Cave[y][x+1] = Yacid_splash_eB;
4638 if (Cave[y][x-1] == Xblank)
4639 Cave[y][x-1] = Yacid_splash_wB;
4640 Next[y][x] = Xsand_stonesand_quickout_2;
4641 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
4645 case Yacid_splash_eB:
4646 case Yacid_splash_wB:
4647 Cave[y][x] = Xsand_stonesand_quickout_1;
4648 Cave[y+1][x] = Xsand_stoneout_1;
4649 Next[y][x] = Xsand_stonesand_quickout_2;
4650 Next[y+1][x] = Xsand_stoneout_2;
4654 Cave[y][x] = Xsand_stonesand_1;
4655 Cave[y+1][x] = Xsand_sandstone_1;
4656 Next[y][x] = Xsand_stonesand_2;
4657 Next[y+1][x] = Xsand_sandstone_2;
4664 case Xsand_stonein_1:
4665 Next[y][x] = Xsand_stonein_2;
4668 case Xsand_stonein_2:
4669 Next[y][x] = Xsand_stonein_3;
4672 case Xsand_stonein_3:
4673 Next[y][x] = Xsand_stonein_4;
4676 case Xsand_stonein_4:
4677 Next[y][x] = Xblank;
4680 case Xsand_stonesand_1:
4681 Next[y][x] = Xsand_stonesand_2;
4684 case Xsand_stonesand_2:
4685 Next[y][x] = Xsand_stonesand_3;
4688 case Xsand_stonesand_3:
4689 Next[y][x] = Xsand_stonesand_4;
4692 case Xsand_stonesand_4:
4697 case Xsand_stonesand_quickout_1:
4698 Next[y][x] = Xsand_stonesand_quickout_2;
4701 case Xsand_stonesand_quickout_2:
4706 case Xsand_stoneout_1:
4707 Next[y][x] = Xsand_stoneout_2;
4710 case Xsand_stoneout_2:
4711 Next[y][x] = Xstone_fall;
4714 case Xsand_sandstone_1:
4715 Next[y][x] = Xsand_sandstone_2;
4718 case Xsand_sandstone_2:
4719 Next[y][x] = Xsand_sandstone_3;
4722 case Xsand_sandstone_3:
4723 Next[y][x] = Xsand_sandstone_4;
4726 case Xsand_sandstone_4:
4727 Next[y][x] = Xsand_stone;
4730 /* --------------------------------------------------------------------- */
4734 Cave[y][x] = XdripperB;
4737 /* --------------------------------------------------------------------- */
4741 Cave[y][x] = Xfake_blankB;
4744 /* --------------------------------------------------------------------- */
4747 if (lev.magnify_cnt)
4748 Cave[y][x] = Xfake_grassB;
4751 /* --------------------------------------------------------------------- */
4754 if (lev.magnify_cnt)
4755 Cave[y][x] = Xdoor_1;
4759 if (lev.magnify_cnt)
4760 Cave[y][x] = Xdoor_2;
4764 if (lev.magnify_cnt)
4765 Cave[y][x] = Xdoor_3;
4769 if (lev.magnify_cnt)
4770 Cave[y][x] = Xdoor_4;
4774 if (lev.magnify_cnt)
4775 Cave[y][x] = Xdoor_5;
4779 if (lev.magnify_cnt)
4780 Cave[y][x] = Xdoor_6;
4784 if (lev.magnify_cnt)
4785 Cave[y][x] = Xdoor_7;
4789 if (lev.magnify_cnt)
4790 Cave[y][x] = Xdoor_8;
4793 /* --------------------------------------------------------------------- */
4797 Next[y][x] = Znormal;
4798 Boom[y-1][x-1] = Xemerald;
4799 Boom[y-1][x] = Xemerald;
4800 Boom[y-1][x+1] = Xemerald;
4801 Boom[y][x-1] = Xemerald;
4802 Boom[y][x] = Xdiamond;
4803 Boom[y][x+1] = Xemerald;
4804 Boom[y+1][x-1] = Xemerald;
4805 Boom[y+1][x] = Xemerald;
4806 Boom[y+1][x+1] = Xemerald;
4807 #if PLAY_ELEMENT_SOUND
4808 play_element_sound(x, y, SAMPLE_boom, element);
4816 Next[y][x] = Znormal;
4817 Boom[y-1][x-1] = Xblank;
4818 Boom[y-1][x] = Xblank;
4819 Boom[y-1][x+1] = Xblank;
4820 Boom[y][x-1] = Xblank;
4821 Boom[y][x] = Xblank;
4822 Boom[y][x+1] = Xblank;
4823 Boom[y+1][x-1] = Xblank;
4824 Boom[y+1][x] = Xblank;
4825 Boom[y+1][x+1] = Xblank;
4826 #if PLAY_ELEMENT_SOUND
4827 play_element_sound(x, y, SAMPLE_boom, element);
4832 #if PLAY_ELEMENT_SOUND
4833 play_element_sound(x, y, SAMPLE_boom, Xandroid);
4836 Next[y][x] = Xboom_2;
4837 #if !PLAY_ELEMENT_SOUND
4838 if (x != lev.exit_x && y != lev.exit_y)
4839 play_sound(x, y, SAMPLE_boom);
4841 lev.exit_x = lev.exit_y = -1;
4846 Next[y][x] = Boom[y][x];
4849 /* --------------------------------------------------------------------- */
4852 if (++y < HEIGHT - 1)
4855 cave_cache = Cave[y];
4868 if (ply[0].alive || ply[1].alive || ply[2].alive || ply[3].alive)
4869 lev.score += score; /* only add a score if someone is alive */
4876 /* triple buffering */