Beispiel #1
0
// program code aways begins at the top of main()
int main(){
  //The next line is a function drom core.cpp
  // it sets up Allegro for graphics and keyboard
  techInit();
    
  gameSetup();  
    
  // this next while loop
  while(key[KEY_ESC] == false){
    updatePaddlePosition();
    
    moveBall();
    
    if(numberOfBricksRemaining() == 0) {
      resetBricks();
    }
    
    drawingThings();
    
    // this line draws the screenBuffer to the screen
    // by drawing to off-screen memory first, then
    // copying the new total image to screen all at once,
    // we can avoid any flickering/flashing from the player
    // seeing characters drawn sequentially.
    // The technique us called double buffering.
    updateScreen();
    
    // is the game going too fast on your awesome modern hardware?
    // Experiment with numbers 0-15 here to slow down the application:
    rest(1);
    }
  return 0;
  } END_OF_MAIN()// putting this line after the main() function
Beispiel #2
0
void gameSetup() {
  resetBricks();
  
  resetBall();
  
  // start with the ball off the bottom of the screen
  ball.y = SCREEN_H + 50;
}
void Breakout::restart(){
  paddle = {PADDLE_START, PADDLE_SIZE};
  ball = {PADDLE_START+paddle.size/2, 1, 0, 1};
  bricks = BRICKS;

  resetBricks();
  updatePaddle();
  level[7-ball.y][ball.x] = 'O';
}