1 /* first part of synchro.
3 * game logic for players.
5 * large switch statement for tiles the player interacts with.
13 static void player(struct PLAYER *);
14 static int test(struct PLAYER *);
15 static void die(struct PLAYER *);
19 /* must test for death and actually kill separately */
20 char ply1_kill = test(&ply1);
21 char ply2_kill = test(&ply2);
23 if (ply1.alive && ply1_kill)
25 if (ply2.alive && ply2_kill)
29 ply1.alive = 1; /* debugging */
34 ply1.anim = SPR_still;
37 ply2.anim = SPR_still;
41 if (ply1.alive) player(&ply1);
42 if (ply2.alive) player(&ply2);
46 if (ply2.alive) player(&ply2);
47 if (ply1.alive) player(&ply1);
52 if (Cave[ply1.oldy][ply1.oldx] == Zplayer)
54 Cave[ply1.oldy][ply1.oldx] = Xblank;
55 Next[ply1.oldy][ply1.oldx] = Xblank;
58 if (Cave[ply1.y][ply1.x] == Xblank)
60 Cave[ply1.y][ply1.x] = Zplayer;
61 Next[ply1.y][ply1.x] = Zplayer;
67 if (Cave[ply2.oldy][ply2.oldx] == Zplayer)
69 Cave[ply2.oldy][ply2.oldx] = Xblank;
70 Next[ply2.oldy][ply2.oldx] = Xblank;
73 if (Cave[ply2.y][ply2.x] == Xblank)
75 Cave[ply2.y][ply2.x] = Zplayer;
76 Next[ply2.y][ply2.x] = Zplayer;
81 static int test(struct PLAYER *ply)
83 register unsigned int x = ply->x;
84 register unsigned int y = ply->y;
176 case Yacid_splash_eB:
177 case Yacid_splash_wB:
189 static void die(struct PLAYER *ply)
191 register unsigned int x = ply->x;
192 register unsigned int y = ply->y;
206 Cave[y-1][x] = Xboom_bug;
217 Cave[y-1][x] = Xboom_bomb;
231 Cave[y][x+1] = Xboom_bug;
242 Cave[y][x+1] = Xboom_bomb;
256 Cave[y+1][x] = Xboom_bug;
267 Cave[y+1][x] = Xboom_bomb;
281 Cave[y][x-1] = Xboom_bug;
292 Cave[y][x-1] = Xboom_bomb;
301 play[SAMPLE_exit] = 1;
305 play[SAMPLE_die] = 1;
309 Cave[y][x] = Xboom_1;
313 static void player(struct PLAYER *ply)
315 register unsigned int x = ply->x;
316 register unsigned int y = ply->y;
317 unsigned int anim = 0; /* initialized to make compilers happy */
320 if ((ply->joy_spin = !ply->joy_spin))
383 if (dx == 0 && dy == 0)
389 if (++ply->dynamite_cnt == 5 && ply->dynamite)
391 Cave[y][x] = Xdynamite_1;
392 play[SAMPLE_dynamite] = 1;
398 ply->dynamite_cnt = 0;
401 Random += 7; /* bit more random if we dont move */
407 ply->joy_n = ply->joy_e = ply->joy_s = ply->joy_w = 0;
408 ply->dynamite_cnt = 0; /* reset dynamite timer if we move */
410 if (ply->joy_fire == 0)
414 /* fire is released */
416 case Yacid_splash_eB:
417 case Yacid_splash_wB:
418 Cave[y][x] = Zplayer;
419 Next[y][x] = Zplayer;
420 play[SAMPLE_blank] = 1;
421 ply->anim = SPR_walk + anim;
452 ply->anim = SPR_walk + anim;
458 Cave[y][x] = (dy ? (dy < 0 ? Ygrass_nB : Ygrass_sB) :
459 (dx > 0 ? Ygrass_eB : Ygrass_wB));
460 Next[y][x] = Zplayer;
461 play[SAMPLE_dirt] = 1;
462 ply->anim = SPR_walk + anim;
468 Cave[y][x] = (dy ? (dy < 0 ? Ydirt_nB : Ydirt_sB) :
469 (dx > 0 ? Ydirt_eB : Ydirt_wB));
470 Next[y][x] = Zplayer;
471 play[SAMPLE_dirt] = 1;
472 ply->anim = SPR_walk + anim;
479 Cave[y][x] = Ydiamond_eat;
480 Next[y][x] = Zplayer;
481 play[SAMPLE_collect] = 1;
482 lev.score += lev.diamond_score;
483 lev.required = lev.required < 3 ? 0 : lev.required - 3;
484 ply->anim = SPR_walk + anim;
491 Cave[y][x] = Yemerald_eat;
492 Next[y][x] = Zplayer;
493 play[SAMPLE_collect] = 1;
494 lev.score += lev.emerald_score;
495 lev.required = lev.required < 1 ? 0 : lev.required - 1;
496 ply->anim = SPR_walk + anim;
502 Cave[y][x] = Ydynamite_eat;
503 Next[y][x] = Zplayer;
504 play[SAMPLE_collect] = 1;
505 lev.score += lev.dynamite_score;
506 ply->dynamite = ply->dynamite > 9998 ? 9999 : ply->dynamite + 1;
507 ply->anim = SPR_walk + anim;
546 Cave[y][x] = Yball_eat;
547 Next[y][x] = Zplayer;
548 play[SAMPLE_collect] = 1;
549 lev.score += lev.key_score;
550 ply->anim = SPR_walk + anim;
556 Cave[y][x] = Yball_eat;
557 Next[y][x] = Zplayer;
558 play[SAMPLE_collect] = 1;
559 lev.score += lev.lenses_score;
560 lev.lenses_cnt = lev.lenses_time;
561 ply->anim = SPR_walk + anim;
567 Cave[y][x] = Yball_eat;
568 Next[y][x] = Zplayer;
569 play[SAMPLE_collect] = 1;
570 lev.score += lev.magnify_score;
571 lev.magnify_cnt = lev.magnify_time;
572 ply->anim = SPR_walk + anim;
581 switch(Cave[y][x+dx])
591 if (Cave[y-1][x+dx+1] == Xblank)
592 Cave[y-1][x+dx+1] = Yacid_splash_eB;
593 if (Cave[y-1][x+dx-1] == Xblank)
594 Cave[y-1][x+dx-1] = Yacid_splash_wB;
595 play[SAMPLE_acid] = 1;
599 case Yacid_splash_eB:
600 case Yacid_splash_wB:
601 Cave[y][x+dx] = dx > 0 ? Ystone_e : Ystone_w;
602 Next[y][x+dx] = Xstone_pause;
606 Cave[y][x] = dx > 0 ? Ystone_eB : Ystone_wB;
607 Next[y][x] = Zplayer;
608 play[SAMPLE_roll] = 1;
612 ply->anim = SPR_push + anim;
619 switch(Cave[y][x+dx])
629 if (Cave[y-1][x+dx+1] == Xblank)
630 Cave[y-1][x+dx+1] = Yacid_splash_eB;
631 if (Cave[y-1][x+dx-1] == Xblank)
632 Cave[y-1][x+dx-1] = Yacid_splash_wB;
633 play[SAMPLE_acid] = 1;
637 case Yacid_splash_eB:
638 case Yacid_splash_wB:
639 Cave[y][x+dx] = dx > 0 ? Ybomb_e : Ybomb_w;
640 Next[y][x+dx] = Xbomb_pause;
644 Cave[y][x] = dx > 0 ? Ybomb_eB : Ybomb_wB;
645 Next[y][x] = Zplayer;
646 play[SAMPLE_roll] = 1;
650 ply->anim = SPR_push + anim;
657 switch(Cave[y][x+dx])
667 if (Cave[y-1][x+dx+1] == Xblank)
668 Cave[y-1][x+dx+1] = Yacid_splash_eB;
669 if (Cave[y-1][x+dx-1] == Xblank)
670 Cave[y-1][x+dx-1] = Yacid_splash_wB;
671 play[SAMPLE_acid] = 1;
675 case Yacid_splash_eB:
676 case Yacid_splash_wB:
677 Cave[y][x+dx] = dx > 0 ? Ynut_e : Ynut_w;
678 Next[y][x+dx] = Xnut_pause;
682 Cave[y][x] = dx > 0 ? Ynut_eB : Ynut_wB;
683 Next[y][x] = Zplayer;
684 play[SAMPLE_roll] = 1;
688 ply->anim = SPR_push + anim;
695 switch(Cave[y][x+dx])
699 Cave[y][x] = dx > 0 ? Yspring_kill_eB : Yspring_kill_wB;
700 Cave[y][x+dx] = dx > 0 ? Yspring_kill_e : Yspring_kill_w;
701 Next[y][x] = Zplayer;
702 Next[y][x+dx] = dx > 0 ? Xspring_e : Xspring_w;
703 play[SAMPLE_slurp] = 1;
704 lev.score += lev.slurp_score;
716 if (Cave[y-1][x+dx+1] == Xblank)
717 Cave[y-1][x+dx+1] = Yacid_splash_eB;
718 if (Cave[y-1][x+dx-1] == Xblank)
719 Cave[y-1][x+dx-1] = Yacid_splash_wB;
720 play[SAMPLE_acid] = 1;
724 case Yacid_splash_eB:
725 case Yacid_splash_wB:
726 Cave[y][x+dx] = dx > 0 ? Yspring_e : Yspring_w;
727 Next[y][x+dx] = dx > 0 ? Xspring_e : Xspring_w;
730 Cave[y][x] = dx > 0 ? Yspring_eB : Yspring_wB;
731 Next[y][x] = Zplayer;
732 play[SAMPLE_roll] = 1;
736 ply->anim = SPR_push + anim;
743 case Xsand_stonein_1:
744 case Xsand_stonein_2:
745 case Xsand_stonein_3:
746 case Xsand_stonein_4:
750 ply->anim = SPR_push + anim;
754 switch(Cave[y+dy][x+dx])
764 if (Cave[y+dy-1][x+dx+1] == Xblank)
765 Cave[y+dy-1][x+dx+1] = Yacid_splash_eB;
766 if (Cave[y+dy-1][x+dx-1] == Xblank)
767 Cave[y+dy-1][x+dx-1] = Yacid_splash_wB;
768 play[SAMPLE_acid] = 1;
772 case Yacid_splash_eB:
773 case Yacid_splash_wB:
774 Cave[y+dy][x+dx] = (dy ? (dy < 0 ? Yballoon_n : Yballoon_s) :
775 (dx > 0 ? Yballoon_e : Yballoon_w));
776 Next[y+dy][x+dx] = Xballoon;
779 Cave[y][x] = (dy ? (dy < 0 ? Yballoon_nB : Yballoon_sB) :
780 (dx > 0 ? Yballoon_eB : Yballoon_wB));
781 Next[y][x] = Zplayer;
782 play[SAMPLE_push] = 1;
787 ply->anim = SPR_push + anim;
799 switch(Cave[y+dy][x+dx])
809 if (Cave[y+dy-1][x+dx+1] == Xblank)
810 Cave[y+dy-1][x+dx+1] = Yacid_splash_eB;
811 if (Cave[y+dy-1][x+dx-1] == Xblank)
812 Cave[y+dy-1][x+dx-1] = Yacid_splash_wB;
813 play[SAMPLE_acid] = 1;
817 case Yacid_splash_eB:
818 case Yacid_splash_wB:
819 Cave[y+dy][x+dx] = (dy ? (dy < 0 ? Yandroid_n : Yandroid_s) :
820 (dx > 0 ? Yandroid_e : Yandroid_w));
821 Next[y+dy][x+dx] = (dy ? (dy < 0 ? Xandroid_2_n : Xandroid_2_s) :
822 (dx > 0 ? Xandroid_2_e : Xandroid_2_w));
825 Cave[y][x] = (dy ? (dy < 0 ? Yandroid_nB : Yandroid_sB) :
826 (dx > 0 ? Yandroid_eB : Yandroid_wB));
827 Next[y][x] = Zplayer;
828 play[SAMPLE_push] = 1;
833 ply->anim = SPR_push + anim;
838 if (ply->keys & 0x01)
845 if (ply->keys & 0x02)
852 if (ply->keys & 0x04)
859 if (ply->keys & 0x08)
866 if (ply->keys & 0x10)
873 if (ply->keys & 0x20)
880 if (ply->keys & 0x40)
887 if (ply->keys & 0x80)
893 if (!tab_blank[Cave[y+dy][x+dx]])
896 Cave[y+dy][x+dx] = Zplayer;
897 Next[y+dy][x+dx] = Zplayer;
898 play[SAMPLE_door] = 1;
899 ply->anim = SPR_walk + anim;
905 play[SAMPLE_press] = 1;
906 lev.wheel_cnt = lev.wheel_time;
912 lev.wind_direction = 0;
916 lev.wind_direction = 1;
920 lev.wind_direction = 2;
924 lev.wind_direction = 3;
928 lev.wind_direction = dy ? (dy < 0 ? 0 : 2) : (dx > 0 ? 1 : 3);
932 play[SAMPLE_press] = 1;
933 lev.wind_cnt = lev.wind_time;
937 play[SAMPLE_press] = 1;
942 play[SAMPLE_press] = 1;
943 lev.ball_cnt = lev.ball_time;
944 lev.ball_state = !lev.ball_state;
950 play[SAMPLE_blank] = 1;
951 ply->anim = SPR_walk + anim;
959 play[SAMPLE_exit] = 1;
961 lev.score += lev.time * lev.exit_score / 100;
962 ply->anim = SPR_walk + anim;
972 /* fire is pressed */
976 Cave[y][x] = Yball_eat;
978 play[SAMPLE_dirt] = 1;
979 ply->anim = SPR_spray + anim;
984 Cave[y][x] = Ydiamond_eat;
986 play[SAMPLE_collect] = 1;
987 lev.score += lev.diamond_score;
988 lev.required = lev.required < 3 ? 0 : lev.required - 3;
989 ply->anim = SPR_walk + anim;
994 Cave[y][x] = Yemerald_eat;
996 play[SAMPLE_collect] = 1;
997 lev.score += lev.emerald_score;
998 lev.required = lev.required < 1 ? 0 : lev.required - 1;
999 ply->anim = SPR_walk + anim;
1003 Cave[y][x] = Ydynamite_eat;
1004 Next[y][x] = Xblank;
1005 play[SAMPLE_collect] = 1;
1006 lev.score += lev.dynamite_score;
1007 ply->dynamite = ply->dynamite > 9998 ? 9999 : ply->dynamite + 1;
1008 ply->anim = SPR_walk + anim;
1044 Cave[y][x] = Yball_eat;
1045 Next[y][x] = Xblank;
1046 play[SAMPLE_collect] = 1;
1047 lev.score += lev.key_score;
1048 ply->anim = SPR_walk + anim;
1052 Cave[y][x] = Yball_eat;
1053 Next[y][x] = Xblank;
1054 play[SAMPLE_collect] = 1;
1055 lev.score += lev.lenses_score;
1056 lev.lenses_cnt = lev.lenses_time;
1057 ply->anim = SPR_walk + anim;
1061 Cave[y][x] = Yball_eat;
1062 Next[y][x] = Xblank;
1063 play[SAMPLE_collect] = 1;
1064 lev.score += lev.magnify_score;
1065 lev.magnify_cnt = lev.magnify_time;
1066 ply->anim = SPR_walk + anim;