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
Imagine a tollbooth at a bridge. Cars passing by the booth are expected to pay a 50 rupees toll. Mostly they do, but sometimes a car goes by without paying. The tollbooth keeps track of the number of cars that have gone by, and of the total amount of money collected. Model this tollbooth with a class called toll Booth. The two data items are a type unsigned int to hold the total number of cars, and a type double to hold the total amount of money collected. A constructor initializes both of these to 0. A member function called payingCar()increments the car total and adds 50 to the cash total. Another function, called nopayCar(), increments the car total but adds nothing to the cash total. Finally, a member function called display() displays the two totals. [Updated]
#include <iostream.h> class Tollboth //class declaretion { //attributes int cars; double collect; pub...
Create a class Rectangle with attributes length and width, each of which Defaults to 1. Provide member functions that calculate the perimeter and the area of the rectangle. Also, provide set and get functions for the length and width attributes. The set functions should verify that length and width are each floating-point numbers larger than 0.0 and less than 20.0. [Updated]
#include <iostream.h> class area //declare class { float width, lenght, areaofrect; //attributes public: area(...
Write a program in assembly language to multiply matrices of 3x3 [Updated]
Tags: Multiplication is assembly language, multiplication of matrices in assembly language, Note: This program is compiled in EMU software...
Write a function to raise a floating point number to an integer power. [Updated]
#include <stdio.h> #include <conio.h> float raise_to_power(float num, int power) { float ans=1, i; for(i=1;...
You just missed a call? Want to get details of that phone number?
Hey Guys, Today in this tutorial I'll teach you guys how you can get details of any mobile number. This is very simple to track any ph...
Write a program in c language to reverse a string by using strrev function or ptrint a string in reverse order
#include <stdio.h> #include <string.h> #include <conio.h> int main() { char str[100]; printf("Enter a s...
Syntax and Flowchart of For loop
In for loop statements execute until the condition is satisfied Syntax: for(initialize counter variable ; condition ; increment/decrement...
Write a program to print all input lines that are longer than 80 characters.
#include <stdio.h> #include <conio.h> int main() { int m=0, i; char string[1000], ch; printf(&q...
Write a program calculate tomorrow's date.
#include <stdio.h> #include <conio.h> struct date { int day; int month; int year; } today, tomo...
Write a program in C++ to print Pascal Series on screen
#include <stdio.h> #include <conio.h> long factorial(int); int main() { int i, n, c; printf("Enter the ...
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