bool update(void) { bool GotEm, GotEm0, GotEm1, GotEm2, GotEm3; MoveGhost(&Ghost0); MoveGhost(&Ghost1); MoveGhost(&Ghost2); MoveGhost(&Ghost3); MovePac(&Pac); if(BlueCount) TheBlue(); GotEm0=false; GotEm1=false; GotEm2=false; GotEm3=false; if((Pac.bx==Ghost0.bx)&&(Pac.by==Ghost0.by)) { GotEm=true; GotEm0=true; } if((Pac.bx==Ghost1.bx)&&(Pac.by==Ghost1.by)) { GotEm=true; GotEm1=true; } if((Pac.bx==Ghost2.bx)&&(Pac.by==Ghost2.by)) { GotEm=true; GotEm2=true; } if((Pac.bx==Ghost3.bx)&&(Pac.by==Ghost3.by)) { GotEm=true; GotEm3=true; } if(GotEm) { if(GotEm0) { if(Ghost0.lastint==G_SCARED) DoEyes(&Ghost0); if(Ghost0.lastint==G_SMART) DoDie(); } if(GotEm1) { if(Ghost1.lastint==G_SCARED) DoEyes(&Ghost1); if(Ghost1.lastint==G_SMART) DoDie(); } if(GotEm2) { if(Ghost2.lastint==G_SCARED) DoEyes(&Ghost2); if(Ghost2.lastint==G_SMART) DoDie(); } if(GotEm3) { if(Ghost3.lastint==G_SCARED) DoEyes(&Ghost3); if(Ghost3.lastint==G_SMART) DoDie(); } } if(NumDots==0) { WAITING=false; DIED=false; } //update_window(destw); return GotEm; }
void Pac_UpdateGhosts(GAME_STATE *ptr, float telaps) { int i; for(i=0;i<MAX_GHOSTS;i++) { ptr->Ghosts[i].fEdibleDuration -= telaps; if (ptr->Ghosts[i].fEdibleDuration < 0) ptr->Ghosts[i].fEdibleDuration = 0; if (ptr->Ghosts[i].bActive == 0) DormantGhost(ptr, &ptr->Ghosts[i]); else if (ptr->Ghosts[i].iInHome) HomedGhost(ptr, &ptr->Ghosts[i]); else MoveGhost(ptr, &ptr->Ghosts[i]); } }
void MoveGhost(struct Player *g) { int nx,ny,goo=0,dx=0,dy=0; bool Check=false; g->mc++; if(g->mc==g->speed) { g->mc=0; nx=g->zx; ny=g->zy; if(g->mcnt==CountMax) Check=true; if(g->mcnt<0) Check=true; if(Check) { g->mcnt=0; g->dir=g->nextdir; } if(g->lastint==G_SMART) { switch(g->dir) { case DIR_UP: dy= -1; g->cur=SPR_GUP; break; case DIR_DOWN: dy=1; g->cur=SPR_GDOWN; break; case DIR_LEFT: dx= -1; g->cur=SPR_GLEFT; break; case DIR_RIGHT: dx=1; g->cur=SPR_GRIGHT; break; default: break; } } if(g->lastint==G_SCARED) { switch(g->dir) { case DIR_UP: dy= -1; g->cur=SPR_BUP; break; case DIR_DOWN: dy=1; g->cur=SPR_BDOWN; break; case DIR_LEFT: dx= -1; g->cur=SPR_BLEFT; break; case DIR_RIGHT: dx=1; g->cur=SPR_BRIGHT; break; default: break; } } if(g->lastint==G_EYES) { switch(g->dir) { case DIR_UP: dy= -1; g->cur=SPR_EUP; break; case DIR_DOWN: dy=1; g->cur=SPR_EDOWN; break; case DIR_LEFT: dx= -1; g->cur=SPR_ELEFT; break; case DIR_RIGHT: dx=1; g->cur=SPR_ERIGHT; break; default: break; } } dx=dx*AspectX; dy=dy*AspectY; if(Check) { DrawBoardPart(g->lx,g->ly,ReadBoard(g->lx,g->ly)); g->lx=(nx+BITMAP_X/2)/BITMAP_X; g->ly=(ny+BITMAP_Y/2)/BITMAP_Y; goo=CheckSpace(nx,ny,&dx,&dy); if(goo) { GhostChoose(g); g->mcnt=CountMax; MoveGhost(g); } } if(!goo) { if(FOOBAR_PACMOVE) DrawBoardPart(g->lx,g->ly,ReadBoard(g->lx,g->ly)); nx+=dx; ny+=dy; g->mcnt++; #ifdef CATCH_OUT if(ny<0) { ny=1; g->dir=DIR_DOWN; } if(ny>SCREEN_Y) { ny=SCREEN_Y-2; g->dir=DIR_UP; } if(nx<0) { nx=1; g->dir=DIR_RIGHT; } if(nx>SCREEN_X) { nx=SCREEN_X-2; g->dir=DIR_LEFT; } #endif //destw->draw(picts[g->cur],nx,ny); destw->copyBlock(srcs,picts[g->cur]->x,picts[g->cur]->y,nx,ny,BITMAP_X,BITMAP_Y); g->zx=nx; g->zy=ny; g->bx=(nx+BITMAP_X/2)/BITMAP_X; g->by=(ny+BITMAP_Y/2)/BITMAP_Y; if(g->lastint==G_EYES) if((g->bx==HomeX)&&(g->by==HomeY)) { g->lastint=G_SMART; DoNormal(g); } } } }