Suche senden
Hochladen
Ping pong game
•
Als DOCX, PDF herunterladen
•
2 gefällt mir
•
701 views
A
Amit Kumar
Folgen
this is a simple ping-pong game made in C++ on Dev c++ IDE .
Weniger lesen
Mehr lesen
Software
Melden
Teilen
Melden
Teilen
1 von 15
Jetzt herunterladen
Empfohlen
A simple snake game project
A simple snake game project
Amit Kumar
Hangman Game Programming in C (coding)
Hangman Game Programming in C (coding)
hasan0812
New
New
Bilal Muhammad
Funcion matematica
Funcion matematica
Jhonny Wladimir Peñaloza Cabello
Include
Include
Munkherdene Batsaikhan
[SI] Ada Lovelace Day 2014 - Tampon Run
[SI] Ada Lovelace Day 2014 - Tampon Run
Maja Kraljič
Reverse Engineering: C++ "for" operator
Reverse Engineering: C++ "for" operator
erithion
JavaScript Gotchas
JavaScript Gotchas
Robert MacLean
Empfohlen
A simple snake game project
A simple snake game project
Amit Kumar
Hangman Game Programming in C (coding)
Hangman Game Programming in C (coding)
hasan0812
New
New
Bilal Muhammad
Funcion matematica
Funcion matematica
Jhonny Wladimir Peñaloza Cabello
Include
Include
Munkherdene Batsaikhan
[SI] Ada Lovelace Day 2014 - Tampon Run
[SI] Ada Lovelace Day 2014 - Tampon Run
Maja Kraljič
Reverse Engineering: C++ "for" operator
Reverse Engineering: C++ "for" operator
erithion
JavaScript Gotchas
JavaScript Gotchas
Robert MacLean
[EN] Ada Lovelace Day 2014 - Tampon run
[EN] Ada Lovelace Day 2014 - Tampon run
Maja Kraljič
An Introduction to Tinkerpop
An Introduction to Tinkerpop
Takahiro Inoue
05 1 수식과 연산자
05 1 수식과 연산자
Changwon National University
Ejercicios de programacion
Ejercicios de programacion
Jeff Tu Pechito
Bai Giang 11
Bai Giang 11
nbb3i
Programming Lisp Clojure - 2장 : 클로저 둘러보기
Programming Lisp Clojure - 2장 : 클로저 둘러보기
JangHyuk You
From Zero to Iterators: Building and Extending the Iterator Hierarchy in a Mo...
From Zero to Iterators: Building and Extending the Iterator Hierarchy in a Mo...
Patrick Niedzielski
Improving the java type system
Improving the java type system
João Loff
Communities - Perl edition (RioJS)
Communities - Perl edition (RioJS)
garux
PHP in 2018 - Q4 - AFUP Limoges
PHP in 2018 - Q4 - AFUP Limoges
✅ William Pinaud
Drawing on canvas
Drawing on canvas
suitzero
プログラム実行の話と OSとメモリの挙動の話
プログラム実行の話と OSとメモリの挙動の話
tatsunori ishikawa
Vcs9
Vcs9
Malikireddy Bramhananda Reddy
Infinity
Infinity
S.M.Zahidul Islam sumon
Arduino coding class
Arduino coding class
Jonah Marrs
20110424 action scriptを使わないflash勉強会
20110424 action scriptを使わないflash勉強会
Hiroki Mizuno
Javascript: The Important Bits
Javascript: The Important Bits
Zumba Fitness - Technology Team
Потоки в перле изнутри
Потоки в перле изнутри
Ilya Zelenchuk
Server
Server
marveenstein
Cg my own programs
Cg my own programs
Amit Kapoor
C Language Lecture 17
C Language Lecture 17
Shahzaib Ajmal
Blocks+gcd入門
Blocks+gcd入門
領一 和泉田
Weitere ähnliche Inhalte
Was ist angesagt?
[EN] Ada Lovelace Day 2014 - Tampon run
[EN] Ada Lovelace Day 2014 - Tampon run
Maja Kraljič
An Introduction to Tinkerpop
An Introduction to Tinkerpop
Takahiro Inoue
05 1 수식과 연산자
05 1 수식과 연산자
Changwon National University
Ejercicios de programacion
Ejercicios de programacion
Jeff Tu Pechito
Bai Giang 11
Bai Giang 11
nbb3i
Programming Lisp Clojure - 2장 : 클로저 둘러보기
Programming Lisp Clojure - 2장 : 클로저 둘러보기
JangHyuk You
From Zero to Iterators: Building and Extending the Iterator Hierarchy in a Mo...
From Zero to Iterators: Building and Extending the Iterator Hierarchy in a Mo...
Patrick Niedzielski
Improving the java type system
Improving the java type system
João Loff
Communities - Perl edition (RioJS)
Communities - Perl edition (RioJS)
garux
PHP in 2018 - Q4 - AFUP Limoges
PHP in 2018 - Q4 - AFUP Limoges
✅ William Pinaud
Drawing on canvas
Drawing on canvas
suitzero
プログラム実行の話と OSとメモリの挙動の話
プログラム実行の話と OSとメモリの挙動の話
tatsunori ishikawa
Vcs9
Vcs9
Malikireddy Bramhananda Reddy
Infinity
Infinity
S.M.Zahidul Islam sumon
Arduino coding class
Arduino coding class
Jonah Marrs
20110424 action scriptを使わないflash勉強会
20110424 action scriptを使わないflash勉強会
Hiroki Mizuno
Javascript: The Important Bits
Javascript: The Important Bits
Zumba Fitness - Technology Team
Потоки в перле изнутри
Потоки в перле изнутри
Ilya Zelenchuk
Server
Server
marveenstein
Was ist angesagt?
(19)
[EN] Ada Lovelace Day 2014 - Tampon run
[EN] Ada Lovelace Day 2014 - Tampon run
An Introduction to Tinkerpop
An Introduction to Tinkerpop
05 1 수식과 연산자
05 1 수식과 연산자
Ejercicios de programacion
Ejercicios de programacion
Bai Giang 11
Bai Giang 11
Programming Lisp Clojure - 2장 : 클로저 둘러보기
Programming Lisp Clojure - 2장 : 클로저 둘러보기
From Zero to Iterators: Building and Extending the Iterator Hierarchy in a Mo...
From Zero to Iterators: Building and Extending the Iterator Hierarchy in a Mo...
Improving the java type system
Improving the java type system
Communities - Perl edition (RioJS)
Communities - Perl edition (RioJS)
PHP in 2018 - Q4 - AFUP Limoges
PHP in 2018 - Q4 - AFUP Limoges
Drawing on canvas
Drawing on canvas
プログラム実行の話と OSとメモリの挙動の話
プログラム実行の話と OSとメモリの挙動の話
Vcs9
Vcs9
Infinity
Infinity
Arduino coding class
Arduino coding class
20110424 action scriptを使わないflash勉強会
20110424 action scriptを使わないflash勉強会
Javascript: The Important Bits
Javascript: The Important Bits
Потоки в перле изнутри
Потоки в перле изнутри
Server
Server
Ähnlich wie Ping pong game
Cg my own programs
Cg my own programs
Amit Kapoor
C Language Lecture 17
C Language Lecture 17
Shahzaib Ajmal
Blocks+gcd入門
Blocks+gcd入門
領一 和泉田
Computer Graphics Lab File C Programs
Computer Graphics Lab File C Programs
Kandarp Tiwari
week-23x
week-23x
KITE www.kitecolleges.com
Lab Question
Lab Question
Export Promotion Bureau
Assignment on Numerical Method C Code
Assignment on Numerical Method C Code
Syed Ahmed Zaki
Tuga IT 2017 - What's new in C# 7
Tuga IT 2017 - What's new in C# 7
Paulo Morgado
C Prog - Pointers
C Prog - Pointers
vinay arora
โปรแกรมย่อยและฟังชันก์มาตรฐาน
โปรแกรมย่อยและฟังชันก์มาตรฐาน
knang
Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02
Er Ritu Aggarwal
C questions
C questions
mohamed sikander
The Noland national flag is a square showing the following pattern. .docx
The Noland national flag is a square showing the following pattern. .docx
Komlin1
Cquestions
Cquestions
mohamed sikander
TRICK
TRICK
Jimmy Ngu
Im trying again -Okay, Im in need of some help - this is the c.pdf
Im trying again -Okay, Im in need of some help - this is the c.pdf
eyeonsecuritysystems
Computer graphics lab manual
Computer graphics lab manual
Uma mohan
C basics
C basics
MSc CST
Double linked list
Double linked list
Sayantan Sur
Cpds lab
Cpds lab
praveennallavelly08
Ähnlich wie Ping pong game
(20)
Cg my own programs
Cg my own programs
C Language Lecture 17
C Language Lecture 17
Blocks+gcd入門
Blocks+gcd入門
Computer Graphics Lab File C Programs
Computer Graphics Lab File C Programs
week-23x
week-23x
Lab Question
Lab Question
Assignment on Numerical Method C Code
Assignment on Numerical Method C Code
Tuga IT 2017 - What's new in C# 7
Tuga IT 2017 - What's new in C# 7
C Prog - Pointers
C Prog - Pointers
โปรแกรมย่อยและฟังชันก์มาตรฐาน
โปรแกรมย่อยและฟังชันก์มาตรฐาน
Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02
C questions
C questions
The Noland national flag is a square showing the following pattern. .docx
The Noland national flag is a square showing the following pattern. .docx
Cquestions
Cquestions
TRICK
TRICK
Im trying again -Okay, Im in need of some help - this is the c.pdf
Im trying again -Okay, Im in need of some help - this is the c.pdf
Computer graphics lab manual
Computer graphics lab manual
C basics
C basics
Double linked list
Double linked list
Cpds lab
Cpds lab
Kürzlich hochgeladen
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
stazi3110
Professional Resume Template for Software Developers
Professional Resume Template for Software Developers
Vinodh Ram
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
Evangelist Apps https://twitter.com/EvangelistSW/
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
Andolasoft Inc
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Christina Lin
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
bodapatigopi8531
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
soniya singh
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
anilsa9823
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
joe51371421
Software Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
Arshad QA
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
kaushalgiri8080
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
Jhone kinadey
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
kalichargn70th171
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Call Girls In Delhi Whatsup 9873940964 Enjoy Unlimited Pleasure
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
Arshad QA
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
SolGuruz
DNT_Corporate presentation know about us
DNT_Corporate presentation know about us
Dynamic Netsoft
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
BradBedford3
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
harshavardhanraghave
Kürzlich hochgeladen
(20)
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Professional Resume Template for Software Developers
Professional Resume Template for Software Developers
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
Software Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
DNT_Corporate presentation know about us
DNT_Corporate presentation know about us
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Ping pong game
1.
#include<iostream> usingnamespace std; #include <stdlib.h> #include<time.h> #include<conio.h> #include<windows.h> #include<iomanip> enumDir{ stop=0,Left,upleft,downleft,Right,upright,downright }; classball { private
: intx,y; intorig_x,orig_y; Dir direction; public: ball(intposx,intposy) { orig_x=posx ; orig_y=posy; x=posx ; y=posy;
2.
direction=stop; } voidreset() { x=orig_x ; y=orig_y; direction=stop; } voidchange_direction(Dird) { direction=d; } voidrandom_direction() { direction=(Dir)((rand()%6)+1) ; } intget_x() { returnx
; } intget_y() { returny ; } Dir get_direction()
3.
{ returndirection; } voidmove() { switch(direction) { case stop: break; case
Left: x-- ; break; case Right: x++ ; break; case upleft: x--,y-- ;break; case downleft: x--,y++; break; case upright: x++,y-- ; break; case downright:x++,y++ ; break; default: break; } } } ; classpaddle { private : int x,y; intorig_x,orig_y; public:
4.
paddle(intposx,intposy) { orig_x=posx ; orig_y=posy ; x=posx
; y=posy; } voidreset() { x=orig_x ; y=orig_y; } intget_x() { returnx ; } intget_y() { returny ; } voidmove_up() { y-- ; } voidmove_down()
5.
{ y++ ; } } ; classgame_maneger { private
: intwidth,height; intscore1,score2; char up1,down1,up2,down2; bool quit; ball *Ball ; paddle *player1; paddle *player2; public: game_maneger(intw,inth) { srand(time(NULL)) ; quit=false ; up1='a' ; down1='z' ; up2='k' ; down2='m' ; score1=score2=0 ;
6.
width=w ; height=h; Ball=new ball(w/2,h/2)
; player1=new paddle(1,h/2-3) ; player2=new paddle(w-3,h/2-3) ; } ~game_maneger() { delete Ball,player1,player2; } voidscore_up(paddle*player) { if(player==player1) score1++ ; else if(player==player2) score2++ ; Ball->reset() ; player1->reset() ; player->reset() ; } voiddraw() { inti,j; intballx,bally;
7.
intplayer1x,player1y,player2x,player2y; ballx=Ball->get_x() ; bally=Ball->get_y() ; player1x=player1->get_x()
; player1y=player1->get_y() ; player2x=player2->get_x() ; player2y=player2->get_y() ; system("cls"); for(i=0;i<width+1;i++) cout<<"xB2" ; cout<<endl ; for(i=0;i<height;i++) { for(j=0;j<width;j++) { if(j==0||j==width-1) cout<<"xB2" ; if(ballx==j&&bally==i) cout<<"O" ; else if(player1x==j&&player1y==i)
8.
cout<<"xDB"; else if(player2x==j&&player2y==i) cout<<"xDB"; else if(player1x==j&&player1y+1==i) cout<<"xDB"; else
if(player1x==j&&player1y+2==i) cout<<"xDB"; else if(player1x==j&&player1y+3==i) cout<<"xDB"; else if(player2x==j&&player2y+1==i) cout<<"xDB"; else if(player2x==j&&player2y+2==i) cout<<"xDB"; else if(player2x==j&&player2y+3==i) cout<<"xDB"; else cout<<" " ; } cout<<endl ; } for(i=0;i<width+1;i++)
9.
cout<<"xB2" ; cout<<endl ; cout<<"n
Player1st score = "<<score1 ; cout<<"n Player2ndscore = "<<score2 ; } voidinput() { Ball->move() ; inti,j; intballx,bally; intplayer1x,player1y,player2x,player2y; char current ; ballx=Ball->get_x() ; bally=Ball->get_y() ; player1x=player1->get_x() ; player1y=player1->get_y() ; player2x=player2->get_x() ; player2y=player2->get_y() ; if(kbhit()) {
10.
current=getch() ; if(current==up1) { if(player1y>0) player1->move_up() ; } if(current==up2) { if(player2y>0) player2->move_up()
; } if(current==down1) { if(player1y+4<height) player1->move_down() ; } if(current==down2) { if(player2y+4<height) player2->move_down() ; } if(Ball->get_direction()==stop) Ball->random_direction() ;
11.
if(current=='q') quit=true ; } } voidlogic() { inti,j; intballx,bally; intplayer1x,player1y,player2x,player2y; char current
; ballx=Ball->get_x() ; bally=Ball->get_y() ; player1x=player1->get_x() ; player1y=player1->get_y() ; player2x=player2->get_x() ; player2y=player2->get_y() ; for(i=0;i<4;i++) { if(ballx==player1x+1) if(bally==player1y+i) Ball->change_direction((Dir)((rand()%3)+4)) ;
12.
} for(i=0;i<4;i++) { if(ballx==player2x-2) if(bally==player2y+i) Ball->change_direction((Dir)((rand()%3)+1)) ; } if(bally==height-1) Ball->change_direction(Ball->get_direction()==downright?upright:upleft) ; if(bally==0) Ball->change_direction(Ball->get_direction()==upright?downright:downleft)
; if(ballx==width-2) score_up(player1) ; if(ballx==0) score_up(player2) ; } voidrun() { while(!quit)
13.
{ draw() ; input() ; logic()
; Sleep(80) ; } } } ; intmain() { cout<<"nnn...................KEYBOARDINSTRUCTIONS................................"; cout<<endl<<endl<<setw(30)<<"KEYBOARDKEYS"<<setw(30)<<"OPERATION"; cout<<"n-----------------------------------------------------------------------"; cout<<endl<<setw(25)<<"a"<<setw(40)<<"leftpadduppwardmovement"; cout<<endl<<setw(25)<<"z"<<setw(40)<<"leftpadddownwardmovement"; cout<<endl<<setw(25)<<"k"<<setw(40)<<"rightpadduppwardmovement"; cout<<endl<<setw(25)<<"m"<<setw(40)<<"rightpadddownwardmovement"; cout<<endl<<setw(25)<<"x"<<setw(40)<<"quite/exitgame"; cout<<"n-----------------------------------------------------------------------"; cout<<"nnn # all keysshouldbe inlowercase onlyn ( as game workson ASCIIvalues)"; cout<<"nnpressENTER to start the game " ; getch() ; system("cls");
14.
game_manegerc(40,20) ; c.run() ; return0
; }
Jetzt herunterladen