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)
1907 set_nearest_player_xy(x, y, &dx, &dy);
1911 if (ply1.alive && ply2.alive)
1913 if ((ply1.x > x ? ply1.x - x : x - ply1.x) +
1914 (ply1.y > y ? ply1.y - y : y - ply1.y) <
1915 (ply2.x > x ? ply2.x - x : x - ply2.x) +
1916 (ply2.y > y ? ply2.y - y : y - ply2.y))
1927 else if (ply1.alive)
1932 else if (ply2.alive)
1945 Next[y][x] = Xblank; /* assume we will move */
1946 temp = ((x < dx) + 1 - (x > dx)) + ((y < dy) + 1 - (y > dy)) * 3;
1952 /* attempt clockwise move first if direct path is blocked */
1954 case 0: /* north west */
1955 if (tab_android_move[Cave[y-1][x-1]]) goto android_nw;
1956 if (tab_android_move[Cave[y-1][x]]) goto android_n;
1957 if (tab_android_move[Cave[y][x-1]]) goto android_w;
1961 if (tab_android_move[Cave[y-1][x]]) goto android_n;
1962 if (tab_android_move[Cave[y-1][x+1]]) goto android_ne;
1963 if (tab_android_move[Cave[y-1][x-1]]) goto android_nw;
1966 case 2: /* north east */
1967 if (tab_android_move[Cave[y-1][x+1]]) goto android_ne;
1968 if (tab_android_move[Cave[y][x+1]]) goto android_e;
1969 if (tab_android_move[Cave[y-1][x]]) goto android_n;
1973 if (tab_android_move[Cave[y][x-1]]) goto android_w;
1974 if (tab_android_move[Cave[y-1][x-1]]) goto android_nw;
1975 if (tab_android_move[Cave[y+1][x-1]]) goto android_sw;
1978 case 4: /* nowhere */
1982 if (tab_android_move[Cave[y][x+1]]) goto android_e;
1983 if (tab_android_move[Cave[y+1][x+1]]) goto android_se;
1984 if (tab_android_move[Cave[y-1][x+1]]) goto android_ne;
1987 case 6: /* south west */
1988 if (tab_android_move[Cave[y+1][x-1]]) goto android_sw;
1989 if (tab_android_move[Cave[y][x-1]]) goto android_w;
1990 if (tab_android_move[Cave[y+1][x]]) goto android_s;
1994 if (tab_android_move[Cave[y+1][x]]) goto android_s;
1995 if (tab_android_move[Cave[y+1][x-1]]) goto android_sw;
1996 if (tab_android_move[Cave[y+1][x+1]]) goto android_se;
1999 case 8: /* south east */
2000 if (tab_android_move[Cave[y+1][x+1]]) goto android_se;
2001 if (tab_android_move[Cave[y+1][x]]) goto android_s;
2002 if (tab_android_move[Cave[y][x+1]]) goto android_e;
2010 /* attempt counterclockwise move first if direct path is blocked */
2012 case 0: /* north west */
2013 if (tab_android_move[Cave[y-1][x-1]]) goto android_nw;
2014 if (tab_android_move[Cave[y][x-1]]) goto android_w;
2015 if (tab_android_move[Cave[y-1][x]]) goto android_n;
2019 if (tab_android_move[Cave[y-1][x]]) goto android_n;
2020 if (tab_android_move[Cave[y-1][x-1]]) goto android_nw;
2021 if (tab_android_move[Cave[y-1][x+1]]) goto android_ne;
2024 case 2: /* north east */
2025 if (tab_android_move[Cave[y-1][x+1]]) goto android_ne;
2026 if (tab_android_move[Cave[y-1][x]]) goto android_n;
2027 if (tab_android_move[Cave[y][x+1]]) goto android_e;
2031 if (tab_android_move[Cave[y][x-1]]) goto android_w;
2032 if (tab_android_move[Cave[y+1][x-1]]) goto android_sw;
2033 if (tab_android_move[Cave[y-1][x-1]]) goto android_nw;
2036 case 4: /* nowhere */
2040 if (tab_android_move[Cave[y][x+1]]) goto android_e;
2041 if (tab_android_move[Cave[y-1][x+1]]) goto android_ne;
2042 if (tab_android_move[Cave[y+1][x+1]]) goto android_se;
2045 case 6: /* south west */
2046 if (tab_android_move[Cave[y+1][x-1]]) goto android_sw;
2047 if (tab_android_move[Cave[y+1][x]]) goto android_s;
2048 if (tab_android_move[Cave[y][x-1]]) goto android_w;
2052 if (tab_android_move[Cave[y+1][x]]) goto android_s;
2053 if (tab_android_move[Cave[y+1][x+1]]) goto android_se;
2054 if (tab_android_move[Cave[y+1][x-1]]) goto android_sw;
2057 case 8: /* south east */
2058 if (tab_android_move[Cave[y+1][x+1]]) goto android_se;
2059 if (tab_android_move[Cave[y][x+1]]) goto android_e;
2060 if (tab_android_move[Cave[y+1][x]]) goto android_s;
2068 Next[y][x] = Xandroid;
2073 Cave[y][x] = Yandroid_nB;
2074 Cave[y-1][x] = Yandroid_n;
2075 Next[y-1][x] = Xandroid;
2076 play_element_sound(x, y, SAMPLE_android_move, element);
2081 Cave[y][x] = Yandroid_neB;
2082 Cave[y-1][x+1] = Yandroid_ne;
2083 Next[y-1][x+1] = Xandroid;
2084 play_element_sound(x, y, SAMPLE_android_move, element);
2089 Cave[y][x] = Yandroid_eB;
2090 Cave[y][x+1] = Yandroid_e;
2091 Next[y][x+1] = Xandroid;
2092 play_element_sound(x, y, SAMPLE_android_move, element);
2097 Cave[y][x] = Yandroid_seB;
2098 Cave[y+1][x+1] = Yandroid_se;
2099 Next[y+1][x+1] = Xandroid;
2100 play_element_sound(x, y, SAMPLE_android_move, element);
2105 Cave[y][x] = Yandroid_sB;
2106 Cave[y+1][x] = Yandroid_s;
2107 Next[y+1][x] = Xandroid;
2108 play_element_sound(x, y, SAMPLE_android_move, element);
2113 Cave[y][x] = Yandroid_swB;
2114 Cave[y+1][x-1] = Yandroid_sw;
2115 Next[y+1][x-1] = Xandroid;
2116 play_element_sound(x, y, SAMPLE_android_move, element);
2121 Cave[y][x] = Yandroid_wB;
2122 Cave[y][x-1] = Yandroid_w;
2123 Next[y][x-1] = Xandroid;
2124 play_element_sound(x, y, SAMPLE_android_move, element);
2129 Cave[y][x] = Yandroid_nwB;
2130 Cave[y-1][x-1] = Yandroid_nw;
2131 Next[y-1][x-1] = Xandroid;
2132 play_element_sound(x, y, SAMPLE_android_move, element);
2135 /* --------------------------------------------------------------------- */
2138 switch (Cave[y-1][x])
2148 Cave[y][x] = Yandroid_nB;
2149 if (Cave[y-2][x+1] == Xblank)
2150 Cave[y-2][x+1] = Yacid_splash_eB;
2151 if (Cave[y-2][x-1] == Xblank)
2152 Cave[y-2][x-1] = Yacid_splash_wB;
2153 Next[y][x] = Xblank;
2154 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
2158 case Yacid_splash_eB:
2159 case Yacid_splash_wB:
2160 Cave[y][x] = Yandroid_nB;
2161 Cave[y-1][x] = Yandroid_n;
2162 Next[y][x] = Xblank;
2163 Next[y-1][x] = Xandroid;
2164 play_element_sound(x, y, SAMPLE_android_move, element);
2172 switch (Cave[y-1][x])
2182 Cave[y][x] = Yandroid_nB;
2183 if (Cave[y-2][x+1] == Xblank)
2184 Cave[y-2][x+1] = Yacid_splash_eB;
2185 if (Cave[y-2][x-1] == Xblank)
2186 Cave[y-2][x-1] = Yacid_splash_wB;
2187 Next[y][x] = Xblank;
2188 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
2192 case Yacid_splash_eB:
2193 case Yacid_splash_wB:
2194 Cave[y][x] = Yandroid_nB;
2195 Cave[y-1][x] = Yandroid_n;
2196 Next[y][x] = Xblank;
2197 Next[y-1][x] = Xandroid_1_n;
2198 play_element_sound(x, y, SAMPLE_android_move, element);
2205 /* --------------------------------------------------------------------- */
2208 switch (Cave[y][x+1])
2218 Cave[y][x] = Yandroid_eB;
2219 if (Cave[y-1][x+2] == Xblank)
2220 Cave[y-1][x+2] = Yacid_splash_eB;
2221 if (Cave[y-1][x] == Xblank)
2222 Cave[y-1][x] = Yacid_splash_wB;
2223 Next[y][x] = Xblank;
2224 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
2228 case Yacid_splash_eB:
2229 case Yacid_splash_wB:
2230 Cave[y][x] = Yandroid_eB;
2231 Cave[y][x+1] = Yandroid_e;
2232 Next[y][x] = Xblank;
2233 Next[y][x+1] = Xandroid;
2234 play_element_sound(x, y, SAMPLE_android_move, element);
2242 switch (Cave[y][x+1])
2252 Cave[y][x] = Yandroid_eB;
2253 if (Cave[y-1][x+2] == Xblank)
2254 Cave[y-1][x+2] = Yacid_splash_eB;
2255 if (Cave[y-1][x] == Xblank)
2256 Cave[y-1][x] = Yacid_splash_wB;
2257 Next[y][x] = Xblank;
2258 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
2262 case Yacid_splash_eB:
2263 case Yacid_splash_wB:
2264 Cave[y][x] = Yandroid_eB;
2265 Cave[y][x+1] = Yandroid_e;
2266 Next[y][x] = Xblank;
2267 Next[y][x+1] = Xandroid_1_e;
2268 play_element_sound(x, y, SAMPLE_android_move, element);
2275 /* --------------------------------------------------------------------- */
2278 switch (Cave[y+1][x])
2288 Cave[y][x] = Yandroid_sB;
2289 if (Cave[y][x+1] == Xblank)
2290 Cave[y][x+1] = Yacid_splash_eB;
2291 if (Cave[y][x-1] == Xblank)
2292 Cave[y][x-1] = Yacid_splash_wB;
2293 Next[y][x] = Xblank;
2294 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
2298 case Yacid_splash_eB:
2299 case Yacid_splash_wB:
2300 Cave[y][x] = Yandroid_sB;
2301 Cave[y+1][x] = Yandroid_s;
2302 Next[y][x] = Xblank;
2303 Next[y+1][x] = Xandroid;
2304 play_element_sound(x, y, SAMPLE_android_move, element);
2312 switch (Cave[y+1][x])
2322 Cave[y][x] = Yandroid_sB;
2323 if (Cave[y][x+1] == Xblank)
2324 Cave[y][x+1] = Yacid_splash_eB;
2325 if (Cave[y][x-1] == Xblank)
2326 Cave[y][x-1] = Yacid_splash_wB;
2327 Next[y][x] = Xblank;
2328 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
2332 case Yacid_splash_eB:
2333 case Yacid_splash_wB:
2334 Cave[y][x] = Yandroid_sB;
2335 Cave[y+1][x] = Yandroid_s;
2336 Next[y][x] = Xblank;
2337 Next[y+1][x] = Xandroid_1_s;
2338 play_element_sound(x, y, SAMPLE_android_move, element);
2345 /* --------------------------------------------------------------------- */
2348 switch (Cave[y][x-1])
2358 Cave[y][x] = Yandroid_wB;
2359 if (Cave[y-1][x] == Xblank)
2360 Cave[y-1][x] = Yacid_splash_eB;
2361 if (Cave[y-1][x-2] == Xblank)
2362 Cave[y-1][x-2] = Yacid_splash_wB;
2363 Next[y][x] = Xblank;
2364 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
2368 case Yacid_splash_eB:
2369 case Yacid_splash_wB:
2370 Cave[y][x] = Yandroid_wB;
2371 Cave[y][x-1] = Yandroid_w;
2372 Next[y][x] = Xblank;
2373 Next[y][x-1] = Xandroid;
2374 play_element_sound(x, y, SAMPLE_android_move, element);
2382 switch (Cave[y][x-1])
2392 Cave[y][x] = Yandroid_wB;
2393 if (Cave[y-1][x] == Xblank)
2394 Cave[y-1][x] = Yacid_splash_eB;
2395 if (Cave[y-1][x-2] == Xblank)
2396 Cave[y-1][x-2] = Yacid_splash_wB;
2397 Next[y][x] = Xblank;
2398 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
2402 case Yacid_splash_eB:
2403 case Yacid_splash_wB:
2404 Cave[y][x] = Yandroid_wB;
2405 Cave[y][x-1] = Yandroid_w;
2406 Next[y][x] = Xblank;
2407 Next[y][x-1] = Xandroid_1_w;
2408 play_element_sound(x, y, SAMPLE_android_move, element);
2415 /* --------------------------------------------------------------------- */
2418 switch (Cave[y+1][x])
2428 Cave[y][x] = Yspring_sB;
2429 if (Cave[y][x+1] == Xblank)
2430 Cave[y][x+1] = Yacid_splash_eB;
2431 if (Cave[y][x-1] == Xblank)
2432 Cave[y][x-1] = Yacid_splash_wB;
2433 Next[y][x] = Xblank;
2434 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
2438 case Yacid_splash_eB:
2439 case Yacid_splash_wB:
2442 Cave[y][x] = Yspring_sB;
2443 Cave[y+1][x] = Yspring_s;
2444 Next[y][x] = Xblank;
2445 Next[y+1][x] = Xspring_fall;
2464 case Xemerald_pause:
2466 case Xdiamond_pause:
2494 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
2496 Cave[y][x] = Yspring_eB;
2497 Cave[y][x+1] = Yspring_e;
2498 if (Cave[y+1][x] == Xbumper)
2499 Cave[y+1][x] = XbumperB;
2500 Next[y][x] = Xblank;
2503 Next[y][x+1] = Xspring_e;
2505 Next[y][x+1] = Xspring_pause;
2511 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
2513 Cave[y][x] = Yspring_wB;
2514 Cave[y][x-1] = Yspring_w;
2515 if (Cave[y+1][x] == Xbumper)
2516 Cave[y+1][x] = XbumperB;
2517 Next[y][x] = Xblank;
2520 Next[y][x-1] = Xspring_w;
2522 Next[y][x-1] = Xspring_pause;
2530 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
2532 Cave[y][x] = Yspring_wB;
2533 Cave[y][x-1] = Yspring_w;
2534 if (Cave[y+1][x] == Xbumper)
2535 Cave[y+1][x] = XbumperB;
2536 Next[y][x] = Xblank;
2539 Next[y][x-1] = Xspring_w;
2541 Next[y][x-1] = Xspring_pause;
2547 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
2549 Cave[y][x] = Yspring_eB;
2550 Cave[y][x+1] = Yspring_e;
2551 if (Cave[y+1][x] == Xbumper)
2552 Cave[y+1][x] = XbumperB;
2553 Next[y][x] = Xblank;
2556 Next[y][x+1] = Xspring_e;
2558 Next[y][x+1] = Xspring_pause;
2569 /* --------------------------------------------------------------------- */
2572 switch (Cave[y+1][x])
2582 Cave[y][x] = Yspring_sB;
2583 if (Cave[y][x+1] == Xblank)
2584 Cave[y][x+1] = Yacid_splash_eB;
2585 if (Cave[y][x-1] == Xblank)
2586 Cave[y][x-1] = Yacid_splash_wB;
2587 Next[y][x] = Xblank;
2588 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
2592 case Yacid_splash_eB:
2593 case Yacid_splash_wB:
2594 Cave[y][x] = Yspring_sB;
2595 Cave[y+1][x] = Yspring_s;
2596 Next[y][x] = Xblank;
2597 Next[y+1][x] = Xspring_fall;
2601 Cave[y][x] = Xspring;
2602 Next[y][x] = Xspring;
2606 /* --------------------------------------------------------------------- */
2609 switch (Cave[y+1][x])
2619 Cave[y][x] = Yspring_sB;
2620 if (Cave[y][x+1] == Xblank)
2621 Cave[y][x+1] = Yacid_splash_eB;
2622 if (Cave[y][x-1] == Xblank)
2623 Cave[y][x-1] = Yacid_splash_wB;
2624 Next[y][x] = Xblank;
2625 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
2629 case Yacid_splash_eB:
2630 case Yacid_splash_wB:
2631 Cave[y][x] = Yspring_sB;
2632 Cave[y+1][x] = Yspring_s;
2633 Next[y][x] = Xblank;
2634 Next[y+1][x] = Xspring_fall;
2638 Cave[y+1][x] = XbumperB;
2641 switch (Cave[y][x+1])
2651 Cave[y][x] = Yspring_eB;
2652 if (Cave[y-1][x+2] == Xblank)
2653 Cave[y-1][x+2] = Yacid_splash_eB;
2654 if (Cave[y-1][x] == Xblank)
2655 Cave[y-1][x] = Yacid_splash_wB;
2656 Next[y][x] = Xblank;
2657 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
2661 case Yacid_splash_eB:
2662 case Yacid_splash_wB:
2667 Cave[y][x] = Yspring_eB;
2668 Cave[y][x+1] = Yspring_e;
2669 Next[y][x] = Xblank;
2670 Next[y][x+1] = Xspring_e;
2679 Cave[y][x] = Yspring_kill_eB;
2680 Cave[y][x+1] = Yspring_kill_e;
2681 Next[y][x] = Xblank;
2682 Next[y][x+1] = Xspring_e;
2683 play_element_sound(x, y, SAMPLE_slurp, Xalien);
2684 score += lev.slurp_score;
2689 Cave[y][x+1] = XbumperB;
2690 Next[y][x] = Xspring_w;
2691 play_element_sound(x, y, SAMPLE_spring, Xspring);
2695 Cave[y][x] = Xspring;
2696 Next[y][x] = Xspring;
2697 play_element_sound(x, y, SAMPLE_spring, Xspring);
2701 /* --------------------------------------------------------------------- */
2704 switch (Cave[y+1][x])
2714 Cave[y][x] = Yspring_sB;
2715 if (Cave[y][x+1] == Xblank)
2716 Cave[y][x+1] = Yacid_splash_eB;
2717 if (Cave[y][x-1] == Xblank)
2718 Cave[y][x-1] = Yacid_splash_wB;
2719 Next[y][x] = Xblank;
2720 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
2724 case Yacid_splash_eB:
2725 case Yacid_splash_wB:
2726 Cave[y][x] = Yspring_sB;
2727 Cave[y+1][x] = Yspring_s;
2728 Next[y][x] = Xblank;
2729 Next[y+1][x] = Xspring_fall;
2733 Cave[y+1][x] = XbumperB;
2736 switch (Cave[y][x-1])
2746 Cave[y][x] = Yspring_wB;
2747 if (Cave[y-1][x] == Xblank)
2748 Cave[y-1][x] = Yacid_splash_eB;
2749 if (Cave[y-1][x-2] == Xblank)
2750 Cave[y-1][x-2] = Yacid_splash_wB;
2751 Next[y][x] = Xblank;
2752 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
2756 case Yacid_splash_eB:
2757 case Yacid_splash_wB:
2762 Cave[y][x] = Yspring_wB;
2763 Cave[y][x-1] = Yspring_w;
2764 Next[y][x] = Xblank;
2765 Next[y][x-1] = Xspring_w;
2774 Cave[y][x] = Yspring_kill_wB;
2775 Cave[y][x-1] = Yspring_kill_w;
2776 Next[y][x] = Xblank;
2777 Next[y][x-1] = Xspring_w;
2778 play_element_sound(x, y, SAMPLE_slurp, Xalien);
2779 score += lev.slurp_score;
2784 Cave[y][x-1] = XbumperB;
2785 Next[y][x] = Xspring_e;
2786 play_element_sound(x, y, SAMPLE_spring, Xspring);
2790 Cave[y][x] = Xspring;
2791 Next[y][x] = Xspring;
2792 play_element_sound(x, y, SAMPLE_spring, Xspring);
2796 /* --------------------------------------------------------------------- */
2799 switch (Cave[y+1][x])
2809 Cave[y][x] = Yspring_sB;
2810 if (Cave[y][x+1] == Xblank)
2811 Cave[y][x+1] = Yacid_splash_eB;
2812 if (Cave[y][x-1] == Xblank)
2813 Cave[y][x-1] = Yacid_splash_wB;
2814 Next[y][x] = Xblank;
2815 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
2819 case Yacid_splash_eB:
2820 case Yacid_splash_wB:
2822 Cave[y][x] = Yspring_sB;
2823 Cave[y+1][x] = Yspring_s;
2824 Next[y][x] = Xblank;
2825 Next[y+1][x] = Xspring_fall;
2830 Cave[y+1][x] = Ybomb_eat;
2831 Next[y+1][x] = Znormal;
2832 Boom[y][x-1] = Xblank;
2833 Boom[y][x] = Xblank;
2834 Boom[y][x+1] = Xblank;
2835 Boom[y+1][x-1] = Xblank;
2836 Boom[y+1][x] = Xblank;
2837 Boom[y+1][x+1] = Xblank;
2838 Boom[y+2][x-1] = Xblank;
2839 Boom[y+2][x] = Xblank;
2840 Boom[y+2][x+1] = Xblank;
2841 #if PLAY_ELEMENT_SOUND
2842 play_element_sound(x, y, SAMPLE_boom, element);
2854 Cave[y][x] = Yspring_sB;
2855 Cave[y+1][x] = Ybug_spring;
2856 Next[y+1][x] = Znormal;
2857 Boom[y][x-1] = Xemerald;
2858 Boom[y][x] = Xemerald;
2859 Boom[y][x+1] = Xemerald;
2860 Boom[y+1][x-1] = Xemerald;
2861 Boom[y+1][x] = Xdiamond;
2862 Boom[y+1][x+1] = Xemerald;
2863 Boom[y+2][x-1] = Xemerald;
2864 Boom[y+2][x] = Xemerald;
2865 Boom[y+2][x+1] = Xemerald;
2866 #if PLAY_ELEMENT_SOUND
2867 play_element_sound(x, y, SAMPLE_boom, element);
2869 score += lev.bug_score;
2880 Cave[y][x] = Yspring_sB;
2881 Cave[y+1][x] = Ytank_spring;
2882 Next[y+1][x] = Znormal;
2883 Boom[y][x-1] = Xblank;
2884 Boom[y][x] = Xblank;
2885 Boom[y][x+1] = Xblank;
2886 Boom[y+1][x-1] = Xblank;
2887 Boom[y+1][x] = Xblank;
2888 Boom[y+1][x+1] = Xblank;
2889 Boom[y+2][x-1] = Xblank;
2890 Boom[y+2][x] = Xblank;
2891 Boom[y+2][x+1] = Xblank;
2892 #if PLAY_ELEMENT_SOUND
2893 play_element_sound(x, y, SAMPLE_boom, element);
2895 score += lev.tank_score;
2902 Cave[y][x] = Yspring_sB;
2903 Cave[y+1][x] = Yeater_spring;
2904 Next[y+1][x] = Znormal;
2905 Boom[y][x-1] = lev.eater_array[lev.eater_pos][0];
2906 Boom[y][x] = lev.eater_array[lev.eater_pos][1];
2907 Boom[y][x+1] = lev.eater_array[lev.eater_pos][2];
2908 Boom[y+1][x-1] = lev.eater_array[lev.eater_pos][3];
2909 Boom[y+1][x] = lev.eater_array[lev.eater_pos][4];
2910 Boom[y+1][x+1] = lev.eater_array[lev.eater_pos][5];
2911 Boom[y+2][x-1] = lev.eater_array[lev.eater_pos][6];
2912 Boom[y+2][x] = lev.eater_array[lev.eater_pos][7];
2913 Boom[y+2][x+1] = lev.eater_array[lev.eater_pos][8];
2914 #if PLAY_ELEMENT_SOUND
2915 play_element_sound(x, y, SAMPLE_boom, element);
2917 lev.eater_pos = (lev.eater_pos + 1) & 7;
2918 score += lev.eater_score;
2923 Cave[y][x] = Yspring_sB;
2924 Cave[y+1][x] = Yalien_spring;
2925 Next[y+1][x] = Znormal;
2926 Boom[y][x-1] = Xblank;
2927 Boom[y][x] = Xblank;
2928 Boom[y][x+1] = Xblank;
2929 Boom[y+1][x-1] = Xblank;
2930 Boom[y+1][x] = Xblank;
2931 Boom[y+1][x+1] = Xblank;
2932 Boom[y+2][x-1] = Xblank;
2933 Boom[y+2][x] = Xblank;
2934 Boom[y+2][x+1] = Xblank;
2935 #if PLAY_ELEMENT_SOUND
2936 play_element_sound(x, y, SAMPLE_boom, element);
2938 score += lev.alien_score;
2942 Cave[y][x] = Xspring;
2943 Next[y][x] = Xspring;
2944 play_element_sound(x, y, SAMPLE_spring, Xspring);
2948 /* --------------------------------------------------------------------- */
2951 if (Cave[y][x+1] == Xdiamond)
2953 Cave[y][x+1] = Ydiamond_eat;
2954 Next[y][x+1] = Xblank;
2955 play_element_sound(x, y, SAMPLE_eater_eat, element);
2959 if (Cave[y+1][x] == Xdiamond)
2961 Cave[y+1][x] = Ydiamond_eat;
2962 Next[y+1][x] = Xblank;
2963 play_element_sound(x, y, SAMPLE_eater_eat, element);
2967 if (Cave[y][x-1] == Xdiamond)
2969 Cave[y][x-1] = Ydiamond_eat;
2970 Next[y][x-1] = Xblank;
2971 play_element_sound(x, y, SAMPLE_eater_eat, element);
2975 if (Cave[y-1][x] == Xdiamond)
2977 Cave[y-1][x] = Ydiamond_eat;
2978 Next[y-1][x] = Xblank;
2979 play_element_sound(x, y, SAMPLE_eater_eat, element);
2983 switch (Cave[y-1][x])
2993 Cave[y][x] = Yeater_nB;
2994 if (Cave[y-2][x+1] == Xblank)
2995 Cave[y-2][x+1] = Yacid_splash_eB;
2996 if (Cave[y-2][x-1] == Xblank)
2997 Cave[y-2][x-1] = Yacid_splash_wB;
2998 Next[y][x] = Xblank;
2999 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
3003 case Yacid_splash_eB:
3004 case Yacid_splash_wB:
3008 Cave[y][x] = Yeater_nB;
3009 Cave[y-1][x] = Yeater_n;
3010 Next[y][x] = Xblank;
3011 Next[y-1][x] = Xeater_n;
3015 Next[y][x] = RANDOM & 1 ? Xeater_e : Xeater_w;
3016 play_element_sound(x, y, SAMPLE_eater, element);
3020 /* --------------------------------------------------------------------- */
3023 if (Cave[y+1][x] == Xdiamond)
3025 Cave[y+1][x] = Ydiamond_eat;
3026 Next[y+1][x] = Xblank;
3027 play_element_sound(x, y, SAMPLE_eater_eat, element);
3031 if (Cave[y][x-1] == Xdiamond)
3033 Cave[y][x-1] = Ydiamond_eat;
3034 Next[y][x-1] = Xblank;
3035 play_element_sound(x, y, SAMPLE_eater_eat, element);
3039 if (Cave[y-1][x] == Xdiamond)
3041 Cave[y-1][x] = Ydiamond_eat;
3042 Next[y-1][x] = Xblank;
3043 play_element_sound(x, y, SAMPLE_eater_eat, element);
3047 if (Cave[y][x+1] == Xdiamond)
3049 Cave[y][x+1] = Ydiamond_eat;
3050 Next[y][x+1] = Xblank;
3051 play_element_sound(x, y, SAMPLE_eater_eat, element);
3055 switch (Cave[y][x+1])
3065 Cave[y][x] = Yeater_eB;
3066 if (Cave[y-1][x+2] == Xblank)
3067 Cave[y-1][x+2] = Yacid_splash_eB;
3068 if (Cave[y-1][x] == Xblank)
3069 Cave[y-1][x] = Yacid_splash_wB;
3070 Next[y][x] = Xblank;
3071 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
3075 case Yacid_splash_eB:
3076 case Yacid_splash_wB:
3080 Cave[y][x] = Yeater_eB;
3081 Cave[y][x+1] = Yeater_e;
3082 Next[y][x] = Xblank;
3083 Next[y][x+1] = Xeater_e;
3087 Next[y][x] = RANDOM & 1 ? Xeater_n : Xeater_s;
3088 play_element_sound(x, y, SAMPLE_eater, element);
3092 /* --------------------------------------------------------------------- */
3095 if (Cave[y][x-1] == Xdiamond)
3097 Cave[y][x-1] = Ydiamond_eat;
3098 Next[y][x-1] = Xblank;
3099 play_element_sound(x, y, SAMPLE_eater_eat, element);
3103 if (Cave[y-1][x] == Xdiamond)
3105 Cave[y-1][x] = Ydiamond_eat;
3106 Next[y-1][x] = Xblank;
3107 play_element_sound(x, y, SAMPLE_eater_eat, element);
3111 if (Cave[y][x+1] == Xdiamond)
3113 Cave[y][x+1] = Ydiamond_eat;
3114 Next[y][x+1] = Xblank;
3115 play_element_sound(x, y, SAMPLE_eater_eat, element);
3119 if (Cave[y+1][x] == Xdiamond)
3121 Cave[y+1][x] = Ydiamond_eat;
3122 Next[y+1][x] = Xblank;
3123 play_element_sound(x, y, SAMPLE_eater_eat, element);
3127 switch (Cave[y+1][x])
3137 Cave[y][x] = Yeater_sB;
3138 if (Cave[y][x+1] == Xblank)
3139 Cave[y][x+1] = Yacid_splash_eB;
3140 if (Cave[y][x-1] == Xblank)
3141 Cave[y][x-1] = Yacid_splash_wB;
3142 Next[y][x] = Xblank;
3143 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
3147 case Yacid_splash_eB:
3148 case Yacid_splash_wB:
3152 Cave[y][x] = Yeater_sB;
3153 Cave[y+1][x] = Yeater_s;
3154 Next[y][x] = Xblank;
3155 Next[y+1][x] = Xeater_s;
3159 Next[y][x] = RANDOM & 1 ? Xeater_e : Xeater_w;
3160 play_element_sound(x, y, SAMPLE_eater, element);
3164 /* --------------------------------------------------------------------- */
3167 if (Cave[y-1][x] == Xdiamond)
3169 Cave[y-1][x] = Ydiamond_eat;
3170 Next[y-1][x] = Xblank;
3171 play_element_sound(x, y, SAMPLE_eater_eat, element);
3175 if (Cave[y][x+1] == Xdiamond)
3177 Cave[y][x+1] = Ydiamond_eat;
3178 Next[y][x+1] = Xblank;
3179 play_element_sound(x, y, SAMPLE_eater_eat, element);
3183 if (Cave[y+1][x] == Xdiamond)
3185 Cave[y+1][x] = Ydiamond_eat;
3186 Next[y+1][x] = Xblank;
3187 play_element_sound(x, y, SAMPLE_eater_eat, element);
3191 if (Cave[y][x-1] == Xdiamond)
3193 Cave[y][x-1] = Ydiamond_eat;
3194 Next[y][x-1] = Xblank;
3195 play_element_sound(x, y, SAMPLE_eater_eat, element);
3199 switch (Cave[y][x-1])
3209 Cave[y][x] = Yeater_wB;
3210 if (Cave[y-1][x] == Xblank)
3211 Cave[y-1][x] = Yacid_splash_eB;
3212 if (Cave[y-1][x-2] == Xblank)
3213 Cave[y-1][x-2] = Yacid_splash_wB;
3214 Next[y][x] = Xblank;
3215 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
3219 case Yacid_splash_eB:
3220 case Yacid_splash_wB:
3224 Cave[y][x] = Yeater_wB;
3225 Cave[y][x-1] = Yeater_w;
3226 Next[y][x] = Xblank;
3227 Next[y][x-1] = Xeater_w;
3231 Next[y][x] = RANDOM & 1 ? Xeater_n : Xeater_s;
3232 play_element_sound(x, y, SAMPLE_eater, element);
3236 /* --------------------------------------------------------------------- */
3249 set_nearest_player_xy(x, y, &dx, &dy);
3259 else if (ply1.alive && ply2.alive)
3261 if ((ply1.x > x ? ply1.x - x : x - ply1.x) +
3262 (ply1.y > y ? ply1.y - y : y - ply1.y) <
3263 (ply2.x > x ? ply2.x - x : x - ply2.x) +
3264 (ply2.y > y ? ply2.y - y : y - ply2.y))
3275 else if (ply1.alive)
3280 else if (ply2.alive)
3297 switch (Cave[y-1][x])
3307 Cave[y][x] = Yalien_nB;
3308 if (Cave[y-2][x+1] == Xblank)
3309 Cave[y-2][x+1] = Yacid_splash_eB;
3310 if (Cave[y-2][x-1] == Xblank)
3311 Cave[y-2][x-1] = Yacid_splash_wB;
3312 Next[y][x] = Xblank;
3313 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
3317 case Yacid_splash_eB:
3318 case Yacid_splash_wB:
3322 Cave[y][x] = Yalien_nB;
3323 Cave[y-1][x] = Yalien_n;
3324 Next[y][x] = Xblank;
3325 Next[y-1][x] = Xalien_pause;
3326 play_element_sound(x, y, SAMPLE_alien, Xalien);
3332 switch (Cave[y+1][x])
3342 Cave[y][x] = Yalien_sB;
3343 Next[y][x] = Xblank;
3344 if (Cave[y][x+1] == Xblank)
3345 Cave[y][x+1] = Yacid_splash_eB;
3346 if (Cave[y][x-1] == Xblank)
3347 Cave[y][x-1] = Yacid_splash_wB;
3348 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
3352 case Yacid_splash_eB:
3353 case Yacid_splash_wB:
3357 Cave[y][x] = Yalien_sB;
3358 Cave[y+1][x] = Yalien_s;
3359 Next[y][x] = Xblank;
3360 Next[y+1][x] = Xalien_pause;
3361 play_element_sound(x, y, SAMPLE_alien, Xalien);
3370 switch (Cave[y][x+1])
3380 Cave[y][x] = Yalien_eB;
3381 if (Cave[y-1][x+2] == Xblank)
3382 Cave[y-1][x+2] = Yacid_splash_eB;
3383 if (Cave[y-1][x] == Xblank)
3384 Cave[y-1][x] = Yacid_splash_wB;
3385 Next[y][x] = Xblank;
3386 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
3390 case Yacid_splash_eB:
3391 case Yacid_splash_wB:
3395 Cave[y][x] = Yalien_eB;
3396 Cave[y][x+1] = Yalien_e;
3397 Next[y][x] = Xblank;
3398 Next[y][x+1] = Xalien_pause;
3399 play_element_sound(x, y, SAMPLE_alien, Xalien);
3405 switch (Cave[y][x-1])
3415 Cave[y][x] = Yalien_wB;
3416 if (Cave[y-1][x] == Xblank)
3417 Cave[y-1][x] = Yacid_splash_eB;
3418 if (Cave[y-1][x-2] == Xblank)
3419 Cave[y-1][x-2] = Yacid_splash_wB;
3420 Next[y][x] = Xblank;
3421 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
3425 case Yacid_splash_eB:
3426 case Yacid_splash_wB:
3430 Cave[y][x] = Yalien_wB;
3431 Cave[y][x-1] = Yalien_w;
3432 Next[y][x] = Xblank;
3433 Next[y][x-1] = Xalien_pause;
3434 play_element_sound(x, y, SAMPLE_alien, Xalien);
3443 Next[y][x] = Xalien;
3446 /* --------------------------------------------------------------------- */
3449 switch (Cave[y+1][x])
3459 Cave[y][x] = Yemerald_sB;
3460 if (Cave[y][x+1] == Xblank)
3461 Cave[y][x+1] = Yacid_splash_eB;
3462 if (Cave[y][x-1] == Xblank)
3463 Cave[y][x-1] = Yacid_splash_wB;
3464 Next[y][x] = Xblank;
3465 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
3469 case Yacid_splash_eB:
3470 case Yacid_splash_wB:
3471 Cave[y][x] = Yemerald_sB;
3472 Cave[y+1][x] = Yemerald_s;
3473 Next[y][x] = Xblank;
3474 Next[y+1][x] = Xemerald_fall;
3493 case Xemerald_pause:
3495 case Xdiamond_pause:
3532 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
3534 Cave[y][x] = Yemerald_eB;
3535 Cave[y][x+1] = Yemerald_e;
3536 Next[y][x] = Xblank;
3537 Next[y][x+1] = Xemerald_pause;
3541 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
3543 Cave[y][x] = Yemerald_wB;
3544 Cave[y][x-1] = Yemerald_w;
3545 Next[y][x] = Xblank;
3546 Next[y][x-1] = Xemerald_pause;
3552 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
3554 Cave[y][x] = Yemerald_wB;
3555 Cave[y][x-1] = Yemerald_w;
3556 Next[y][x] = Xblank;
3557 Next[y][x-1] = Xemerald_pause;
3561 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
3563 Cave[y][x] = Yemerald_eB;
3564 Cave[y][x+1] = Yemerald_e;
3565 Next[y][x] = Xblank;
3566 Next[y][x+1] = Xemerald_pause;
3572 if (++lev.shine_cnt > 50)
3574 lev.shine_cnt = RANDOM & 7;
3575 Cave[y][x] = Xemerald_shine;
3581 /* --------------------------------------------------------------------- */
3583 case Xemerald_pause:
3584 switch (Cave[y+1][x])
3594 Cave[y][x] = Yemerald_sB;
3595 if (Cave[y][x+1] == Xblank)
3596 Cave[y][x+1] = Yacid_splash_eB;
3597 if (Cave[y][x-1] == Xblank)
3598 Cave[y][x-1] = Yacid_splash_wB;
3599 Next[y][x] = Xblank;
3600 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
3604 case Yacid_splash_eB:
3605 case Yacid_splash_wB:
3606 Cave[y][x] = Yemerald_sB;
3607 Cave[y+1][x] = Yemerald_s;
3608 Next[y][x] = Xblank;
3609 Next[y+1][x] = Xemerald_fall;
3613 Cave[y][x] = Xemerald;
3614 Next[y][x] = Xemerald;
3618 /* --------------------------------------------------------------------- */
3621 switch (Cave[y+1][x])
3631 Cave[y][x] = Yemerald_sB;
3632 if (Cave[y][x+1] == Xblank)
3633 Cave[y][x+1] = Yacid_splash_eB;
3634 if (Cave[y][x-1] == Xblank)
3635 Cave[y][x-1] = Yacid_splash_wB;
3636 Next[y][x] = Xblank;
3637 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
3641 case Yacid_splash_eB:
3642 case Yacid_splash_wB:
3644 Cave[y][x] = Yemerald_sB;
3645 Cave[y+1][x] = Yemerald_s;
3646 Next[y][x] = Xblank;
3647 Next[y+1][x] = Xemerald_fall;
3651 if (lev.wonderwall_time)
3653 lev.wonderwall_state = 1;
3654 Cave[y][x] = Yemerald_sB;
3655 if (tab_blank[Cave[y+2][x]])
3657 Cave[y+2][x] = Ydiamond_s;
3658 Next[y+2][x] = Xdiamond_fall;
3661 Next[y][x] = Xblank;
3662 play_element_sound(x, y, SAMPLE_wonderfall, Xwonderwall);
3667 Cave[y][x] = Xemerald;
3668 Next[y][x] = Xemerald;
3669 play_element_sound(x, y, SAMPLE_diamond, Xemerald);
3673 /* --------------------------------------------------------------------- */
3676 switch (Cave[y+1][x])
3686 Cave[y][x] = Ydiamond_sB;
3687 if (Cave[y][x+1] == Xblank)
3688 Cave[y][x+1] = Yacid_splash_eB;
3689 if (Cave[y][x-1] == Xblank)
3690 Cave[y][x-1] = Yacid_splash_wB;
3691 Next[y][x] = Xblank;
3692 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
3696 case Yacid_splash_eB:
3697 case Yacid_splash_wB:
3698 Cave[y][x] = Ydiamond_sB;
3699 Cave[y+1][x] = Ydiamond_s;
3700 Next[y][x] = Xblank;
3701 Next[y+1][x] = Xdiamond_fall;
3720 case Xemerald_pause:
3722 case Xdiamond_pause:
3759 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
3761 Cave[y][x] = Ydiamond_eB;
3762 Cave[y][x+1] = Ydiamond_e;
3763 Next[y][x] = Xblank;
3764 Next[y][x+1] = Xdiamond_pause;
3768 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
3770 Cave[y][x] = Ydiamond_wB;
3771 Cave[y][x-1] = Ydiamond_w;
3772 Next[y][x] = Xblank;
3773 Next[y][x-1] = Xdiamond_pause;
3779 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
3781 Cave[y][x] = Ydiamond_wB;
3782 Cave[y][x-1] = Ydiamond_w;
3783 Next[y][x] = Xblank;
3784 Next[y][x-1] = Xdiamond_pause;
3788 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
3790 Cave[y][x] = Ydiamond_eB;
3791 Cave[y][x+1] = Ydiamond_e;
3792 Next[y][x] = Xblank;
3793 Next[y][x+1] = Xdiamond_pause;
3799 if (++lev.shine_cnt > 50)
3801 lev.shine_cnt = RANDOM & 7;
3802 Cave[y][x] = Xdiamond_shine;
3808 /* --------------------------------------------------------------------- */
3810 case Xdiamond_pause:
3811 switch (Cave[y+1][x])
3821 Cave[y][x] = Ydiamond_sB;
3822 if (Cave[y][x+1] == Xblank)
3823 Cave[y][x+1] = Yacid_splash_eB;
3824 if (Cave[y][x-1] == Xblank)
3825 Cave[y][x-1] = Yacid_splash_wB;
3826 Next[y][x] = Xblank;
3827 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
3831 case Yacid_splash_eB:
3832 case Yacid_splash_wB:
3833 Cave[y][x] = Ydiamond_sB;
3834 Cave[y+1][x] = Ydiamond_s;
3835 Next[y][x] = Xblank;
3836 Next[y+1][x] = Xdiamond_fall;
3840 Cave[y][x] = Xdiamond;
3841 Next[y][x] = Xdiamond;
3845 /* --------------------------------------------------------------------- */
3848 switch (Cave[y+1][x])
3858 Cave[y][x] = Ydiamond_sB;
3859 if (Cave[y][x+1] == Xblank)
3860 Cave[y][x+1] = Yacid_splash_eB;
3861 if (Cave[y][x-1] == Xblank)
3862 Cave[y][x-1] = Yacid_splash_wB;
3863 Next[y][x] = Xblank;
3864 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
3868 case Yacid_splash_eB:
3869 case Yacid_splash_wB:
3871 Cave[y][x] = Ydiamond_sB;
3872 Cave[y+1][x] = Ydiamond_s;
3873 Next[y][x] = Xblank;
3874 Next[y+1][x] = Xdiamond_fall;
3878 if (lev.wonderwall_time)
3880 lev.wonderwall_state = 1;
3881 Cave[y][x] = Ydiamond_sB;
3882 if (tab_blank[Cave[y+2][x]])
3884 Cave[y+2][x] = Ystone_s;
3885 Next[y+2][x] = Xstone_fall;
3888 Next[y][x] = Xblank;
3889 play_element_sound(x, y, SAMPLE_wonderfall, Xwonderwall);
3894 Cave[y][x] = Xdiamond;
3895 Next[y][x] = Xdiamond;
3896 play_element_sound(x, y, SAMPLE_diamond, Xdiamond);
3900 /* --------------------------------------------------------------------- */
3903 switch (Cave[y+1][x])
3913 Cave[y][x] = Ydrip_s1B;
3914 if (Cave[y][x+1] == Xblank)
3915 Cave[y][x+1] = Yacid_splash_eB;
3916 if (Cave[y][x-1] == Xblank)
3917 Cave[y][x-1] = Yacid_splash_wB;
3918 Next[y][x] = Xdrip_stretchB;
3919 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
3923 case Yacid_splash_eB:
3924 case Yacid_splash_wB:
3928 Cave[y][x] = Ydrip_s1B;
3929 Cave[y+1][x] = Ydrip_s1;
3930 Next[y][x] = Xdrip_stretchB;
3931 Next[y+1][x] = Xdrip_stretch;
3972 play_element_sound(x, y, SAMPLE_drip, Xdrip_fall);
3976 /* --------------------------------------------------------------------- */
3979 Cave[y][x] = Ydrip_s2;
3980 Next[y][x] = Xdrip_fall;
3983 case Xdrip_stretchB:
3984 Cave[y][x] = Ydrip_s2B;
3985 Next[y][x] = Xblank;
3989 Next[y][x] = Xdrip_fall;
3992 /* --------------------------------------------------------------------- */
3995 switch (Cave[y+1][x])
4005 Cave[y][x] = Ybomb_sB;
4006 if (Cave[y][x+1] == Xblank)
4007 Cave[y][x+1] = Yacid_splash_eB;
4008 if (Cave[y][x-1] == Xblank)
4009 Cave[y][x-1] = Yacid_splash_wB;
4010 Next[y][x] = Xblank;
4011 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
4015 case Yacid_splash_eB:
4016 case Yacid_splash_wB:
4017 Cave[y][x] = Ybomb_sB;
4018 Cave[y+1][x] = Ybomb_s;
4019 Next[y][x] = Xblank;
4020 Next[y+1][x] = Xbomb_fall;
4039 case Xemerald_pause:
4041 case Xdiamond_pause:
4069 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
4071 Cave[y][x] = Ybomb_eB;
4072 Cave[y][x+1] = Ybomb_e;
4073 Next[y][x] = Xblank;
4074 Next[y][x+1] = Xbomb_pause;
4078 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
4080 Cave[y][x] = Ybomb_wB;
4081 Cave[y][x-1] = Ybomb_w;
4082 Next[y][x] = Xblank;
4083 Next[y][x-1] = Xbomb_pause;
4089 if (tab_blank[Cave[y][x-1]] && tab_acid[Cave[y+1][x-1]])
4091 Cave[y][x] = Ybomb_wB;
4092 Cave[y][x-1] = Ybomb_w;
4093 Next[y][x] = Xblank;
4094 Next[y][x-1] = Xbomb_pause;
4098 if (tab_blank[Cave[y][x+1]] && tab_acid[Cave[y+1][x+1]])
4100 Cave[y][x] = Ybomb_eB;
4101 Cave[y][x+1] = Ybomb_e;
4102 Next[y][x] = Xblank;
4103 Next[y][x+1] = Xbomb_pause;
4112 /* --------------------------------------------------------------------- */
4115 switch (Cave[y+1][x])
4125 Cave[y][x] = Ybomb_sB;
4126 if (Cave[y][x+1] == Xblank)
4127 Cave[y][x+1] = Yacid_splash_eB;
4128 if (Cave[y][x-1] == Xblank)
4129 Cave[y][x-1] = Yacid_splash_wB;
4130 Next[y][x] = Xblank;
4131 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
4135 case Yacid_splash_eB:
4136 case Yacid_splash_wB:
4137 Cave[y][x] = Ybomb_sB;
4138 Cave[y+1][x] = Ybomb_s;
4139 Next[y][x] = Xblank;
4140 Next[y+1][x] = Xbomb_fall;
4149 /* --------------------------------------------------------------------- */
4152 switch (Cave[y+1][x])
4162 Cave[y][x] = Ybomb_sB;
4163 if (Cave[y][x+1] == Xblank)
4164 Cave[y][x+1] = Yacid_splash_eB;
4165 if (Cave[y][x-1] == Xblank)
4166 Cave[y][x-1] = Yacid_splash_wB;
4167 Next[y][x] = Xblank;
4168 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
4172 case Yacid_splash_eB:
4173 case Yacid_splash_wB:
4174 Cave[y][x] = Ybomb_sB;
4175 Cave[y+1][x] = Ybomb_s;
4176 Next[y][x] = Xblank;
4177 Next[y+1][x] = Xbomb_fall;
4181 Cave[y][x] = Ybomb_eat;
4182 Next[y][x] = Znormal;
4183 Boom[y-1][x-1] = Xblank;
4184 Boom[y-1][x] = Xblank;
4185 Boom[y-1][x+1] = Xblank;
4186 Boom[y][x-1] = Xblank;
4187 Boom[y][x] = Xblank;
4188 Boom[y][x+1] = Xblank;
4189 Boom[y+1][x-1] = Xblank;
4190 Boom[y+1][x] = Xblank;
4191 Boom[y+1][x+1] = Xblank;
4192 #if PLAY_ELEMENT_SOUND
4193 play_element_sound(x, y, SAMPLE_boom, element);
4198 /* --------------------------------------------------------------------- */
4201 if (lev.wind_cnt == 0)
4204 switch (lev.wind_direction)
4207 switch (Cave[y-1][x])
4217 Cave[y][x] = Yballoon_nB;
4218 if (Cave[y-2][x+1] == Xblank)
4219 Cave[y-2][x+1] = Yacid_splash_eB;
4220 if (Cave[y-2][x-1] == Xblank)
4221 Cave[y-2][x-1] = Yacid_splash_wB;
4222 Next[y][x] = Xblank;
4223 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
4227 case Yacid_splash_eB:
4228 case Yacid_splash_wB:
4229 Cave[y][x] = Yballoon_nB;
4230 Cave[y-1][x] = Yballoon_n;
4231 Next[y][x] = Xblank;
4232 Next[y-1][x] = Xballoon;
4240 switch (Cave[y][x+1])
4250 Cave[y][x] = Yballoon_eB;
4251 if (Cave[y-1][x+2] == Xblank)
4252 Cave[y-1][x+2] = Yacid_splash_eB;
4253 if (Cave[y-1][x] == Xblank)
4254 Cave[y-1][x] = Yacid_splash_wB;
4255 Next[y][x] = Xblank;
4256 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
4260 case Yacid_splash_eB:
4261 case Yacid_splash_wB:
4262 Cave[y][x] = Yballoon_eB;
4263 Cave[y][x+1] = Yballoon_e;
4264 Next[y][x] = Xblank;
4265 Next[y][x+1] = Xballoon;
4273 switch (Cave[y+1][x])
4283 Cave[y][x] = Yballoon_sB;
4284 if (Cave[y][x+1] == Xblank)
4285 Cave[y][x+1] = Yacid_splash_eB;
4286 if (Cave[y][x-1] == Xblank)
4287 Cave[y][x-1] = Yacid_splash_wB;
4288 Next[y][x] = Xblank;
4289 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
4293 case Yacid_splash_eB:
4294 case Yacid_splash_wB:
4295 Cave[y][x] = Yballoon_sB;
4296 Cave[y+1][x] = Yballoon_s;
4297 Next[y][x] = Xblank;
4298 Next[y+1][x] = Xballoon;
4306 switch (Cave[y][x-1])
4316 Cave[y][x] = Yballoon_wB;
4317 if (Cave[y-1][x] == Xblank)
4318 Cave[y-1][x] = Yacid_splash_eB;
4319 if (Cave[y-1][x-2] == Xblank)
4320 Cave[y-1][x-2] = Yacid_splash_wB;
4321 Next[y][x] = Xblank;
4322 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
4326 case Yacid_splash_eB:
4327 case Yacid_splash_wB:
4328 Cave[y][x] = Yballoon_wB;
4329 Cave[y][x-1] = Yballoon_w;
4330 Next[y][x] = Xblank;
4331 Next[y][x-1] = Xballoon;
4339 /* --------------------------------------------------------------------- */
4342 Next[y][x] = Xacid_2;
4346 Next[y][x] = Xacid_3;
4350 Next[y][x] = Xacid_4;
4354 Next[y][x] = Xacid_5;
4358 Next[y][x] = Xacid_6;
4362 Next[y][x] = Xacid_7;
4366 Next[y][x] = Xacid_8;
4370 Next[y][x] = Xacid_1;
4374 Next[y][x] = Xfake_acid_2;
4378 Next[y][x] = Xfake_acid_3;
4382 Next[y][x] = Xfake_acid_4;
4386 Next[y][x] = Xfake_acid_5;
4390 Next[y][x] = Xfake_acid_6;
4394 Next[y][x] = Xfake_acid_7;
4398 Next[y][x] = Xfake_acid_8;
4402 Next[y][x] = Xfake_acid_1;
4405 /* --------------------------------------------------------------------- */
4408 if (lev.ball_state == 0)
4411 Cave[y][x] = Xball_1B;
4412 Next[y][x] = Xball_2;
4419 if (lev.ball_state == 0)
4422 Cave[y][x] = Xball_2B;
4423 Next[y][x] = Xball_1;
4431 play_element_sound(x, y, SAMPLE_ball, element);
4432 if (lev.ball_random)
4437 if (lev.ball_array[lev.ball_pos][0] != Xblank &&
4438 tab_blank[Cave[y-1][x-1]])
4440 Cave[y-1][x-1] = Yball_eat;
4441 Next[y-1][x-1] = lev.ball_array[lev.ball_pos][0];
4446 if (lev.ball_array[lev.ball_pos][1] != Xblank &&
4447 tab_blank[Cave[y-1][x]])
4449 Cave[y-1][x] = Yball_eat;
4450 Next[y-1][x] = lev.ball_array[lev.ball_pos][1];
4455 if (lev.ball_array[lev.ball_pos][2] != Xblank &&
4456 tab_blank[Cave[y-1][x+1]])
4458 Cave[y-1][x+1] = Yball_eat;
4459 Next[y-1][x+1] = lev.ball_array[lev.ball_pos][2];
4464 if (lev.ball_array[lev.ball_pos][3] != Xblank &&
4465 tab_blank[Cave[y][x-1]])
4467 Cave[y][x-1] = Yball_eat;
4468 Next[y][x-1] = lev.ball_array[lev.ball_pos][3];
4473 if (lev.ball_array[lev.ball_pos][4] != Xblank &&
4474 tab_blank[Cave[y][x+1]])
4476 Cave[y][x+1] = Yball_eat;
4477 Next[y][x+1] = lev.ball_array[lev.ball_pos][4];
4482 if (lev.ball_array[lev.ball_pos][5] != Xblank &&
4483 tab_blank[Cave[y+1][x-1]])
4485 Cave[y+1][x-1] = Yball_eat;
4486 Next[y+1][x-1] = lev.ball_array[lev.ball_pos][5];
4491 if (lev.ball_array[lev.ball_pos][6] != Xblank &&
4492 tab_blank[Cave[y+1][x]])
4494 Cave[y+1][x] = Yball_eat;
4495 Next[y+1][x] = lev.ball_array[lev.ball_pos][6];
4500 if (lev.ball_array[lev.ball_pos][7] != Xblank &&
4501 tab_blank[Cave[y+1][x+1]])
4503 Cave[y+1][x+1] = Yball_eat;
4504 Next[y+1][x+1] = lev.ball_array[lev.ball_pos][7];
4511 if (lev.ball_array[lev.ball_pos][0] != Xblank &&
4512 tab_blank[Cave[y-1][x-1]])
4514 Cave[y-1][x-1] = Yball_eat;
4515 Next[y-1][x-1] = lev.ball_array[lev.ball_pos][0];
4518 if (lev.ball_array[lev.ball_pos][1] != Xblank &&
4519 tab_blank[Cave[y-1][x]])
4521 Cave[y-1][x] = Yball_eat;
4522 Next[y-1][x] = lev.ball_array[lev.ball_pos][1];
4525 if (lev.ball_array[lev.ball_pos][2] != Xblank &&
4526 tab_blank[Cave[y-1][x+1]])
4528 Cave[y-1][x+1] = Yball_eat;
4529 Next[y-1][x+1] = lev.ball_array[lev.ball_pos][2];
4532 if (lev.ball_array[lev.ball_pos][3] != Xblank &&
4533 tab_blank[Cave[y][x-1]])
4535 Cave[y][x-1] = Yball_eat;
4536 Next[y][x-1] = lev.ball_array[lev.ball_pos][3];
4539 if (lev.ball_array[lev.ball_pos][4] != Xblank &&
4540 tab_blank[Cave[y][x+1]])
4542 Cave[y][x+1] = Yball_eat;
4543 Next[y][x+1] = lev.ball_array[lev.ball_pos][4];
4546 if (lev.ball_array[lev.ball_pos][5] != Xblank &&
4547 tab_blank[Cave[y+1][x-1]])
4549 Cave[y+1][x-1] = Yball_eat;
4550 Next[y+1][x-1] = lev.ball_array[lev.ball_pos][5];
4553 if (lev.ball_array[lev.ball_pos][6] != Xblank &&
4554 tab_blank[Cave[y+1][x]])
4556 Cave[y+1][x] = Yball_eat;
4557 Next[y+1][x] = lev.ball_array[lev.ball_pos][6];
4560 if (lev.ball_array[lev.ball_pos][7] != Xblank &&
4561 tab_blank[Cave[y+1][x+1]])
4563 Cave[y+1][x+1] = Yball_eat;
4564 Next[y+1][x+1] = lev.ball_array[lev.ball_pos][7];
4569 lev.ball_pos = (lev.ball_pos + 1) % lev.num_ball_arrays;
4571 lev.ball_pos = (lev.ball_pos + 1) & 7;
4575 /* --------------------------------------------------------------------- */
4578 if (tab_blank[Cave[y-1][x]])
4580 Cave[y-1][x] = Ygrow_ns_eat;
4581 Next[y-1][x] = Xgrow_ns;
4582 play_element_sound(x, y, SAMPLE_grow, Xgrow_ns);
4585 if (tab_blank[Cave[y+1][x]])
4587 Cave[y+1][x] = Ygrow_ns_eat;
4588 Next[y+1][x] = Xgrow_ns;
4589 play_element_sound(x, y, SAMPLE_grow, Xgrow_ns);
4595 if (tab_blank[Cave[y][x+1]])
4597 Cave[y][x+1] = Ygrow_ew_eat;
4598 Next[y][x+1] = Xgrow_ew;
4599 play_element_sound(x, y, SAMPLE_grow, Xgrow_ew);
4602 if (tab_blank[Cave[y][x-1]])
4604 Cave[y][x-1] = Ygrow_ew_eat;
4605 Next[y][x-1] = Xgrow_ew;
4606 play_element_sound(x, y, SAMPLE_grow, Xgrow_ew);
4611 /* --------------------------------------------------------------------- */
4614 if (lev.wonderwall_time && lev.wonderwall_state)
4616 Cave[y][x] = XwonderwallB;
4617 play_element_sound(x, y, SAMPLE_wonder, Xwonderwall);
4622 /* --------------------------------------------------------------------- */
4625 if (lev.required > 0)
4631 Cave[y][x] = Xexit_1;
4632 Next[y][x] = Xexit_2;
4636 Cave[y][x] = Xexit_2;
4637 Next[y][x] = Xexit_3;
4641 Cave[y][x] = Xexit_3;
4642 Next[y][x] = Xexit_1;
4645 play_element_sound(x, y, SAMPLE_exit_open, Xexit);
4650 Next[y][x] = Xexit_2;
4654 Next[y][x] = Xexit_3;
4658 Next[y][x] = Xexit_1;
4661 /* --------------------------------------------------------------------- */
4664 play_element_sound(x, y, SAMPLE_tick, Xdynamite_1);
4665 Next[y][x] = Xdynamite_2;
4669 play_element_sound(x, y, SAMPLE_tick, Xdynamite_2);
4670 Next[y][x] = Xdynamite_3;
4674 play_element_sound(x, y, SAMPLE_tick, Xdynamite_3);
4675 Next[y][x] = Xdynamite_4;
4679 play_element_sound(x, y, SAMPLE_tick, Xdynamite_4);
4680 Next[y][x] = Zdynamite;
4681 Boom[y-1][x-1] = Xblank;
4682 Boom[y-1][x] = Xblank;
4683 Boom[y-1][x+1] = Xblank;
4684 Boom[y][x-1] = Xblank;
4685 Boom[y][x] = Xblank;
4686 Boom[y][x+1] = Xblank;
4687 Boom[y+1][x-1] = Xblank;
4688 Boom[y+1][x] = Xblank;
4689 Boom[y+1][x+1] = Xblank;
4692 /* --------------------------------------------------------------------- */
4695 if (lev.wheel_cnt && x == lev.wheel_x && y == lev.wheel_y)
4696 Cave[y][x] = XwheelB;
4699 /* --------------------------------------------------------------------- */
4703 Cave[y][x] = XswitchB;
4706 /* --------------------------------------------------------------------- */
4709 switch (Cave[y+1][x])
4720 Cave[y][x] = Xsand_stonesand_quickout_1;
4721 if (Cave[y][x+1] == Xblank)
4722 Cave[y][x+1] = Yacid_splash_eB;
4723 if (Cave[y][x-1] == Xblank)
4724 Cave[y][x-1] = Yacid_splash_wB;
4725 Next[y][x] = Xsand_stonesand_quickout_2;
4726 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
4729 Cave[y][x] = Xsand_stonesand_3;
4730 if (Cave[y][x+1] == Xblank)
4731 Cave[y][x+1] = Yacid_splash_eB;
4732 if (Cave[y][x-1] == Xblank)
4733 Cave[y][x-1] = Yacid_splash_wB;
4734 Next[y][x] = Xsand_stonesand_4;
4735 play_element_sound(x, y, SAMPLE_acid, Xacid_1);
4740 case Yacid_splash_eB:
4741 case Yacid_splash_wB:
4743 Cave[y][x] = Xsand_stonesand_quickout_1;
4744 Cave[y+1][x] = Xsand_stoneout_1;
4745 Next[y][x] = Xsand_stonesand_quickout_2;
4746 Next[y+1][x] = Xsand_stoneout_2;
4749 Cave[y][x] = Xsand_stonesand_3;
4750 Cave[y+1][x] = Xsand_stoneout_1;
4751 Next[y][x] = Xsand_stonesand_4;
4752 Next[y+1][x] = Xsand_stoneout_2;
4757 Cave[y][x] = Xsand_stonesand_1;
4758 Cave[y+1][x] = Xsand_sandstone_1;
4759 Next[y][x] = Xsand_stonesand_2;
4760 Next[y+1][x] = Xsand_sandstone_2;
4767 case Xsand_stonein_1:
4768 Next[y][x] = Xsand_stonein_2;
4771 case Xsand_stonein_2:
4772 Next[y][x] = Xsand_stonein_3;
4775 case Xsand_stonein_3:
4776 Next[y][x] = Xsand_stonein_4;
4779 case Xsand_stonein_4:
4780 Next[y][x] = Xblank;
4783 case Xsand_stonesand_1:
4784 Next[y][x] = Xsand_stonesand_2;
4787 case Xsand_stonesand_2:
4788 Next[y][x] = Xsand_stonesand_3;
4791 case Xsand_stonesand_3:
4792 Next[y][x] = Xsand_stonesand_4;
4795 case Xsand_stonesand_4:
4800 case Xsand_stonesand_quickout_1:
4801 Next[y][x] = Xsand_stonesand_quickout_2;
4804 case Xsand_stonesand_quickout_2:
4809 case Xsand_stoneout_1:
4810 Next[y][x] = Xsand_stoneout_2;
4813 case Xsand_stoneout_2:
4814 Next[y][x] = Xstone_fall;
4817 case Xsand_sandstone_1:
4818 Next[y][x] = Xsand_sandstone_2;
4821 case Xsand_sandstone_2:
4822 Next[y][x] = Xsand_sandstone_3;
4825 case Xsand_sandstone_3:
4826 Next[y][x] = Xsand_sandstone_4;
4829 case Xsand_sandstone_4:
4830 Next[y][x] = Xsand_stone;
4833 /* --------------------------------------------------------------------- */
4837 Cave[y][x] = XdripperB;
4840 /* --------------------------------------------------------------------- */
4844 Cave[y][x] = Xfake_blankB;
4847 /* --------------------------------------------------------------------- */
4850 if (lev.magnify_cnt)
4851 Cave[y][x] = Xfake_grassB;
4854 /* --------------------------------------------------------------------- */
4857 if (lev.magnify_cnt)
4858 Cave[y][x] = Xdoor_1;
4862 if (lev.magnify_cnt)
4863 Cave[y][x] = Xdoor_2;
4867 if (lev.magnify_cnt)
4868 Cave[y][x] = Xdoor_3;
4872 if (lev.magnify_cnt)
4873 Cave[y][x] = Xdoor_4;
4877 if (lev.magnify_cnt)
4878 Cave[y][x] = Xdoor_5;
4882 if (lev.magnify_cnt)
4883 Cave[y][x] = Xdoor_6;
4887 if (lev.magnify_cnt)
4888 Cave[y][x] = Xdoor_7;
4892 if (lev.magnify_cnt)
4893 Cave[y][x] = Xdoor_8;
4896 /* --------------------------------------------------------------------- */
4900 Next[y][x] = Znormal;
4901 Boom[y-1][x-1] = Xemerald;
4902 Boom[y-1][x] = Xemerald;
4903 Boom[y-1][x+1] = Xemerald;
4904 Boom[y][x-1] = Xemerald;
4905 Boom[y][x] = Xdiamond;
4906 Boom[y][x+1] = Xemerald;
4907 Boom[y+1][x-1] = Xemerald;
4908 Boom[y+1][x] = Xemerald;
4909 Boom[y+1][x+1] = Xemerald;
4910 #if PLAY_ELEMENT_SOUND
4911 play_element_sound(x, y, SAMPLE_boom, element);
4919 Next[y][x] = Znormal;
4920 Boom[y-1][x-1] = Xblank;
4921 Boom[y-1][x] = Xblank;
4922 Boom[y-1][x+1] = Xblank;
4923 Boom[y][x-1] = Xblank;
4924 Boom[y][x] = Xblank;
4925 Boom[y][x+1] = Xblank;
4926 Boom[y+1][x-1] = Xblank;
4927 Boom[y+1][x] = Xblank;
4928 Boom[y+1][x+1] = Xblank;
4929 #if PLAY_ELEMENT_SOUND
4930 play_element_sound(x, y, SAMPLE_boom, element);
4935 #if PLAY_ELEMENT_SOUND
4936 play_element_sound(x, y, SAMPLE_boom, Xandroid);
4939 Next[y][x] = Xboom_2;
4940 #if !PLAY_ELEMENT_SOUND
4941 if (x != lev.exit_x && y != lev.exit_y)
4942 play_sound(x, y, SAMPLE_boom);
4944 lev.exit_x = lev.exit_y = -1;
4949 Next[y][x] = Boom[y][x];
4952 /* --------------------------------------------------------------------- */
4955 if (++y < HEIGHT - 1)
4958 cave_cache = Cave[y];
4971 if (ply[0].alive || ply[1].alive || ply[2].alive || ply[3].alive)
4972 lev.score += score; /* only add a score if someone is alive */
4979 /* triple buffering */