Friday, April 2, 2010

Hangman (GAME)

/*******************************************************
APPLICATION : HANGMAN (The Game)
CODED BY : Ankit Pokhrel
COMPILED ON : Borland Turbo C++ Ver 3.0
DATE : 2009 - 12 - 06
********************************************************/

#include "iostream.h"
#include "stdio.h"
#include "graphics.h"
#include "conio.h"
#include "dos.h"
#include "stdlib.h"
#include "string.h"
#include "ctype.h"

const int UP = 72;
const int DOWN = 80;
const int ENTER = 13;
const int ESC = 27;

int face()
{
int midx = getmaxx()/2;
int midy = getmaxy()/2,i,shift;

delay(1000);
for(i = 0;i <= 10;i++) { setcolor(RED); settextstyle(10,0,i); outtextxy(50,20,"HANG"); delay(90); setcolor(BLACK); settextstyle(10,0,i); outtextxy(50,20,"HANG"); } setcolor(RED); settextstyle(10,0,i); outtextxy(50,20,"HANG"); shift = 0; for(i = 0;i <= 10;i++) { setcolor(RED); settextstyle(10,0,10); outtextxy(midx - 220,shift,"MAN"); delay(5); setcolor(BLACK); settextstyle(10,0,10); outtextxy(midx - 220,shift,"MAN"); shift+=15; } setcolor(BLUE); settextstyle(10,0,10); outtextxy(100,200,"MAN"); setcolor(RED); settextstyle(10,0,10); outtextxy(50,20,"HANG"); for(i = 6;i >= 2;i--)
{
setcolor(LIGHTBLUE);
settextstyle(9,0,i);
outtextxy(midx - 100,20,"THE");
delay(90);
setcolor(BLACK);
settextstyle(9,0,i);
outtextxy(midx - 100,20,"THE");
}

setcolor(RED);
settextstyle(10,0,10);
outtextxy(50,20,"HANG");

setcolor(LIGHTBLUE);
settextstyle(9,0,i);
outtextxy(midx - 100,20,"THE");

for(i = 6;i >= 2;i--)
{
setcolor(GREEN);
settextstyle(9,0,i);
outtextxy(midx-50,20,"GAME");
delay(90);
setcolor(BLACK);
settextstyle(9,0,i);
outtextxy(midx-50,20,"GAME");
}

setcolor(GREEN);
settextstyle(9,0,i);
outtextxy(midx-50,20,"GAME");

delay(800);

setcolor(BLACK);
settextstyle(9,0,1);
outtextxy(midx - 100,20,"THE");

setcolor(BLACK);
settextstyle(9,0,1);
outtextxy(midx - 50,20,"GAME");

setcolor(LIGHTBLUE);
settextstyle(9,0,1);
outtextxy(midx - 90,10,"THE");

setcolor(GREEN);
settextstyle(9,0,1);
outtextxy(midx - 39,10,"GAME");


setcolor(BLACK);
settextstyle(10,0,10);
outtextxy(50,20,"HANG");


for(i = 10;i >= 6;i--)
{
setcolor(RED);
settextstyle(10,0,i);
outtextxy(midx - 100,20,"HANG");
delay(50);
setcolor(BLACK);
settextstyle(10,0,i);
outtextxy(midx - 100,20,"HANG");
}
setcolor(RED);
settextstyle(10,0,i);
outtextxy(midx - 100,20,"HANG");

setcolor(BLACK);
settextstyle(10,0,10);
outtextxy(100,200,"MAN");

shift = 150;
for(i = 10;i >= 6;i--)
{
setcolor(BLUE);
settextstyle(10,0,i);
outtextxy(midx - 100,shift,"MAN");
delay(50);
setcolor(BLACK);
settextstyle(10,0,i);
outtextxy(midx - 100,shift,"MAN");
shift-=15;
}
setcolor(BLUE);
settextstyle(10,0,i);
outtextxy(midx - 87,shift + 10,"MAN");

setcolor(CYAN);
setfillstyle(CLOSE_DOT_FILL,RED);
bar(5,5,midx - 105,midy - 55);
bar(midx + 70,5 ,2 * midx - 5,midy - 55);
bar(5,midy - 55,2 * midx - 5,2 * midy - 5);
rectangle(midx - 105,5,midx + 70,midy - 55);
rectangle(5,5,2 * midx - 5,2 * midy - 5);


delay(400);
setfillstyle(0,DARKGRAY);
bar3d(10,10,midx - 110,midy - 55,0,0);
setcolor(BROWN);
settextstyle(2,0,5);
outtextxy(25,15,"PROJECT SUBMITTED BY");
line(15,30,midx - 115,30);
outtextxy(20,35,"ANKIT POKHREL");
outtextxy(20,55,"BE COMPUTER");
outtextxy(20,75,"FIRST YEAR/SECOND PART");
outtextxy(20,95,"ACME ENGINEERING COLLEGE");
outtextxy(20,115,"2066, MANGSIR 20");
outtextxy(50,135,"COMPILED ON");
outtextxy(35,155,"TURBO C++ VER 3.0");

delay(400);
setcolor(CYAN);
setfillstyle(0,DARKGRAY);
bar3d(midx + 75,10 ,2 * midx - 10,midy - 55,0,0);
setcolor(BROWN);
settextstyle(2,0,5);
outtextxy(midx + 150,10,"SUBMITTED TO");
line(midx + 80,30,midx + 305,30);
outtextxy(midx + 85,40,"------------------");
outtextxy(midx + 85,60,"LECTURER,");
outtextxy(midx + 85,80,"DEPARTMENT OF COMPUTER" );
outtextxy(midx + 85,100,"ACME ENGINEERING COLLEGE");
outtextxy(midx + 85,120,"SITAPAILA, KATHMANDU");
line(midx + 80,145,midx + 305,145);

delay(300);
setcolor(CYAN);
bar3d(midx - 157,midy - 30,midx + 150,midy - 10,0,0);
setcolor(GREEN);
outtextxy(midx - 90,midy - 27,"PLEASE, SELECT OPTION");

settextstyle(10,0,2);
setcolor(CYAN);
bar3d(midx - 155,midy + 10,midx + 150,midy + 195,0,0);
setcolor(LIGHTBLUE);
outtextxy(midx - 50,midy + 15,"START");
outtextxy(midx - 120,midy + 55,"HOW TO PLAY");
outtextxy(midx - 140,midy + 95,"ABOUT HANGMAN");
outtextxy(midx - 50,midy + 135,"LEAVE");


int key = 1;
char ch;
while(1)
{
switch (key)
{
case 1:

setcolor(LIGHTBLUE);
settextstyle(10,0,2);
outtextxy(midx - 50,midy + 135,"LEAVE");
outtextxy(midx - 120,midy + 55,"HOW TO PLAY");

setcolor(GREEN);
settextstyle(10,0,2);
outtextxy(midx - 50,midy + 15,"START");
break;

case 2:

setcolor(LIGHTBLUE);
settextstyle(10,0,2);
outtextxy(midx - 50,midy + 15,"START");
outtextxy(midx - 140,midy + 95,"ABOUT HANGMAN");

setcolor(GREEN);
settextstyle(10,0,2);
outtextxy(midx - 120,midy + 55,"HOW TO PLAY");
break;

case 3:
setcolor(LIGHTBLUE);
settextstyle(10,0,2);
outtextxy(midx - 120,midy + 55,"HOW TO PLAY");
outtextxy(midx - 50,midy + 135,"LEAVE");

setcolor(GREEN);
settextstyle(10,0,2);
outtextxy(midx - 140,midy + 95,"ABOUT HANGMAN");
break;


case 4:
setcolor(LIGHTBLUE);
settextstyle(10,0,2);
outtextxy(midx - 140,midy + 95,"ABOUT HANGMAN");
outtextxy(midx - 50,midy + 15,"START");

setcolor(GREEN);
settextstyle(10,0,2);
outtextxy(midx - 50,midy + 135,"LEAVE");
break;

}

ch = getch();
if(ch == ENTER)
break;

if(ch == DOWN)
{
++key;
if(key > 4)
key = 1;
}

if(ch == UP)
{
--key;
if(key < 1) key = 4; } } return key; } void background(char *name,int q = 1,int l = 1,int c = 3) { graphdefaults(); int x = getmaxx(); int y = getmaxy(); char temp[51],ch[2]; graphdefaults(); itoa(q,ch,10); ch[1] = '\0'; strcpy(temp,"QUESTION : "); strcat(temp,ch); setcolor(BROWN); line(0,50,x,50); line(0,y-50,x,y-50); name[0] = toupper(name[0]); setcolor(GREEN); settextstyle(2,HORIZ_DIR,5); outtextxy(20,20,name); outtextxy(x/2 - 60,20,temp); strcpy(temp,"LEVEL : "); itoa(l,ch,10); ch[1] = '\0'; strcat(temp,ch); outtextxy(x - 100,20,temp); strcpy(temp,"LIFE LEFT : "); itoa(c,ch,10); ch[1] = '\0'; strcat(temp,ch); outtextxy(20,y - 30,temp); strcpy(temp,"CATAGORY : "); switch(l) { case 1: strcat(temp,"SCIENCE"); break; case 2: strcat(temp,"COUNTRY"); break; case 3: strcat(temp,"SPORTS"); break; case 4: strcat(temp,"CAPITALS"); break; case 5: strcat(temp,"HISTORY"); break; case 6: strcat(temp,"COMPUTER"); break; case 7: strcat(temp,"POLITICIANS"); break; case 8: strcat(temp,"TECHNOLOGY"); break; case 9: strcat(temp,"BOOKS"); break; case 10: strcat(temp,"MISCELLANEOUS"); break; } outtextxy(x - 200,y - 30,temp); } void rope() { int midx = getmaxx()/2; int midy = getmaxy()/2; setcolor(RED); setlinestyle(SOLID_LINE,0,2); line(midx - 36,midy - 188,midx - 36,midy - 110); } void head(int color = BROWN) { rope(); graphdefaults(); int midx = getmaxx()/2; int midy = getmaxy()/2; setcolor(color); settextstyle(0,0,3); outtextxy(midx - 48,midy - 110,"\1"); } void body(int color = BROWN) { int midx = getmaxx()/2; int midy = getmaxy()/2; setfillstyle(SOLID_FILL,color); bar(midx - 35,midy - 30,midx - 37,midy - 88); } void leg(int color = BROWN) { int midx = getmaxx()/2; int midy = getmaxy()/2; setcolor(color); setfillstyle(SOLID_FILL,color); line(midx - 40,midy - 30,midx - 30,midy - 30); bar(midx - 42,midy + 10,midx - 40 ,midy - 30); bar(midx - 32 ,midy - 30,midx - 30,midy + 10); } void hand(int color = BROWN) { int midx = getmaxx()/2; int midy = getmaxy()/2; setcolor(color); setfillstyle(SOLID_FILL,color); line(midx - 40,midy - 80,midx - 30,midy - 80); bar(midx - 42,midy - 80,midx - 40 ,midy - 40); bar(midx - 32 ,midy - 80,midx - 30,midy - 40); } void hang() { graphdefaults(); int midx = getmaxx()/2; int midy = getmaxy()/2; setcolor(RED); int shift = 0; shift = 0; for(int i = 0;i < 5;i++) { setcolor(BLACK); settextstyle(0,0,3); outtextxy(midx - 48,midy - 110 + shift,"\1"); setfillstyle(SOLID_FILL,BLACK); bar(midx - 35,midy - 30 + shift,midx - 37,midy - 88 + shift); line(midx - 40,midy - 30 + shift,midx - 30,midy - 30 + shift); bar(midx - 42,midy + 10 + shift,midx - 40 ,midy - 30 + shift); bar(midx - 32 ,midy - 30 + shift,midx - 30,midy + 10 + shift); line(midx - 40,midy - 80,midx - 30,midy - 80); bar(midx - 42,midy - 80,midx - 40 ,midy - 40); bar(midx - 32 ,midy - 80,midx - 30,midy - 40); setcolor(RED); setlinestyle(SOLID_LINE,0,2); line(midx - 36,midy - 188,midx - 36,midy - 110 + shift); shift += 10; setcolor(RED); settextstyle(0,0,3); outtextxy(midx - 48,midy - 110 + shift,"\1"); setfillstyle(SOLID_FILL,RED); bar(midx - 35,midy - 30 + shift,midx - 37,midy - 88 + shift); line(midx - 40,midy - 30 + shift,midx - 30,midy - 30 + shift); bar(midx - 42,midy + 10 + shift,midx - 40 ,midy - 30 + shift); bar(midx - 32 ,midy - 30 + shift,midx - 30,midy + 10 + shift); line(midx - 40,midy - 80 + shift,midx - 30,midy - 80 + shift); bar(midx - 42,midy - 80 + shift,midx - 40 ,midy - 40 + shift); bar(midx - 32 ,midy - 80 + shift,midx - 30,midy - 40 + shift); setcolor(RED); setlinestyle(SOLID_LINE,0,2); line(midx - 36,midy - 188,midx - 36,midy - 110 + shift); delay(100 + shift * 6); } setcolor(BLACK); settextstyle(0,0,3); outtextxy(midx - 48,midy - 110 + shift,"\1"); setfillstyle(SOLID_FILL,BLACK); bar(midx - 35,midy - 30 + shift,midx - 37,midy - 88 + shift); line(midx - 40,midy - 30 + shift,midx - 30,midy - 30 + shift); bar(midx - 42,midy + 10 + shift,midx - 40 ,midy - 30 + shift); bar(midx - 32 ,midy - 30 + shift,midx - 30,midy + 10 + shift); line(midx - 40,midy - 80 + shift,midx - 30,midy - 80 + shift); bar(midx - 42,midy - 80 + shift,midx - 40 ,midy - 40 + shift); bar(midx - 32 ,midy - 80 + shift,midx - 30,midy - 40 + shift); setcolor(RED); line(midx - 36,midy - 188,midx - 36,midy - 110 + shift); settextstyle(0,0,3); outtextxy(midx - 48,midy - 110 + shift,"\2"); setfillstyle(SOLID_FILL,RED); bar(midx - 35,midy - 30 + shift,midx - 37,midy - 88 + shift); setlinestyle(SOLID_LINE,0,3); line(midx - 39,midy - 30 + shift,midx - 33,midy - 30 + shift); line(midx - 60,midy + 10 + shift,midx - 40,midy - 30 + shift); line(midx - 32,midy - 30 + shift,midx - 10,midy + 10 + shift); line(midx - 39,midy - 80 + shift,midx - 33,midy - 80 + shift); line(midx - 40,midy - 80 + shift,midx - 60,midy - 50 + shift); line(midx - 33,midy - 80 + shift,midx - 10,midy - 50 + shift); } void right(int color) { graphdefaults(); int x = getmaxx(); int y = getmaxy(); setcolor(color); setlinestyle(SOLID_LINE,0,3); line(x/2 - 33,y - 30,x/2 - 26,y - 23); line(x/2 - 25,y - 24,x/2 - 10,y - 31); } void gameover() { int midx = getmaxx()/2; int midy = getmaxy()/2; cleardevice(); settextjustify(CENTER_TEXT,CENTER_TEXT); settextstyle(2,0,10); setcolor(RED); outtextxy(midx,midy,"GAME OVER"); setcolor(GREEN); outtextxy(midx,midy + 50,"THANKYOU FOR PLAYING."); delay(1500); closegraph(); exit(0); } void wrong(int color) { graphdefaults(); int midx = getmaxx()/2; int y = getmaxy(); setcolor(color); settextstyle(SANS_SERIF_FONT,HORIZ_DIR,4); outtextxy(midx - 28,y - 40,"(X)"); } void about_hangman(void) { cleardevice(); setcolor(WHITE); setfillstyle(11,RED); bar3d(5,5,getmaxx() - 5,getmaxy() - 5,0,0); /* Outermost Bar */ setfillstyle(11,DARKGRAY); delay(500); bar3d(110,20,540,86,0,0); /* Internal Small Bar */ settextstyle(10,HORIZ_DIR,3); settextjustify(LEFT_TEXT,LEFT_TEXT); delay(600); outtextxy(160,67,"ABOUT HANGMAN"); delay(500); setfillstyle(9,DARKGRAY); bar3d(10,415,630,100,0,0); /* Internal Large Bar */ delay(650); settextstyle(SMALL_FONT,HORIZ_DIR,5); outtextxy(34,125," -> This Program was developed ,coded and completed as a Home");
delay(250);
outtextxy(33,140,"Project on 21th Mangsir 2066 (6th DEC 2009).");
delay(250);
outtextxy(33,155,"This Application was developed using the simple concepts of the C programming ");
delay(250);
outtextxy(33,170,"Language. General components of C language like Loops ,String,Function,File");
delay(250);
outtextxy(33,185,"C - Graphics and Conditional Statements are used in this Program.");
delay(250);

setcolor(WHITE);
settextstyle(SMALL_FONT,HORIZ_DIR,4);
outtextxy(19,209,"c");
circle(21,207,6);
circle(21,207,5);
settextstyle(SMALL_FONT,HORIZ_DIR,5);
setcolor(WHITE);
outtextxy(32,211,"Ankit Pokhrel (2066 B.S. / 2009 A.D). All Rights Reserved.");
delay(200);

setcolor(RED);
settextstyle(SANS_SERIF_FONT,HORIZ_DIR,0);
outtextxy(19,245,"W");
sound(150);
delay(180);
nosound();
outtextxy(40,245,"A");
sound(350);
delay(180);
nosound();
outtextxy(60,245,"R");
sound(150);
delay(180);
nosound();
outtextxy(80,245,"N");
sound(350);
delay(180);
nosound();
outtextxy(100,245,"I");
sound(150);
delay(180);
nosound();
outtextxy(105,245,"N");
sound(350);
delay(180);
nosound();
outtextxy(125,245,"G");
sound(150);
delay(250);
nosound();

settextstyle(SMALL_FONT,HORIZ_DIR,5);
setcolor(WHITE);
outtextxy(19,260," No part of the program can be reproduced or distributed in any form or by");
delay(250);
outtextxy(33,275,"any means,or stored in a database or retrieval system,without prior written");
delay(250);
outtextxy(33,290,"permission of the programmer. Requests for permission or further information ");
delay(250);
outtextxy(33,305,"should be adressed to Ankit Pokhrel in the address below.");
delay(250);

settextstyle(SMALL_FONT,HORIZ_DIR,6);
outtextxy(33,328,"Ankit Pokhrel");
line(33,330,153,330);

delay(300);
settextstyle(SMALL_FONT,HORIZ_DIR,5);
outtextxy(33,350,"Department of Computer.");

delay(300);
outtextxy(33,365,"Acme Engineeirng College.");

delay(300);
outtextxy(33,380,"Phone no : +977-1-9803970090");

delay(300);
outtextxy(33,395,"E-mail : ankitpokhrel@gmail.com");

delay(300);
outtextxy(33,410,"Kathmandu, NEPAL");

delay(200);
settextstyle(DEFAULT_FONT,HORIZ_DIR,2);
setcolor(WHITE);
outtextxy(30,450,"Press any key to return to main menu");
getch();
}

void how_to_play (void)
{
cleardevice();
setfillstyle(11,RED);
settextstyle(10,HORIZ_DIR,4);
settextjustify(LEFT_TEXT,LEFT_TEXT);
setcolor(WHITE);
bar3d(5,5,getmaxx() - 5,getmaxy() - 5,0,0); /* Internal Large Bar */
setfillstyle(11,DARKGRAY);
delay(500);
bar3d(62,20,563,86,0,0);
setcolor(WHITE);
delay(600);
outtextxy(105,72,"HOW TO PLAY?");
delay(500);
setcolor(WHITE);
setfillstyle(9,DARKGRAY);
bar3d(10,415,630,100,0,0);
settextstyle(SMALL_FONT,HORIZ_DIR,5);
delay(650);
setcolor(WHITE);
outtextxy(14,130,"-> This is a Single Player Guessing Game Named HANGMAN.");
delay(300);
outtextxy(14,160,"-> The Game is Divided into 9 Levels.");
delay(300);
outtextxy(14,190,"-> Each Level Contains 8 Questions Except Last Level (7 Questions).");
delay(300);
outtextxy(14,220,"-> A Word with Certain Letters is Displayed on a Screen. You have to Guess The ");
outtextxy(14,235," Correct Word Letter by Letter & if all of the attempt fails The Man is Hanged.");
delay(300);
outtextxy(14,265,"-> If The Man is Hanged 3 Times You Loose.");
delay(300);
outtextxy(14,295,"-> The Catagory Provides You Hint to Guess The Correct Word.");
delay(300);
outtextxy(14,325,"-> If You Hit Wrong Letter the Color of Different Parts of The Man is Changed");
outtextxy(14,340," to RED.");
delay(300);
outtextxy(14,370,"-> You can Press \'ESC\' any time to Terminate the Program.");
delay(300);
settextstyle(DEFAULT_FONT,HORIZ_DIR,2);
setcolor(WHITE);
outtextxy(55,450,"Press any key to return back...");
getch();
}

void start_game()
{
FILE *source;
char filename[] = "Words.txt",player[15] = "";
char str[31],c[2],key,temp[31];
int question = 1,level = 1,count = 1,life = 3,pass;
int midx = getmaxx()/2,midy = getmaxy()/2;
source = fopen(filename,"r");
if(source == NULL)
{
cleardevice();
cout << "ERROR : Unable to find file."; cout << "\nPress any key to halt..."; getch(); exit(0); } midx = getmaxx()/2; midy = getmaxy()/2; setcolor(CYAN); setfillstyle(WIDE_DOT_FILL,DARKGRAY); bar3d(midx - 155,midy + 10,midx + 150,midy + 195,0,0); setcolor(LIGHTBLUE); setfillstyle(0,DARKGRAY); bar3d(midx - 70,midy + 40,midx + 70,midy + 65,0,0); bar3d(midx - 70,midy + 90,midx + 70,midy + 115,0,0); setcolor(DARKGRAY); settextstyle(SMALL_FONT,HORIZ_DIR,5); outtextxy(midx - 55,midy + 45,"Write Your Name"); gotoxy(midx - 26,22); cin >> player;

int h = 0;
do
{
if(h == 9)
{
settextstyle(2,0,8);
setcolor(LIGHTBLUE);
outtextxy(midx - 100,midy + 203 ,"NEXT LEVEL");
delay(1200);
h = 0;
}

cleardevice();
count = 1;

background(player,question,level,life);
head();
body();
leg();
hand();

setfillstyle(SOLID_FILL,BLACK);
bar(0,320,2 * midx,360);
fgets(str,30,source);

++question;

if(question%9 == 0)
{
h = question;
++level;
if(level == 10)
gameover();
question = 1;
}

int n = strlen(str);
str[n-1] = '\0';
for(int i = 0;i < n-1;i++)
temp[i] = ' ';
int shift = 25;

if(n <= 9)
{
setcolor(GREEN);
settextstyle(0,0,0);
temp[0] = str[0];
c[0] = str[0];
c[1] = '\0';
settextjustify(CENTER_TEXT,CENTER_TEXT);
outtextxy((midx - 148),midy + 103,c);

setcolor(RED);
for(int i = 1;i < n-1;i++)
{
outtextxy((midx - 148) + shift,midy + 115,"-");
shift += 25;
}

}

else
{
setcolor(GREEN);
settextstyle(0,0,0);
temp[0] = str[0];
c[0] = str[0];
c[1] = '\0';
outtextxy((midx - 150),midy + 100,c);
c[0] = str[n - 2];
temp[n - 2] = str[n - 2];
c[1] = '\0';
outtextxy((midx - 150) + (n-2) * 25,midy + 100,c);
c[0] = str[int(n/2)];
temp[int(n/2)] = str[int(n/2)];
c[1] = '\0';
outtextxy((midx - 150) + n/2 * 25,midy + 100,c);

for(int i = 1;i < n-2;i++)
{
if(i != (int(n/2)) && str[i] != ' ')
{
setcolor(RED);
settextjustify(CENTER_TEXT,CENTER_TEXT);
settextstyle(0,0,0);
outtextxy((midx - 148) + shift,midy + 115,"-");
}
shift += 25;
}
}
shift = 25;
temp[n-1] = '\0';
while(1)
{

if(strcmpi(temp,str) == 0)
{
delay(600);
break;
}
key = getch();
key = toupper(key);
if(key == ESC)
{
cleardevice();
setcolor(GREEN);
settextjustify(CENTER_TEXT,CENTER_TEXT);
settextstyle(2,0,12);
outtextxy(midx,midy,"BYE BYE");
outtextxy(midx,midy + 33,"THANKYOU FOR PLAYING.");
delay(1000);
closegraph();
exit(0);
}

pass = 0;
for(int i = 0;i < n-1;i++)
{
if(key == str[i])
{
right(GREEN);
delay(300);
right(BLACK);
if(i != 0 && i!= n-1)
{
temp[i] = key;
c[0] = str[i];
c[1] = '\0';
setcolor(GREEN);
outtextxy((midx - 150) + shift * i,midy + 100,c);
}
++pass;
}

}

if(pass == 0)
{
wrong(RED);
delay(300);
wrong(BLACK);

if(count == 1)
leg(RED);
if(count == 2)
hand(RED);
if(count == 3)
body(RED);
if(count == 4)
{
setfillstyle(SOLID_FILL,BLACK);
bar(0,midy + 108,2 * midx,midy + 128);

static int hangc = 0;
setfillstyle(SOLID_FILL,BLACK);
bar(0,330,2 * midx,350);
hang();
--life;
++hangc;
if(hangc == 3)
{
delay(900);
gameover();
}

delay(900);
break;

}

++count;
}

}
}while(1);
}

void main()
{
clrscr();
int gd = DETECT,gm,midx,midy,option;
initgraph(&gd,&gm,"c:\\tc\\bgi");

int errorcode = graphresult();

if (errorcode != grOk) // An Error Occurred
{
cout << "Graphics error: " << grapherrormsg(errorcode);
cout << "\nPress any key to halt...";
getch();
exit(0); // Return With Error Code
}

do
{
option = face();
switch(option)
{
case 1:
start_game();
break;

case 2:
how_to_play();
cleardevice();
graphdefaults();
break;

case 3:
about_hangman();
cleardevice();
graphdefaults();
break;

case 4:
cleardevice();
setcolor(GREEN);
settextjustify(CENTER_TEXT,CENTER_TEXT);
settextstyle(2,0,12);
outtextxy(midx,midy,"BYE BYE");
outtextxy(midx,midy + 33,"THANKYOU FOR PLAYING.");
closegraph();
exit(0);

}
}while(option != 1);

}//END OF MAIN

// END OF PROGRAM


//Words for the Game
//Save in seperate notepad file words.txt

ENTHALPY
GENETICS
AMPLITUDE
COSMOLOGY
SUPERNOVA
DEUTERIUM
RADIOACTIVITY
HARMONIC MOTION
LITHUANIA
BELORUSSIA
TURKMENISTAN
KYRGYZSTAN
MAURITANIA
SLOVAKIA
SIERRA LEONE
CZECHOSLOVAKIA
BADMINTON
ELEPHANT POLO
WRESTLING
ARCHERY
SKATEBOARDING
ICE SKATING
BULLFIGHTING
GYMNASTICS
WARSAW
HELSINKI
KHARTOUM
NASSAU
VILNIUS
TALLIN
REYKJAVIK
NOUAKCHOTT
ADOLF HITLER
GENGHIS KHAN
OTTOMAN EMPIRE
HAN DYNASTY
COLOSSEUM
CASABLANCA
SCANDINAVIAN
CHARLEMAGNE
MICROSOFT
MICROPROCESSOR
NANOTECHNOLOGY
INTELLIGENCE
ENCRYPTION
LINUS TORVALDS
ETHICAL HACKING
MALICIOUS HACKERS
F D ROOSEVELT
WISTON CHURCHILL
MAO ZEDONG
JOSEPH STALIN
VLADIMIR LENIN
STEPHEN HARPER
JOSIP BROZ TITO
MUHAMMAD PROPHET
SUBMARINE
AUTOMOBILE
FIGHTER AIRCRAFT
TELECOMMUNICATION
NUCLEAR BOMB
DIGITAL TECHNOLOGY
MULTIMEDIA
SUPERCOMPUTER
THE ALCHEMIST
INVISIBLE MAN
THE EIGHTH DAY
THE GREAT FIRE
THE CENTAUR
THE FIXER
THE MAGIC BARREL

No comments:

Post a Comment