|
|
1.1 ! root 1: /*----------------------------------------------------------------------*/ ! 2: /* */ ! 3: /* PACMAN for BBN BitGraphs */ ! 4: /* */ ! 5: /* File: fruit.c68 */ ! 6: /* Contents: fruit handling routines */ ! 7: /* Author: Bob Brown (rlb) */ ! 8: /* Purdue CS */ ! 9: /* Date: May, 1982 */ ! 10: /* Description: Fruits are put up for grabs at most twice per */ ! 11: /* wave (hence stalling buys nothing). They are */ ! 12: /* scheduled to go off at a random time when the */ ! 13: /* wave is started. */ ! 14: /* */ ! 15: /*----------------------------------------------------------------------*/ ! 16: ! 17: #include "style.h" ! 18: #include "pacman.h" ! 19: ! 20: /* ! 21: ** Scheduling: ! 22: ** At the beginning of a wave or round, fruitinit is called to schedule ! 23: ** the appearance of a fruit. A typical wave lasts 80-90 scheduling ! 24: ** seconds, hence the first fruit always appears sometime in the first ! 25: ** half of the wave. ! 26: ** Once "alive", the death of the fruit is scheduled. If the pacman ! 27: ** gets to the fruit first, the death routine does nothing when the ! 28: ** time elapses except schedule a new fruit. ! 29: */ ! 30: ! 31: fruitinit(reset) ! 32: bool reset; ! 33: { ! 34: int fruiton(); ! 35: Fruit.alive = FALSE; ! 36: Fruit.row = MZtoSC(FRUITROW); ! 37: Fruit.col = MZtoSC(FRUITCOL); ! 38: if ( reset ) ! 39: Fruit.thiswave = FRUITSPERWAVE; ! 40: eladd(grand(MINFRUITDELAY,MAXFRUITDELAY),fruiton,NULL,0); ! 41: } ! 42: ! 43: fruitcomp() ! 44: { ! 45: if ( Fruit.alive ) ! 46: blt40(Fruit.font,Fruit.row,Fruit.col,INVERT); ! 47: } ! 48: ! 49: /* ! 50: ** fruiton - turn on the fruit, start timer to turn it off ! 51: */ ! 52: int ! 53: fruiton() ! 54: { ! 55: int fruitoff(); ! 56: Fruit.alive = TRUE; ! 57: Fruit.thiswave--; ! 58: Fruit.value = (Wave+1)/2 * VALFRUIT; ! 59: Fruit.font = FRUITCHAR /* + max(Wave/2,MAXFRUITFONT) */ ; ! 60: fruitcomp(); ! 61: eladd(FRUITTIME,fruitoff,NULL,0); ! 62: } ! 63: int ! 64: fruitoff() ! 65: { ! 66: int fruiton(); ! 67: if ( Fruit.alive ) { ! 68: fruitcomp(); ! 69: Fruit.alive = FALSE; ! 70: } ! 71: if ( Fruit.thiswave > 0 ) ! 72: eladd(grand(MINFRUITDELAY,MAXFRUITDELAY),fruiton,NULL,0); ! 73: ! 74: } ! 75: hasfruit() ! 76: { ! 77: if ( Fruit.alive ) ! 78: return (iabs(Fruit.row-Pacman.row)<3 && iabs(Fruit.col-Pacman.col)<3 ); ! 79: return FALSE; ! 80: } ! 81: hitfruit() ! 82: { ! 83: int crow, ccol; ! 84: addscore(Fruit.value); ! 85: #ifdef V1_25 ! 86: settextop(INVERT|COMPL); ! 87: #endif ! 88: #if V1_76 | V2_0 ! 89: settextop(RASTSXD); ! 90: #endif ! 91: #ifdef BLIT ! 92: textmode = F_XOR; ! 93: #endif ! 94: crow = SCtoROW(Fruit.row)+1; ! 95: ccol = SCtoCOL(Fruit.col)-6; ! 96: mvprintf(crow, ccol, "%4d",Fruit.value); ! 97: #ifdef BLIT ! 98: sleep(12); ! 99: #else ! 100: sleep(750); ! 101: #endif ! 102: mvprintf(crow, ccol, "%4d",Fruit.value); ! 103: #ifdef V1_25 ! 104: settextop(REPLACE|COMPL); ! 105: #endif ! 106: #if V2_0 | V1_76 ! 107: settextop(RASTS); ! 108: #endif ! 109: #ifdef BLIT ! 110: textmode = F_STORE; ! 111: #endif ! 112: fruitcomp(); ! 113: Fruit.alive = FALSE; ! 114: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.