Add to Favorites    Make Home Page 4997 Online  
 Language Categories  
 Our Services  

Home » C++ Home » Games Home » Graphics Hangman


Search Projects & Source Codes:

Title Graphics Hangman
Author Email ianandpoonu [at]
Description This is a graphics hangman with both human vs human and cpu
human playing options. A very flexible game with lots of friendly user
interfaces. It is easy to handle.
while copying some of the long sentences are broken and rest is placed
the next line.
this may cause compilation errors. So please
join the parts to avoid compilation errors.

Category C++ » Games
Hits 24283
Code Select and Copy the Code
#include<iostream.h> #include<conio.h> #include<stdio.h> #include<stdlib.h> #include<string.h> #include<dos.h> #include<graphics.h> int select(int mult) { union REGS inregs, outregs ; int bli=1,use=1,key=34,i; settextstyle(2,0,5); while(key!=28) { if(bli>0) { use=bli; setfillstyle(1,0); bli=0-bli; } else if(bli<0) { use=0-bli; setfillstyle(1,8); bli=0-bli; } floodfill(221,111+use*40,15); delay(100); if(bli<0) { key=kbhit(); if(kbhit()) { inregs.h.ah = 0 ; int86(22, &inregs, &outregs) ; key=outregs.h.ah; } } if((key==72)&&(use>1)) { bli=use-1; } if((key==80)&&(use<mult)) { bli=use+1; } } if(bli<0) bli=0-bli; return(bli); } void main() { int driver=DETECT,mode; initgraph(&driver,&mode,""); clrscr(); int score,cho,b[15],ana,hang,num,guess,remain,count=-1,mica; char a[15],h,le='?',ques[41][15]={"kuwait","giraffe","zebra","elephant","ostrit ch","mangoose","donkey","baseball","rugby","crocodile","camel","chimpanzee ","dolphin","scorpion","tarantula","rattlesnake","alligator","greatdain"," alsation","dalmatian","bulldog","boxer","srilanka","indonesia","norway","v ietnam","cameroon","zimbabwe","mexico","argentina","panama","singapore","s weden","portugal","austria","switzerland","yugoslavia","greece","woodpecke r","viper"}; char clue[40][30]={"a country","a wild animal","a wild animal","a wild/domestic animal","a wild bird","a wild animal","a domestic animal","a game","a game","a reptile","a wild/domestic animal","a wild animal","a sea mammal","an arthropod","an arthropod","a snake","a reptile","a dog","a dog","a dog","a dog","a dog","a country","a country","a country","a country","a country","a country","a country","a country","a country","a country","a country","a country","a country","a country","a country","a country","a bird","a snake"}; char option[3][20]={"Human v/s human"," Human v/s cpu"," Exit"}; char cue[30],loop; char d[15],inpu; randomize(); guess=int(rand()%1000); remain=guess%40; do { for(int i=0;i<15;i++) { d[i]='_'; a[i]='?'; } mica=0; loop='y'; score=0; ana=1; hang=0; strcpy(cue," "); cleardevice(); setcolor(15); rectangle(0,0,639,479); setfillstyle(1,8); floodfill(100,100,15); settextstyle(3,0,4); setcolor(15); outtextxy(230,70,"HANG MAN"); rectangle(10,400,630,470); settextstyle(2,0,5); for(i=0;i<120;i+=40) { rectangle(220,150+i,390,180+i); setviewport(221,151+i,389,179+i,1); clearviewport(); setviewport(0,0,639,479,1); outtextxy(247,157+i,option[i/40]); rectangle(240,155+i,370,175+i); } outtextxy(30,380,"About the game:-"); outtextxy(20,420,"This game is very familiar to you. We will be hiding a word and you have to find"); outtextxy(30,440,"it by guessing each of it's letters, a clue will be provided."); cho=select(3); if(cho==1) { cleardevice(); setcolor(15); rectangle(0,0,639,479); setfillstyle(1,8); floodfill(100,100,15); count++; b[count]=40; outtextxy(120,150,"Now one of you who is going to guess, type in your word"); outtextxy(180,170,"(a single word < 13 words).I will hide it for you."); setbkcolor(8); i=0; h=0; while(h!=13) { gotoxy(3,2); h=getche(); a[i]=h; gotoxy(3,2); cout<<" "; i++; } a[i-1]='<num;j++) { cout<<" "<<d[j]; } gotoxy(28,26); if(hang==1) { line(540,150,540,170); } else if(hang==2) { circle(540,190,20); } else if(hang==3) { line(540,210,540,250); } else if(hang==4) { line(540,220,520,240); line(540,220,560,240); } else if(hang==5) { line(540,250,520,270); } else if(hang==6) { line(540,250,560,270); } if((hang>=6)) { setviewport(41,374,599,402,1); clearviewport(); setviewport(0,0,639,479,1); outtextxy(50,380,"you couldnot find the word,now I will fill the blanks"); if(d[mica]=='_') { for(long double gh=0;gh<39999999;gh++); d[mica]=a[mica]; } mica++; continue; } else if(ana>num) mica=num+1; if((ana<=num)&&(hang<=5)) { setviewport(41,374,599,402,1); clearviewport(); setviewport(0,0,639,479,1); outtextxy(50,380,"enter your guess :-"); gotoxy(28,25); cin>>le; if((le==a[0])||(le==a[1])||(le==a[2])||(le==a[3])||(le==a[4])||(le==a[5])| |(le==a[6])||(le==a[7])||(le==a[8])||(le==a[9])||(le==a[10])||(le==a[11])| |(le==a[12])||(le==a[13])) { for(int j=0;j<num;j++) { if(le==a[j]) { d[j]=a[j]; ana++; a[j]='1'; } } } else hang++; } else ana++; }while((mica-1)!=num); ret: setviewport(41,374,599,402,1); clearviewport(); setviewport(0,0,639,479,1); outtextxy(50,380,"Press n to know your score!!"); loop=getche(); if(loop!='n') goto ret; cleardevice(); rectangle(0,0,639,479); rectangle(370,100,620,350); rectangle(40,373,600,403); rectangle(20,100,270,350); setfillstyle(1,8); floodfill(1,1,15); line(450,150,450,300); line(420,300,480,300); line(450,150,540,150); line(540,150,540,170); circle(540,190,20); line(540,210,540,250); line(540,220,520,240); line(540,220,560,240); line(540,250,520,270); line(540,250,560,270); setviewport(41,374,599,402,1); clearviewport(); setviewport(0,0,639,479,1); outtextxy(50,380,"Want to try again(y/n)"); if(ana>=num) { outtextxy(50,150,"You Win!"); } else { outtextxy(50,150,"You Lose!"); } outtextxy(50,202,"Your Point is "); gotoxy(25,14); score=0; for(i=0;i<num;i++) { if(a[i]=='1') { score++; } } cout<<(score*100)/num; outtextxy(50,255,"The Answer is "); gotoxy(12,20); cout<<ques[b[count]]; inpu=getche(); }while(inpu=='Y'||inpu=='y'); cleardevice(); outtextxy(80,150,"This game is developed by Anand ts. Watch out! coming soon"); outtextxy(170,175,"from the same developer `THE ACE'!"); for(long double mas=0;mas<=99999999;mas++); exit(0); } 5,"75%"); bar(590,209,604,204); rectangle(590,209,604,204); outtextxy(590,194,"5%"); } else if(correct_answer==3) { bar(498,209,512,204); rectangle(498,209,512,204); outtextxy(498,194,"5%"); bar(530,209,544,190); rectangle(530,209,544,190); outtextxy(527,180,"15%"); bar(560,209,574,199); rectangle(560,209,574,199); outtextxy(559,189,"10%"); bar(590,209,604,138); rectangle(590,209,604,138); outtextxy(584,118,"70%"); } setcolor(11); settextstyle(7,0,2); if(correct_answer==0) outtextxy(51,384,"A)"); else if(correct_answer==1) outtextxy(331,384,"B)"); else if(correct_answer==2) outtextxy(51,433,"C)"); else if(correct_answer==3) outtextxy(331,433,"D)"); } return flag; } /************************************************************************* / //---------------------- show_score_card() ----------------------------// /************************************************************************* / void crorepati::show_score_card(int count) { setcolor(9); line(478,45,620,45); for(int i=0;i HTTP sta

Related Source Codes

Script Name Author
Moving ball screen saver karlmarx
The Classic Game of Snake & Ladder Lakshmi Narayana .A
Railway seat reservation question which comes in sapient VyomWorld
To calculate percentile Ravi Mathur
Send to folder ANIMESH SAHU
Analog clock and calendar Nazia & Rida
Data structure (stack Implimentation) Swapnil B Adsure
Memory Game AnirudhSanyal
Easy Calc Anirudh Sanyal
GK Quiz Anirudh Sanyal
Hangman Game Manish Jain
Snakeman Manish Jain
Full month Calendar Nigi
Cursor shapes nigi


Google Groups Subscribe to SourceCodesWorld - Techies Talk

Free eBook - Interview Questions: Get over 1,000 Interview Questions in an eBook for free when you join JobsAssist. Just click on the button below to join JobsAssist and you will immediately receive the Free eBook with thousands of Interview Questions in an ebook when you join.

New! Click here to Add your Code!

ASP Home | C Home | C++ Home | COBOL Home | Java Home | Pascal Home
Source Codes Home Page


Google Search


Source Codes is a part of Vyom Network.

Vyom Network : Web Hosting | Dedicated Server | Free SMS, GRE, GMAT, MBA | Online Exams | Freshers Jobs | Software Downloads | Interview Questions | Jobs, Discussions | Placement Papers | Free eBooks | Free eBooks | Free Business Info | Interview Questions | Free Tutorials | Arabic, French, German | IAS Preparation | Jokes, Songs, Fun | Free Classifieds | Free Recipes | Free Downloads | Bangalore Info | Tech Solutions | Project Outsourcing, Web Hosting | GATE Preparation | MBA Preparation | SAP Info | Software Testing | Google Logo Maker | Freshers Jobs

Sitemap | Privacy Policy | Terms and Conditions
Copyright ©2003-2017, All Rights Reserved.
Page URL:

Download Yahoo Messenger | Placement Papers | Free SMS | C Interview Questions | C++ Interview Questions | Quick2Host Review