# help me with my pong game homework

 jo vembeer · October 20, 2015 hi, I am learning c++ and need to learn how to make a pong game. Anybody who is volunteer to help me?

## Replies

 Cristiano Cappagli · October 21, 2015 Well at least you should try to begin writing some lines... i think programming is all about thinking and writing, if you don't use your brain you won't create cool things ...said by a newbie programmer jo vembeer · October 22, 2015 thank you for your advice cristiano. I know that I should try to begin writing some lines. BUT I HAVE A REALLY BAD TEACHER. so I cant learn c++ from him. I usually watch tutorials, and learned basic things like loops functions. But What I want you to help me is conspire me and show me the algorithms.especially I want to learn the logic of the game. for example , which functions do I have to write and why. Sooo, if anybody can help me that way, I am gonna be so thankful. Cristiano Cappagli · October 23, 2015 I don't think to have the knowledge to create something like that for now, but i'm studying C++ only with books or tutorials so you should keep doing like that for now  and you should do a lot of exercises and step by step you'll be able to create the right, or at least working, algorithm jo vembeer · October 26, 2015 thanks a lot jo vembeer · October 28, 2015 #include #include #include #include using namespace std;#define KEY_UP 72#define KEY_DOWN 80#define KEY_LEFT 75#define KEY_RIGHT 77void gotoxy(int x, int y)//start gotoxy{ static HANDLE h = NULL; if (!h) h = GetStdHandle(STD_OUTPUT_HANDLE); COORD c = { x, y }; SetConsoleCursorPosition(h, c);} //end function gotoxyint main() {//start main srand(time(0)); bool controlx = 0, controly = 0, controlTop, controlRaket; int a = 0; // for getch ( raket) int g = 0; // game over control int score = 0; //score control int kalan = 3; int  topx, topy, raket_1x, raket_2x, raket_1y, raket_2y, raket_3x, raket_3y, start; int kenar_sagx[30], kenar_sagy[30], kenar_solx[30], kenar_soly[30], kenar_altx[55], kenar_alty[55], kenar_ustx[55], kenar_usty[55] ; raket_1x = 45; raket_2x = 45; raket_3x = 45; raket_1y = 11; raket_2y = 12; raket_3y = 13; topx = 1; topy = 1; cout << "Yukari ve asagi ok tuslarini kullan \n\n Baslamak icin bir tusa bas "; start = _getch(); // ba?latma tu?unu al?r  while (1) {//start while system("cls"); if (_kbhit()) {//start kbhit if switch ((a = _getch())) {//start switch case KEY_UP: if (raket_1y == 0) break; raket_1y--; raket_2y--; raket_3y--; raket_1y--; raket_2y--; raket_3y--; break; case KEY_DOWN: if (raket_3y == 30) break; raket_1y++; raket_2y++; raket_3y++; raket_1y++; raket_2y++; raket_3y++; break; /*  */      case KEY_RIGHT: if (raket_1x == 54) break; raket_1x++; raket_2x++; raket_3x++; raket_1x++; raket_2x++; raket_3x++; break; case KEY_LEFT: if (raket_1x == 0) break; raket_1x--; raket_2x--; raket_3x--; raket_1x--; raket_2x--; raket_3x--; break;         default: break; }//end switch }//end kbhit if gotoxy(raket_1x, raket_1y); cout << "I"; gotoxy(raket_2x, raket_2y); cout << "I"; gotoxy(raket_3x, raket_3y); cout << "I"; gotoxy(topx, topy); cout << "O"; if (topx == 55 && g == 3) {//start game over control system("cls"); cout << "Game Over \n"; system("Pause"); exit(0); }//end game over control if ( (((raket_1x == topx == 1) && (raket_1y == topy == 1)) || ((raket_2x == topx == 1) && (raket_2y == topy == 1)) || ((raket_3x == topx == 1) && (raket_3y == topy == 1))) && controlRaket == 0) {//start raket sekme control controlx = 1; controly = 1; score++; } if (( (((raket_1x == topx == 1) && (raket_1y == topy == 1)) || ((raket_2x == topx == 1) && (raket_2y == topy == 1)) || ((raket_3x == topx == 1) && (raket_3y == topy == 1))) && controlTop == 0) && controlRaket == 0) { controlx = 1; controly = 0; score++; } if((((raket_1x == topx == 1) && (raket_1y == topy == 1)) || ((raket_2x == topx == 1) && (raket_2y == topy == 1)) || ((raket_3x == topx == 1) && (raket_3y == topy == 1))) && controlRaket == 1) {//start raket sekme control controlx = 0; controly = 1; score++; } if (((((raket_1x == topx == 1) && (raket_1y == topy == 1)) || ((raket_2x == topx == 1) && (raket_2y == topy == 1)) || ((raket_3x == topx == 1) && (raket_3y == topy == 1))) && controlTop == 0) && controlRaket == 1) { controlx = 0; controly = 0; score++; } //start topx control if (topx == 1){ controlx = 0; controlRaket = 0;//raket arkas? sekme } if (topx == 55) { controlRaket = 1;//raket arkas? sekme controlx = 1; g++; kalan--; } if (controlx == 0 ) topx++; if (controlx == 1 ) topx--; //end topx control gotoxy(30,33 ); cout << "Skorun  :  " << score ; gotoxy(30, 36); cout << "Kalan Hakkin : " << kalan; //start topy control  if (topy == 1) {  controly = 0;    controlTop = 0;        } if (topy == 30) { controly = 1;    controlTop = 1; // topun raketten a?a?? ve ya yukar? sekmesini kontrol için        } if (controly == 0 && controlTop == 0) {  topy++; } if (controly == 1) { topy--; } //end topy control  Sleep(100);//game speed }//end while system("Pause"); return 0;}//end main jo vembeer · October 28, 2015 how can I put  "|" s and "*" s at the edges? jo vembeer · October 28, 2015 How can I define and use "w", "a" , "s" , "d" keys like key_up, key_down. I want to add one more stick, and control it with "w,a,s,d".HELP ME PLEASE...
• 1

## C++

131,280 followers