   console ascii arkanoid game
  Hi i have been getting into c++ and wanted to try to create an ascii console game. I have made this little one level arkanoid style game. Source code is also here if anyone is intrested in commenting on that. screenshot:cpp code:-----------------------#include <windows.h>#include <iostream>using namespace std;const int rows = 19;const int columns = 19;char r[rows][columns];const char ball='0';const char brick=177;const char pl=178;const char empty=' ';const char upBlock=220;const char downBlock=223;const char leftBlock=222;const char rightBlock=221;int posx=12;int posy=rows-2;int sx=1;int sy=-1;int points=0;int lives=5;int counter=0;int player[5]={10,11,12,13,14};bool gameOver=false;bool keyLeft=false;bool keyRight=false;HANDLE hStdin; DWORD cNumRead, fdwMode, fdwSaveOldMode; DWORD c = 0;INPUT_RECORD irInBuf[128]; KEY_EVENT_RECORD ker ;void setupKeyboard();bool move();bool hasBricks();void movePlayer();void createLevel();int main (int argc, char *argv[]){setupKeyboard();createLevel();while(hasBricks() && !gameOver){system("CLS");movePlayer();cout << "\n";cout << "   points: " << points  << "    lives: "<< lives << "\n";cout << "   ";for(int i=0;i<columns;i++){cout << upBlock;}cout << "\n";for(int m=0; m<rows;m++){cout << "  "<< leftBlock;for(int n=0; n<columns;n++){cout << r[m][n];}cout << rightBlock <<"\n";}cout << "   ";for(int i=0;i<columns;i++){cout << downBlock;}cout << "\n";r[posy][posx]=empty;counter++;counter%=2;if(counter==0){if(!move()){cout << "\a   lost a life \n";Sleep(3000);if(lives<1){gameOver=true;}}}r[posy][posx]=ball;r[rows-1][player[0]]=pl;r[rows-1][player[1]]=pl;r[rows-1][player[2]]=pl;r[rows-1][player[3]]=pl;r[rows-1][player[4]]=pl;Sleep(30);}system("CLS");if(!hasBricks()){cout << "\n\n   You won !!!11!";}cout << "\n\n   Your score was "<<points<<"\n\n   Thank you for playing";Sleep(10000);}void setupKeyboard(){hStdin = GetStdHandle(STD_INPUT_HANDLE); if (hStdin == INVALID_HANDLE_VALUE) cout << "GetStdHandle"; // Save the current input mode, to be restored on exit. if (! GetConsoleMode(hStdin, &fdwSaveOldMode) ) cout << "GetConsoleMode"; // Enable the window and mouse input events. fdwMode = ENABLE_WINDOW_INPUT | ENABLE_MOUSE_INPUT; if (! SetConsoleMode(hStdin, fdwMode) ) cout << "SetConsoleMode"; }void createLevel(){for(int m=0; m<rows;m++){for(int n=0; n<columns;n++){if(m<6 && n>3 && n< 16){if((m%2==0 && n%2==1) || (m%2==1 && n%2==0)){r[m][n]= brick;}}else{r[m][n]= empty;}}}}void movePlayer(){GetNumberOfConsoleInputEvents(hStdin,&c);if(c>0){ReadConsoleInput( hStdin, // input buffer handle irInBuf,// buffer to read into 128,    // size of read buffer &cNumRead);  // number of records read // Dispatch the events to the appropriate handler. for (int i = 0; i < (int)cNumRead; i++) {switch(irInBuf.EventType) { case KEY_EVENT: // keyboard input ker = irInBuf.Event.KeyEvent; if(ker.bKeyDown){int code= (int) ker.wVirtualKeyCode;if(code == 37){keyLeft=true;}if(code == 39 ){keyRight=true;}}else {int code= (int) ker.wVirtualKeyCode;if(code == 37){keyLeft=false;}if(code == 39 ){keyRight=false;}}break; case MOUSE_EVENT:break;// mouse input case WINDOW_BUFFER_SIZE_EVENT:break; // scrn buf. resizing case FOCUS_EVENT:break;  // disregard focus events case MENU_EVENT:break;   // disregard menu events default:break;  } }}if(keyLeft && player[0]>0){for (int i=0;i<5;i++){r[rows-1][player]=empty;player -= 1 ; r[rows-1][player]=pl;}}if(keyRight&& player[4]<columns-1){for (int i=4;i>=0;i--){r[rows-1][player]=empty;player += 1 ; r[rows-1][player]=pl;}}}bool move(){if( posx + sx > columns-1 || posx + sx < 0 ) {sx *= -1;}if( posy + sy < 0) {sy *= -1;}if(posy + sy > rows-1){//hit the groundlives--;sy *=-1;posx = player[2];posy = rows-2;return false;}if(r[posy+sy][posx+sx] == brick ){r[posy+sy][posx+sx]=empty;posx += sx;posy += sy;sy *= -1;points+=10;return true;}else if(posy+sy == rows-1 && posx + sx == player[0]){sx=-1;sy*=-1;}else if(posy+sy == rows-1 && (posx + sx == player[1]||posx + sx == player[2] || posx + sx == player[3])){sx=0;sy*=-1;}else if(posy+sy == rows-1 && posx + sx == player[4]){sx=1;sy*=-1;}posx += sx;posy += sy;return true;}bool hasBricks(){for(int m=0; m<rows;m++){for(int n=0; n<columns;n++){if(r[m][n]== brick){return true;}}}return false;}