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

Home » C++ Home » Games Home » puzzle -Game (Mini Project)

A D V E R T I S E M E N T

Search Projects & Source Codes:

Title puzzle -Game (Mini Project)
Author Abhishek Belkonikar
Author Email abhishek_belkonikar [at] rediffmail.com
Description This program is a game in which numbers are spread randomly & player is supposed to arrange them sr=eriouly.

Category C++ » Games
Hits 431455
Code Select and Copy the Code
Code : #include<iostream.h> #include<dos.h> #include<conio.h> #include<graphics.h> #include<stdio.h> // GLOBAL VARIABLES int a[5][5]; int t[16]={0,4,11,12,7,1,15,5,13,6,10,3,2,14,8,9}; int test[16]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; struct pos { int h,v; }p[4][4]; int row=4,col=4; // FUNCTION PROTOTYPES void game(int); //MOVEMENT void rec(); //DRAWING RECTANGLE void pri(); //PRINTING NUMBERS INITIALLY int getkey(); // TO TRACE KEY PRESSED inline void space() { cout<<" "; } inline void print(int r,int c) { cout<<a[r][c]; } void init(); //TO STORE CO-ORDINATES int stop(); // STOPING CRITERION void gopr(int,int); //TO PRINT NUMBER IN GAME void main() { int gm=DETECT,gd=DETECT; initgraph(&gm,&gd,""); int d,cr=1; init(); rec(); pri(); while(cr!=16) { d=getkey(); game(d); cr=stop(); } settextstyle(10,0,1); outtextxy(400,300,"You are winner!"); getch(); } void rec() { setcolor(5); for(int i=0;i<200;i+=50) { for(int j=0;j<240;j+=60) rectangle(j+100,i+100,j+50,i+60); } } void pri() { int k=1; for(int x=0,i=6;x<4;x++,i+=3) { for(int y=0,j=10;y<4&&k<16;y++,j+=7,k++) { gotoxy(p[x][y].h,p[x][y].v); cout<<a[x][y]; } } } int getkey() { union REGS i,o; while(!kbhit()); i.h.ah=0; int86(22,&i,&o); return(o.h.ah); } void init() { int k=1; for(int x=0,i=6;x<4;x++,i+=3) { for(int y=0,j=10;y<4;y++,j+=7) { p[x][y].h=j; p[x][y].v=i; a[x][y]=t[k++]; } } } void game(int s) { int r=row-1; int c=col-1; if(s==77 &&c!=0) //right { col--; a[r][c]=a[r][c-1]; gopr(r,c-1); space(); gopr(r,c); print(r,c-1); } if(s==80 && r!=0) //down { row--; a[r][c]=a[r-1][c]; gopr(r-1,c); space(); gopr(r,c); print(r-1,c); } if(s==75 && c!=3) //left { a[r][c]=a[r][c+1]; col++; gopr(r,c+1); space(); gopr(r,c); print(r,c+1); } if(s==72 &&r!=3) //up { a[r][c]=a[r+1][c]; row++; gopr(r+1,c); space(); gopr(r,c); print(r+1,c); } } void gopr(int x, int y) { gotoxy(p[x][y].h,p[x][y].v); } int stop() { int k=0,d=1; for(int x=0;x<4;x++) { for(int y=0;y<4;y++) { if(a[x][y]==test[k]) d++; k++; } } return d; }

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
HIGH/LOW GAME MOLLY ARORA
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

A D V E R T I S E M E N T




Google Groups Subscribe to SourceCodesWorld - Techies Talk
Email:

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

 Advertisements  

Google Search

Google

Source Codes World.com 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 | Important Websites
Copyright ©2003-2024 SourceCodesWorld.com, All Rights Reserved.
Page URL: http://www.sourcecodesworld.com/source/show.asp?ScriptID=880


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