// Draw all four bunkers on the screen. void drawBunkers() { int i = 0; for (i = 0; i < BUNKER_COUNT; i++){ drawBunker(i); } }
//updates the origin location by the predefined amount void moveAliens(){ //call move aliens sound //moveInvadersSound(); activeInvaderMoveSound(); //what to do if aliens are on the left side of the screen if(alienDirection == LEFT && (alienOriginX - PIXELS_PER_MOVE < -1*(ALIEN_WIDTH * firstColAliveAliens))){ alienOriginY += PIXELS_PER_MOVE; undrawAliens(DOWN); alienDirection = RIGHT; } //aliens are on the right side of the screen else if(alienDirection == RIGHT && (alienOriginX + alienFarRightOffset + PIXELS_PER_MOVE > (SCREEN_X_PIXELS + (ALIENS_PER_ROW - lastColAliveAliens - 1)*ALIEN_WIDTH))){ alienOriginY += PIXELS_PER_MOVE; undrawAliens(DOWN); alienDirection = LEFT; } //aliens are free to move as normal else{ alienOriginX += alienDirection == RIGHT ? PIXELS_PER_MOVE : PIXELS_PER_MOVE * -1; undrawAliens(alienDirection); } int in; for(in = 0; in < NUM_BUNKERS; in++){ drawBunker(in); } drawAliens(); firstColAliveAliens = findFirstAliveColumn(); lastColAliveAliens = findLastAliveColumn(); lastRowAliveAliens = findLastAliveRow(); int j; for(j = 0; j < NUM_ALIEN_BULLETS; j++){ drawAlienBullet(j); } //drawAliens(); if((alienOriginY + (lastRowAliveAliens+1) * ALIEN_HEIGHT) >= (BUNKER_INITIAL_Y + 3*BUNKER_HEIGHT)){ runGameOver(0); } }
void damageBunker(int bunkerNum, int bunkerBlock){ switch(bunkerBlock){ case 0: if(bunkerArray[bunkerNum].damageStateTopLeft < 5){ bunkerArray[bunkerNum].damageStateTopLeft=bunkerArray[bunkerNum].damageStateTopLeft + 1; } else{ bunkerArray[bunkerNum].damageStateTopLeft = 5; } break; case 1: if(bunkerArray[bunkerNum].damageStateBlockTopLeft < 5){ bunkerArray[bunkerNum].damageStateBlockTopLeft=bunkerArray[bunkerNum].damageStateBlockTopLeft + 1; } else{ bunkerArray[bunkerNum].damageStateBlockTopLeft = 5; } break; case 2: if(bunkerArray[bunkerNum].damageStateBlockTopRight < 5){ bunkerArray[bunkerNum].damageStateBlockTopRight=bunkerArray[bunkerNum].damageStateBlockTopRight + 1; } else{ bunkerArray[bunkerNum].damageStateBlockTopRight = 5; } break; case 3: if(bunkerArray[bunkerNum].damageStateTopRight < 5){ bunkerArray[bunkerNum].damageStateTopRight=bunkerArray[bunkerNum].damageStateTopRight + 1; } else{ bunkerArray[bunkerNum].damageStateTopRight = 5; } break; case 4: if(bunkerArray[bunkerNum].damageStateBlockLeftSide < 5){ bunkerArray[bunkerNum].damageStateBlockLeftSide=bunkerArray[bunkerNum].damageStateBlockLeftSide + 1; } else{ bunkerArray[bunkerNum].damageStateBlockLeftSide = 5; } break; case 5: if(bunkerArray[bunkerNum].damageStateBottomLeft < 5){ bunkerArray[bunkerNum].damageStateBottomLeft=bunkerArray[bunkerNum].damageStateBottomLeft + 1; } else{ bunkerArray[bunkerNum].damageStateBottomLeft = 5; } break; case 6: if(bunkerArray[bunkerNum].damageStateBottomRight < 5){ bunkerArray[bunkerNum].damageStateBottomRight=bunkerArray[bunkerNum].damageStateBottomRight + 1; } else{ bunkerArray[bunkerNum].damageStateBottomRight = 5; } break; case 7: if(bunkerArray[bunkerNum].damageStateBlockRightSide < 5){ bunkerArray[bunkerNum].damageStateBlockRightSide=bunkerArray[bunkerNum].damageStateBlockRightSide + 1; } else{ bunkerArray[bunkerNum].damageStateBlockRightSide = 5; } break; case 8: if(bunkerArray[bunkerNum].damageStateBlockBottomLeft < 5){ bunkerArray[bunkerNum].damageStateBlockBottomLeft=bunkerArray[bunkerNum].damageStateBlockBottomLeft + 1; } else{ bunkerArray[bunkerNum].damageStateBlockBottomLeft = 5; } break; case 9: if(bunkerArray[bunkerNum].damageStateBlockBottomRight < 5){ bunkerArray[bunkerNum].damageStateBlockBottomRight=bunkerArray[bunkerNum].damageStateBlockBottomRight + 1; } else{ bunkerArray[bunkerNum].damageStateBlockBottomRight = 5; } break; default: break; } drawBunker(bunkerNum); }