Pages
Home
skip to main
|
skip to sidebar
Computer Programming
Code of Game in C++
Saturday, 4 May 2013
Click Here To Download Compiled Game
#include
#include
#include "conio.h" #include
using namespace::std; HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE); COORD CursorPosition; void gotoXY(int x, int y) { CursorPosition.X = x; // Locates column CursorPosition.Y = y; // Locates Row SetConsoleCursorPosition(console,CursorPosition); // Sets position for next thing to be printed } void drawgamebody() { int i, j=6, k; gotoXY(18, 1); cout<<"****************************************"; gotoXY(18, 2); cout<<"*************W E L C O M E**************"; gotoXY(18, 3); cout<<"****************************************"<
>pw; if(pw!=1 && pw!=2) { cout<<"Enter a valid number 1 or 2."; goto ask_again; } gotoXY(0, 19); cout<<" \n \n \n "; gotoXY(0, 19); cout<<"Enter name of first player: "; gets(n1); if(blunder>0) { gets(n1); } gotoXY(0, 20); if(pw==2) { cout<<"Enter name of second player: "; gets(n2); } else { cout<<"Enter name of second player: Computer"; strcpy(n2, "Computer"); } next: if(tie==6) { goto move; } i++; play=i%2; if(play==1) { save_key=1; sign=sou1; gotoXY(0, 21); cout<<" "; gotoXY(0, 21); cout<
>loc; tie++; if(store_loc[loc]==1 || store_loc[loc]==2) { gotoXY(0, 22); cout<<"Enter Valid input."<
>loc; } else { srand(time(0)); loc=1+rand() % 9; } tie++; if(store_loc[loc]==1 || store_loc[loc]==2) { gotoXY(0, 22); cout<<"Enter Valid input."<
>loc; if(store_loc[loc] != 1 && store_loc[loc] != 2) { cout<<"Nothing to move."; i--; goto move; } else if(store_loc[loc]!=1) { cout<<"You cannot move this position."; i--; goto move; } else { gotoXY(0, 22); cout<<" "; } gotoXY(0, 21); cout<
>loc1; } //play 2nd player if(play==0) { save_key=2; sign=sou2; gotoXY(0, 21); cout<<" "; if(pw==2) { gotoXY(0, 21); cout<
>loc; if(store_loc[loc] != 1 && store_loc[loc] != 2) { cout<<"Nothing to move."; i--; goto move; } else if(store_loc[loc]!=2) { cout<<"You cannot move this."; i--; goto move; } else { gotoXY(0, 22); cout<<" "; } gotoXY(0, 21); cout<
>loc1; } //computer's condition. else { gotoXY(0, 21); cout<
>ask; if(ask=='y' || ask=='Y') { // clear name and location. gotoXY(27, 19); cout<<" "; gotoXY(27, 20); cout<<" "; gotoXY(0, 21); cout<<" "; gotoXY(0, 22); cout<<" \n "; goto play_again; //start game again. } else { goto end; } } if((store_loc[4]==1 && store_loc[5]==1 && store_loc[6]==1) || (store_loc[4]==2 && store_loc[5]==2 && store_loc[6]==2)) { gotoXY(0, 22); if(store_loc[4]==1) {strcpy(winer, n1);} else{strcpy(winer, n2);} cout<<"Congrates "<
>ask; if(ask=='y' || ask=='Y') { // clear name and location. gotoXY(27, 19); cout<<" "; gotoXY(27, 20); cout<<" "; gotoXY(0, 21); cout<<" "; gotoXY(0, 22); cout<<" \n "; goto play_again; //start game again. } else { goto end; } } if((store_loc[7]==1 && store_loc[8]==1 && store_loc[9]==1) || (store_loc[7]==2 && store_loc[8]==2 && store_loc[9]==2)) { gotoXY(0, 22); if(store_loc[7]==1) {strcpy(winer, n1);} else{strcpy(winer, n2);} cout<<"Congrates "<
>ask; if(ask=='y' || ask=='Y') { // clear name and location. gotoXY(27, 19); cout<<" "; gotoXY(27, 20); cout<<" "; gotoXY(0, 21); cout<<" "; gotoXY(0, 22); cout<<" \n "; goto play_again; //start game again. } else { goto end; } } if((store_loc[1]==1 && store_loc[4]==1 && store_loc[7]==1) || (store_loc[1]==2 && store_loc[4]==2 && store_loc[7]==2)) { gotoXY(0, 22); if(store_loc[1]==1) {strcpy(winer, n1);} else{strcpy(winer, n2);} cout<<"Congrates "<
>ask; if(ask=='y' || ask=='Y') { // clear name and location. gotoXY(27, 19); cout<<" "; gotoXY(27, 20); cout<<" "; gotoXY(0, 21); cout<<" "; gotoXY(0, 22); cout<<" \n "; goto play_again; //start game again. } else { goto end; } } if((store_loc[2]==1 && store_loc[5]==1 && store_loc[8]==1) || (store_loc[2]==2 && store_loc[5]==2 && store_loc[8]==2)) { gotoXY(0, 22); if(store_loc[2]==1) {strcpy(winer, n1);} else{strcpy(winer, n2);} cout<<"Congrates "<
>ask; if(ask=='y' || ask=='Y') { // clear name and location. gotoXY(27, 19); cout<<" "; gotoXY(27, 20); cout<<" "; gotoXY(0, 21); cout<<" "; gotoXY(0, 22); cout<<" \n "; goto play_again; //start game again. } else { goto end; } } if((store_loc[3]==1 && store_loc[6]==1 && store_loc[9]==1) || (store_loc[3]==2 && store_loc[6]==2 && store_loc[9]==2)) { gotoXY(0, 22); if(store_loc[3]==1) {strcpy(winer, n1);} else{strcpy(winer, n2);} cout<<"Congrates "<
>ask; if(ask=='y' || ask=='Y') { // clear name and location. gotoXY(27, 19); cout<<" "; gotoXY(27, 20); cout<<" "; gotoXY(0, 21); cout<<" "; gotoXY(0, 22); cout<<" \n "; goto play_again; //start game again. } else { goto end; } } if((store_loc[1]==1 && store_loc[5]==1 && store_loc[9]==1) || (store_loc[1]==2 && store_loc[5]==2 && store_loc[9]==2)) { gotoXY(0, 22); if(store_loc[1]==1) {strcpy(winer, n1);} else{strcpy(winer, n2);} cout<<"Congrates "<
>ask; if(ask=='y' || ask=='Y') { // clear name and location. gotoXY(27, 19); cout<<" "; gotoXY(27, 20); cout<<" "; gotoXY(0, 21); cout<<" "; gotoXY(0, 22); cout<<" \n "; goto play_again; //start game again. } else { goto end; } } if((store_loc[3]==1 && store_loc[5]==1 && store_loc[7]==1) || (store_loc[3]==2 && store_loc[5]==2 && store_loc[7]==2)) { gotoXY(0, 22); if(store_loc[3]==1) {strcpy(winer, n1);} else{strcpy(winer, n2);} cout<<"Congrates "<
>ask; if(ask=='y' || ask=='Y') { // clear name and location. gotoXY(27, 19); cout<<" "; gotoXY(27, 20); cout<<" "; gotoXY(0, 21); cout<<" "; gotoXY(0, 22); cout<<" \n "; goto play_again; //start game again. } else { goto end; } } else { goto next; } end: cout<<"Game Over"; }
Newer Post
Older Post
Home
Categories
Advanced Programs
Array
Assembly Language
C Language
C Language Tutorials
C++
C++ Language
C++ Tutorials
Dev
File Handling
for loop
Functions
Graphics
If-Else-If (Conditions)
Interview Questions
Link List
Loops (For While Do-While)
Matrix
Mobile number details
OOP
pointer
Programs for Beginners
Recursion
Simple Programes (Beginers)
Strings
Structure
Switch
Track phone number
whose number is this calling me
whose number lookup
Archives
►
2018
(1)
►
February
(1)
►
2014
(25)
►
July
(10)
►
June
(2)
►
May
(2)
►
March
(4)
►
February
(6)
►
January
(1)
▼
2013
(116)
►
July
(16)
►
June
(8)
▼
May
(27)
Write a program to create single link list.
Write a program to multiply two matrix and show re...
Write a program in c language to find first and se...
Write a C program to implement the following: 1. ...
Write a program in c language to insert a new elem...
Looping Tutorial in C++ language.
Write a program in C language to find area of rect...
Write a program in C language to find area of circle.
Write a function in C++ to add two numbers using f...
Write a program to create a class name employee an...
Scope resolution operator in C++
Write A Program To Find A Maximum Number In Array
Write A Program Search In Given Number In Array Us...
Write A Program Search A Given Number In Array Usi...
Write a program to swap numbers using two variables.
Write a program to print ASCCI code for given char...
Write A Program To Swap A Two Number With Each Other
Write a program to calculate volum and area of sph...
Write a program to add and subtract complex equati...
Write a program in C language for bubble sorting i...
Write a program in C language for bubble sorting i...
Code of Game in C++
Write a program to get 9 numbers from user in two ...
Write a program to get row number from user and pr...
Write a program to get numbers from user and sort ...
Imagine a tollbooth at a bridge. Cars passing by t...
Create a class Rectangle with attributes length an...
►
April
(65)
Search Box
Most Reading
Tags
Advanced Programs
Array
Assembly Language
C Language
C Language Tutorials
C++
C++ Language
C++ Tutorials
Dev
File Handling
for loop
Functions
Graphics
If-Else-If (Conditions)
Interview Questions
Link List
Loops (For While Do-While)
Matrix
Mobile number details
OOP
pointer
Programs for Beginners
Recursion
Simple Programes (Beginers)
Strings
Structure
Switch
Track phone number
whose number is this calling me
whose number lookup
About Me
Awais
Muhammad Awais Rahman
Unknown
Contact Form
Name
Email
*
Message
*
Copyright © 2013.
Computer Programming
.
All Rights Reserved