void endofgame(void) { Sint4 i; bool initflag=FALSE; for (i=0;i<diggers;i++) addscore(i,0); if (playing || !drfvalid) return; if (gauntlet) { cleartopline(); outtext("TIME UP",120,0,3); for (i=0;i<50 && !escape;i++) newframe(); outtext(" ",120,0,3); } for (i=curplayer;i<curplayer+diggers;i++) { scoret=scdat[i].score; if (scoret>scorehigh[11]) { gclear(); drawscores(); strcpy(pldispbuf,"PLAYER "); if (i==0) strcat(pldispbuf,"1"); else strcat(pldispbuf,"2"); outtext(pldispbuf,108,0,2); outtext(" NEW HIGH SCORE ",64,40,2); getinitials(); shufflehigh(); savescores(); initflag=TRUE; } } if (!initflag && !gauntlet) { cleartopline(); outtext("GAME OVER",104,0,3); for (i=0;i<50 && !escape;i++) newframe(); outtext(" ",104,0,3); setretr(TRUE); } }
void testpause(void) { int i; if (pausef) { soundpause(); sett2val(40); setsoundt2(); cleartopline(); outtext(ddap, "PRESS ANY KEY",80,0,1); getkey(true); cleartopline(); drawscores(ddap); for (i=0;i<diggers;i++) addscore(ddap, i,0); drawlives(ddap); if (!synchvid) curtime=gethrt(); pausef=false; } else soundpauseoff(); }
void game(void) { int16_t t,c,i; bool flashplayer=false; if (gauntlet) { cgtime=gtime*1193181l; timeout=false; } initlives(); gamedat[0].level=startlev; if (nplayers==2) gamedat[1].level=startlev; alldead=false; ddap->gclear(); curplayer=0; initlevel(); curplayer=1; initlevel(); zeroscores(); bonusvisible=true; if (nplayers==2) flashplayer=true; curplayer=0; while (getalllives()!=0 && !escape && !timeout) { while (!alldead && !escape && !timeout) { initmbspr(); if (playing) randv=playgetrand(); else randv=getlrt(); #ifdef INTDRF fprintf(info,"%lu\n",randv); frame=0; #endif recputrand(randv); if (levnotdrawn) { levnotdrawn=false; drawscreen(ddap); if (flashplayer) { flashplayer=false; strcpy(pldispbuf,"PLAYER "); if (curplayer==0) strcat(pldispbuf,"1"); else strcat(pldispbuf,"2"); cleartopline(); for (t=0;t<15;t++) for (c=1;c<=3;c++) { outtext(ddap, pldispbuf,108,0,c); writecurscore(ddap, c); newframe(); if (escape) return; } drawscores(ddap); for (i=0;i<diggers;i++) addscore(ddap, i,0); } } else initchars(); outtext(ddap, " ",108,0,3); initscores(ddap); drawlives(ddap); music(1); flushkeybuf(); for (i=0;i<diggers;i++) readdirect(i); while (!alldead && !gamedat[curplayer].levdone && !escape && !timeout) { penalty=0; dodigger(ddap); domonsters(ddap); dobags(ddap); if (penalty>8) incmont(penalty-8); testpause(); checklevdone(); } erasediggers(); musicoff(); t=20; while ((getnmovingbags()!=0 || t!=0) && !escape && !timeout) { if (t!=0) t--; penalty=0; dobags(ddap); dodigger(ddap); domonsters(ddap); if (penalty<8) t=0; } soundstop(); for (i=0;i<diggers;i++) killfire(i); erasebonus(ddap); cleanupbags(); savefield(); erasemonsters(); recputeol(); if (playing) playskipeol(); if (escape) recputeog(); if (gamedat[curplayer].levdone) soundlevdone(); if (countem()==0 || gamedat[curplayer].levdone) { #ifdef INTDRF fprintf(info,"%i\n",frame); #endif for (i=curplayer;i<diggers+curplayer;i++) if (getlives(i)>0 && !digalive(i)) declife(i); drawlives(ddap); gamedat[curplayer].level++; if (gamedat[curplayer].level>1000) gamedat[curplayer].level=1000; initlevel(); } else if (alldead) { #ifdef INTDRF fprintf(info,"%i\n",frame); #endif for (i=curplayer;i<curplayer+diggers;i++) if (getlives(i)>0) declife(i); drawlives(ddap); } if ((alldead && getalllives()==0 && !gauntlet && !escape) || timeout) endofgame(ddap); } alldead=false; if (nplayers==2 && getlives(1-curplayer)!=0) { curplayer=1-curplayer; flashplayer=levnotdrawn=true; } } #ifdef INTDRF fprintf(info,"-1\n%lu\n%i",getscore0(),gamedat[0].level); #endif }