void pacMan() { DEBUGpln("in pacMan"); if(powerPillEaten>0){ for(int i =32+(powerPillEaten*17); i>-17; i--){ long nowish = millis(); cls(); drawPac(i,0,-1); if(powerPillEaten>0) drawScaredGhost(i-17,0); if(powerPillEaten>1) drawScaredGhost(i-34,0); if(powerPillEaten>2) drawScaredGhost(i-51,0); if(powerPillEaten>3) drawScaredGhost(i-68,0); matrix.swapBuffers(false); while(millis()-nowish<50) bgProcess(); //Give the background process some lovin' } powerPillEaten = 0; } else{ int hasEaten = 0; int powerPill = random(0,5); int numGhosts=random(0,4); if(powerPill ==0){ if(numGhosts==0) numGhosts++; powerPillEaten = numGhosts; } for(int i=-17; i<32+(numGhosts*17); i++){ cls(); long nowish = millis(); for(int j = 0; j<6;j++){ if( j*5> i){ if(powerPill==0 && j==4){ matrix.fillCircle(j*5,8,2,matrix.Color333(7,3,0)); } else{ matrix.fillRect(j*5,8,2,2,matrix.Color333(7,3,0)); } } } if(i==19 && powerPill == 0) hasEaten=1; drawPac(i,0,1); if(hasEaten == 0){ if(numGhosts>0) drawGhost(i-17,0,matrix.Color333(3,0,3)); if(numGhosts>1) drawGhost(i-34,0,matrix.Color333(3,0,0)); if(numGhosts>2) drawGhost(i-51,0,matrix.Color333(0,3,3)); if(numGhosts>3) drawGhost(i-68,0,matrix.Color333(7,3,0)); } else{ if(numGhosts>0) drawScaredGhost(i-17-(i-19)*2,0); if(numGhosts>1) drawScaredGhost(i-34-(i-19)*2,0); if(numGhosts>2) drawScaredGhost(i-51-(i-19)*2,0); if(numGhosts>3) drawScaredGhost(i-68-(i-19)*2,0); } matrix.swapBuffers(false); while(millis()-nowish<50) bgProcess(); //Give the background process some lovin' } } }
void draw::gameDraw(const modify *level, sf::RenderWindow &mainWindow){ drawMap(mainWindow, level->loadedMap, false); drawPac(mainWindow, level->pacX, level->pacY, level->pacDirection, level->switchPac, level->pacOpen); drawGhost(mainWindow, level->ghostX, level->ghostY, level); }