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';
}
void Breakout::movePaddle(int controls){
  switch(controls){
    case LEFT:
      paddle.moveLeft();
      break;
    case RIGHT:
      paddle.moveRight();
      break;
  }
  updatePaddle();

}
Esempio n. 3
0
LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message,
                                 WPARAM wParam, LPARAM lParam)
{
    /**   process system messages   **/
    switch (message)
    {
        // when window is first created
        case WM_CREATE:
            // start timer running
            // with an ID of ID_TIMER (macro)
            // 20 millisecond intervals
            // and no callback function (thus we'll get a message instead)
            SetTimer(hwnd, ID_TIMER, 10, 0);
            break;
        // message from timer "ID_TIMER"
        case WM_TIMER:
            setUpdateRegion(hwnd); // add rectangle to update region
            updateGame(hwnd);     // do the game math update all rectangles
            UpdateWindow(hwnd);  // send WM_PAINT if update region is not empty
            break;
        // whenever the mouse moves over our window
        case WM_MOUSEMOVE:
            // store mouse position
            mpoint_x = MAKEPOINTS(lParam);
            // update paddle rectangle immediately
            updatePaddle();
            break;
        // sent when window is being closed
        case WM_DESTROY:
            cleanUp();
            PostQuitMessage(0);    // send a WM_QUIT a 0 to the message queue
            break;
        // the system message to paint the update region
        case WM_PAINT:
            // paint all rectangles to update region
            refreshWindow(hwnd);
            break;
        // for messages that we don't deal with use the default window procedure
        default:
            return DefWindowProc(hwnd, message, wParam, lParam);
    }

    return 0;
}