Kendrya Vidalaya No. 2 Delhi Cantt. New Delhi, Ii-Shift: Submitted As A Part of C.B.S.E. Curriculum FOR THE YEAR 2018-19

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 36

Kendrya Vidalaya No.

2
Delhi Cantt.
New Delhi , ii-Shift

SUBMITTED AS A PART OF C.B.S.E. CURRICULUM


FOR THE YEAR 2018-19

Submitted To:
Mrs. Neelam Gupta
PGT(Computer Science)

Submitted By:
Prabhat Kumar Mishra
roll no:9175064
COMPUTER SCIENCE
PROJECT FILE

Topic- Jumble words


Game

Language-C++
TABLE OF CONTENTS

Certificate.

Acknowledgement.

Header files and functions.

Coding.

Screenshots.

Bibliography.
Certificate
This is to certify that Prabhat Kumar Mishra
of class twelve, KV No.2 Delhi Cantt, New Delhi has
successfully completed his project in computer
practicals for the AISSCE as prescribed by CBSE in
the year 2018-2019.

Date :

Registration No. :

Signature of Internal Signature of External


Examiner Examiner

__________________ __________________
Acknowledgement
I thank my Computer Science teacher Mrs.
Neelam Gupta for guidance and support. I would
also like to thank my parents and my friends for
encouraging me during the course of this project.
Finally I would like to thank CBSE for giving me
this opportunity to undertake this project.
HEADER FILES USED

GRAPHICS.H- initgraph();
setbkcolor();
setcolor();
settextstyle();
outtextxy();
circle(); rectangle(); line();
 PROCESS.H- exit();
 FSTREAM.H- read(),write(),open(),close();
 CONIO.H- getch();
 STDLIB.H- rand();
 STRING.H- strcpy();
 DOS.H- delay();
CODING:
//HEADER FILES USED IN PROGRAM:

#include<fstream.h>
#include<graphics.h>
#include<stdio.h>
#include<string.h>
#include<conio.h>
#include<stdlib.h>
#include<dos.h>

//*******************************************************
****************************

class word //class for words


{
public:
int i;
char word [15];
};

//*******************************************************
****************************

void disp(char[],int,int,char[]); //function for displaying game main


screen
void circle5(int,int,int); //function for making circles
void insertsc(int,char[]); //function for saving name and total
points
void clr(); //for clearing screen
void load(); //for loading function 1
void load2(); //for loading function 2
void thanknote(); //thanks note

//*******************************************************
****************************
void swap(char &a,char&b) //function for swapping values
{
char c=a;
a=b;
b=c;
}

//*******************************************************
****************************

void rearr(char st[],int size) // function for rearranging words


randomly
{
randomize();
int randnum= random(size-2)+1;
for(int i=0;i<size-1&&randnum<size-1;i+2,randnum++)
{
swap(st[i],st[randnum]);
}
}

//*******************************************************
****************************

void displayhs() //FUNCTION for displaying the score


{
word o;
ifstream fin("highscore.txt");

gotoxy(1,10);
cout<<"\nPLAYER NAME\t\tSCORE\n\n";
for(int i=0;i<10;++i)
{
fin.read((char*)&o,sizeof(o));
cout<<i+1<<">> "<<o.word<<"\t\t\t"<<o.i<<"\n";
}
fin.close();
getch();
}

//*******************************************************
****************************

void main() //MAIN FUNCTION for wellcome screen


and game menu
{
clrscr();
int gdriver=DETECT,gmode;
initgraph(&gdriver,&gmode,"C:/TC/BGI");

word o;
ifstream fin;
char plname[25],rearanged[15],ans[15];
int score,lev,i;
randomize();
setfillstyle(2,RED);
bar(0,0,getmaxx(),getmaxy());
setcolor(YELLOW);
circle5(getmaxx()/2,getmaxy()/5+100,105);
setcolor(GREEN);
circle5(getmaxx()/2,getmaxy()/5+100,110);
setcolor(CYAN);
circle5(getmaxx()/2,getmaxy()/5+100,115);
textcolor(BLUE);
{ //wellcome screen output TEXT
gotoxy(32,10);
settextstyle(3,0,3);
cout<<"KV NO.2 DELHI CANTT";
gotoxy(34,11);
cout<<"NEW DELHI-110010";
gotoxy(35,13);
cout<<" C++ project ";
gotoxy(39,14);
cout<<" On ";
gotoxy(32,16);
cout<<"WORD GUESSING GAME";
gotoxy(1,26);
cout<<"\n\n\n\n\nCreated By:";
cout<<"Prabhat Kumar Mishra\n";
cout<<"\t\t\t&\n";
cout<<"\t\t\t\Rohan Yadav";
cout<<"\nSubmitted to:";
cout<<"Mrs.Neelam Gupta";
cout<<"\n\n\t\t\t Press any key to continue ...";
}

getch();
main:
load();
setbkcolor(BLACK);
int no=random(10);
clr();
score=0;lev=1;
setcolor(GREEN); //for creating circle OUTSIDE THE
MENU
circle5(getmaxx()/2,getmaxy()/2,195);
setcolor(YELLOW);
circle5(getmaxx()/2,getmaxy()/2,200);
setcolor(RED);
circle5(getmaxx()/2,getmaxy()/2,205);
gotoxy(25,12);
settextstyle(3,0,5);
cout<<"GAME MENU:\n\n"; //TEXT for menue.
gotoxy(26,14);
cout<<"Enter Options";
gotoxy(26,16);
cout<<"1>> To start game:\n";
gotoxy(26,17);
cout<<"2>> To view high scores:";
gotoxy(26,18);
cout<<"3>> To view info:";
gotoxy(26,19);
cout<<"4>> To EXIT : ";
gotoxy(28,21);
cout<<"Your choice: ";
int choice;
cin>>choice;
switch(choice)
{
case 1: //case 1 for playing game
{
game:
load2();
clr();
setbkcolor(BLACK);
gotoxy(2,2);
textcolor(BLACK);
cout<<"\n\n\n\t\t\t\tEnter your NAME : ";
cin>>plname;
clr(); // level one
gotoxy(35,15);
cout<<"LEVEL 1";
delay(2600);
clr();
fin.open("lev1.txt");
for(i=0;i<=no;++i)
fin.read((char *)&o,sizeof(o));
fin.close();
strcpy(rearanged,o.word);
rearr(rearanged,lev+2);
disp(plname,score,lev,rearanged);
cin>>ans;
if(strcmp(ans,o.word)!=0)
{textcolor(BLACK);
gotoxy(32,25);
cout<<"WRONG";
gotoxy(32,26);
cout<<"Correct word is :-";
gotoxy(32,27);
cout<<o.word;
delay(2600);
goto end;
}
gotoxy(32,25);
cout<<"CORRECT";
delay(2600);
score+=lev*5;
++lev;

clr(); //level 2
gotoxy(30,15);
cout<<"LEVEL 2";
delay(3000);
clr();
fin.open("lev2.txt");
for(i=0;i<=no;++i)
fin.read((char *)&o,sizeof(o));
fin.close();
strcpy(rearanged,o.word);
rearr(rearanged,lev+2);
disp(plname,score,lev,rearanged);
cin>>ans;
if(strcmp(ans,o.word)!=0)
{textcolor(WHITE);
gotoxy(32,25);
cout<<"WRONG";
gotoxy(32,26);
cout<<"Correct word is :-";
gotoxy(32,27);
cout<<o.word;
delay(2600);
goto end;
}
gotoxy(32,25);
cout<<"CORRECT";
delay(2600);
score+=lev*5;
++lev;

clr(); //level 3
gotoxy(30,15);
cout<<"LEVEL 3";
delay(2600);
clr();
fin.open("lev3.txt");
for(i=0;i<=no;++i)
fin.read((char *)&o,sizeof(o));
fin.close();
strcpy(rearanged,o.word);
rearr(rearanged,lev+2);
disp(plname,score,lev,rearanged);
cin>>ans;
if(strcmp(ans,o.word)!=0)
{textcolor(WHITE);
gotoxy(32,25);
cout<<"WRONG";
gotoxy(32,26);
cout<<"Correct word is :-";
gotoxy(32,27);
cout<<o.word;
delay(2600);
goto end;
}
gotoxy(32,25);
cout<<"CORRECT";
delay(2600);
score+=lev*5;
++lev;

clr(); //level 4
gotoxy(30,15);
cout<<"LEVEL 4";
delay(2600);
clr();
fin.open("lev4.txt");
for(i=0;i<=no;++i)
fin.read((char *)&o,sizeof(o));
fin.close();
strcpy(rearanged,o.word);
rearr(rearanged,lev+2);
disp(plname,score,lev,rearanged);
cin>>ans;
if(strcmp(ans,o.word)!=0)
{textcolor(WHITE);
gotoxy(32,25);
cout<<"WRONG";
gotoxy(32,26);
cout<<"Correct word is :-";
gotoxy(32,27);
cout<<o.word;
delay(2600);
goto end;
}
gotoxy(32,25);
cout<<"CORRECT";
delay(2600);
score+=lev*5;
++lev;

clr(); // level 5
gotoxy(30,15);
cout<<"LEVEL 5";
delay(2600);
clr();
fin.open("lev5.txt");
for(i=0;i<=no;++i)
fin.read((char *)&o,sizeof(o));
fin.close();
strcpy(rearanged,o.word);
rearr(rearanged,lev+2);
disp(plname,score,lev,rearanged);
cin>>ans;
if(strcmp(ans,o.word)!=0)
{textcolor(WHITE);
gotoxy(32,25);
cout<<"WRONG";
gotoxy(32,26);
cout<<"Correct word is :-";
gotoxy(32,27);
cout<<o.word;
delay(2600);
goto end;
}
gotoxy(32,25);
cout<<"CORRECT";
delay(2600);
score+=lev*5;
++lev;
clr(); //level 6
gotoxy(30,15);
cout<<"LEVEL 6";
delay(2600);
clr();
fin.open("lev6.txt");
for(i=0;i<=no;++i)
fin.read((char *)&o,sizeof(o));
fin.close();
strcpy(rearanged,o.word);
rearr(rearanged,lev+2);
disp(plname,score,lev,rearanged);
cin>>ans;
if(strcmp(ans,o.word)!=0)
{textcolor(WHITE);
gotoxy(32,25);
cout<<"WRONG";
gotoxy(32,26);
cout<<"Correct word is :-";
gotoxy(32,27);
cout<<o.word;
delay(2600);
goto end;
}
gotoxy(32,25);
cout<<"CORRECT";
delay(2600);
score+=lev*5;
++lev;

clr(); // level 7
gotoxy(30,15);
cout<<"LEVEL 7";
delay(2600);
clr();
fin.open("lev7.txt");
for(i=0;i<=no;++i)
fin.read((char *)&o,sizeof(o));
fin.close();
strcpy(rearanged,o.word);
rearr(rearanged,lev+2);
disp(plname,score,lev,rearanged);
cin>>ans;
if(strcmp(ans,o.word)!=0)
{textcolor(WHITE);
gotoxy(32,25);
cout<<"WRONG";
gotoxy(32,26);
cout<<"Correct word is :-";
gotoxy(32,27);
cout<<o.word;
delay(2600);
goto end;
}
gotoxy(32,25);
cout<<"CORRECT";
delay(2600);
score+=lev*5;
++lev;

clr(); //level 8
gotoxy(30,15);
cout<<"LEVEL 8";
delay(2600);
clr();
fin.open("lev8.txt");
for(i=0;i<=no;++i)
fin.read((char *)&o,sizeof(o));
fin.close();
strcpy(rearanged,o.word);
rearr(rearanged,lev+2);
disp(plname,score,lev,rearanged);
cin>>ans;
if(strcmp(ans,o.word)!=0)
{textcolor(WHITE);
gotoxy(32,25);
cout<<"WRONG";
gotoxy(32,26);
cout<<"Correct word is :-";
gotoxy(32,27);
cout<<o.word;
delay(2600);
goto end;
}
gotoxy(32,25);
cout<<"CORRECT";
delay(2600);
score+=lev*5;
++lev;

clr(); //level 9
gotoxy(30,15);
cout<<"LEVEL 9";
delay(2600);
clr();
fin.open("lev9.txt");
for(i=0;i<=no;++i)
fin.read((char *)&o,sizeof(o));
fin.close();
strcpy(rearanged,o.word);
rearr(rearanged,lev+2);
disp(plname,score,lev,rearanged);
cin>>ans;
if(strcmp(ans,o.word)!=0)
{textcolor(WHITE);
gotoxy(32,25);
cout<<"WRONG";
gotoxy(32,26);
cout<<"Correct word is :-";
gotoxy(32,27);
cout<<o.word;
delay(2600);
goto end;
}
gotoxy(32,25);
cout<<"CORRECT";
delay(2600);
score+=lev*5;
++lev;

clr(); // Final level 10


gotoxy(30,15);
cout<<"LEVEL 10";
delay(2600);
clr();
fin.open("lev10.txt");
for(i=0;i<=no;++i)
fin.read((char *)&o,sizeof(o));
fin.close();
strcpy(rearanged,o.word);
rearr(rearanged,lev+2);
disp(plname,score,lev,rearanged);
cin>>ans;
if(strcmp(ans,o.word)!=0)
{textcolor(WHITE);
gotoxy(32,25);
cout<<"WRONG";
gotoxy(32,26);
cout<<"Correct word is :-";
gotoxy(32,27);
cout<<o.word;
delay(2600);
goto end;
}
gotoxy(32,25);
cout<<"CORRECT";
gotoxy(32,26);
cout<<"YOU WIN";
delay(2600);
score+=lev*5;
++lev;
}

end:
{
clr();
gotoxy(1,1);

cout<<"\n\t\t\t GAME OVER"; //here program will


show
//total score made by player

cout<<"\n\n\n\nYour score :- "<<score<<"\n\n\n";


insertsc(score,plname);
displayhs();

opt:
cout<<"Want to play again(y/n): ";
char ch;
cin>>ch;
{ if(ch=='y'||ch=='Y')
goto game;
else if(ch=='n'||ch=='n')
goto main;
else
cout<<"Oops wrong option,Please type correct
one\n";
goto opt; }
}

case 2: // option for displaying total score


{
load2();
clr();
setbkcolor(BLUE);
displayhs();

opt2:
cout<<"Want to play the game(y/n): ";
char ch;
cin>>ch;
{ if(ch=='y'||ch=='Y')
goto game;
else if(ch=='n'||ch=='n')
goto main;
else
cout<<"Oops wrong option,Please type correct
one\n";
goto opt2; }
}

case 3: //option for displaying discription of the game


{
load2();
clr();
setbkcolor(BLUE);
gotoxy(1,1);
setcolor(12);
{
cout<<"\t\t\t\t\tTOPIC=JUMBLE WORDS GAME.";
cout<<"This game is designed by MR.Prabhat Kumar Mishra
as there 12 c++ project.";
cout<<"\n\n * This game is divided into 10 levels ,as you will
move further"
"the level of dif -ficulty will increases\n";
cout<<"\n * In each level,rearranged word will be given"
"and you have to guess the correct word and
then type it.\n";
cout<<"\nIf your enter right word,then you will move to next
level, ";
cout<<"\nElse you are out of the game.";
cout<<"\n\n\t\t\t\t BEST OF LUCK";
}

opt3:
cout<<"\n\n Return to main menu or exit? (y/n): ";
char ch;
cin>>ch;
{ if(ch=='y'||ch=='Y')
goto main;
else if(ch=='n'||ch=='n')
exit(0);
else
cout<<"Oops wrong option,Please type correct one\n\n";
goto opt3; }
}

case 4:
{
thanknote();
delay(20000);
exit(0);
}
}
getch();
}

//*******************************************************
****************************

void clr() //function for clearing output screen


{
for(int i=0;i<100;++i)
cout<<"\n";
}

//*******************************************************
****************************

void circle5(int x,int y,int r) // function for making user defined


circle
{
for(int i=r;i<r+6;++i)
circle(x,y,i);
}

//*******************************************************
****************************

void disp(char plname[],int score,int lev,char rearanged[])


//function for the main game
{setcolor(GREEN);
circle5(getmaxx()/2,getmaxy()/2,95);
setbkcolor(BLUE);
circle5(getmaxx()/4,getmaxy()/4,95);
circle5(getmaxx()*3/4,getmaxy()/4,95);
rectangle(getmaxx()/2-
100,getmaxy()/2+97,getmaxx()/2+100,getmaxx()/2+129);
rectangle(getmaxx()/2-
101,getmaxy()/2+96,getmaxx()/2+99,getmaxx()/2+128);
rectangle(getmaxx()/2-
102,getmaxy()/2+95,getmaxx()/2+98,getmaxx()/2+127);
rectangle(getmaxx()/2-
103,getmaxy()/2+94,getmaxx()/2+97,getmaxx()/2+126);
gotoxy(14,5);
cout<<"Player Name:";
gotoxy(14,8);
cout<<plname;
gotoxy(55,5);
cout<<"Your Score:";
gotoxy(55,8);
cout<<score;
gotoxy(37,11);
cout<<"Level :"<<lev;
gotoxy(35,15);
cout<<"Your word:-";
gotoxy(35,17);
cout<<rearanged;
gotoxy(32,23);
cout<<"Enter correct word:";
gotoxy(32,24);
}

//*******************************************************
****************************

void insertsc(int score,char name[]) //function for inserting score


in a file
{
word o1,o2;
strcpy(o2.word,name);
o2.i=score;
ifstream fi("highscore.txt");
ofstream fo("temp.txt");
for(int i=0;i<10;++i)
{fi.read((char*)&o1,sizeof(o1));
if(o1.i>score)
fo.write((char*)&o1,sizeof(o1));
if(o1.i<=score)
{fo.write((char*)&o2,sizeof(o2));
fo.write((char*)&o1,sizeof(o1));
for(int j=i+1;j<10;++j)
{fi.read((char*)&o1,sizeof(o1));
fo.write((char*)&o1,sizeof(o1));
}
goto last;
}
}
last:
fi.close();
fo.close();
remove("highscore.txt");
rename("temp.txt","highscore.txt");
}

//*******************************************************
****************************
void thanknote() //function for thanking the user for using this
game
{
clr();
setbkcolor(GREEN);
gotoxy(1,1);
cout<<"\n\n\n\n\n\
THANK YOU for using this program.\n\
--Created by:\n\
Prabhat Kumar Mishra\n\
XII th ";
}

//*******************************************************
****************************

void load() //main loading function


{
int i,gd=DETECT,gm;
initgraph(&gd,&gm,"C:/TC/BGI");
setbkcolor(BLACK);
setcolor(WHITE);
for(i=35;i<555;i++)
{
line(25+i,170,25+i,200);
}

for(i=35;i<555;i++)
{
setcolor(GREEN); //** this is for green filling in the
loading bar.
line(25+i,170,25+i,200); //** this is for increasing the size of
green bar.
delay(5);

setcolor(WHITE); //** this is for the text color.


settextstyle(SMALL_FONT,0,16); //** this is for the font style.
outtextxy(110,220,"Loading Menu"); //** text that you want to
show.
delay(2); //** delay for some seconds.

setcolor(rand()%16); //** this is for color full loading dots.


settextstyle(SMALL_FONT,HORIZ_DIR,16);
outtextxy(400,220,"......"); //** forshowing the dots.
delay(10);
}

//*******************************************************
****************************

void load2() //function for loading the options of menue


{
int i,gd=DETECT,gm;
initgraph(&gd,&gm,"C:/TC/BGI");
setbkcolor(BLACK);
setcolor(WHITE);
for(i=35;i<300;i++)
{
line(25+i,170,25+i,200);
}

for(i=35;i<300;i++)
{
setcolor(YELLOW); //** this is for yellow filling in the
loading bar.
line(25+i,170,25+i,200); //** this is for increasing the size of
yellow bar.
delay(5);

setcolor(WHITE); //** this is for the text color.


settextstyle(SMALL_FONT,0,16); //** this is for the font style.
outtextxy(60,220,"Loading"); //** text that you want to show.
delay(5); //** delay for some seconds.

setcolor(rand()%16); //** this is for color full loading dots.


settextstyle(SMALL_FONT,HORIZ_DIR,16);
outtextxy(250,220,"....."); //** forshowing the dots.
delay(10);
}
}

//*******************************************************
****************************

/*END OF CODING*/

//*******************************************************
****************************
SCREENSHOTS
WELLCOME SCREEN:

LOADING SCREEN:
game menu:

LOADING SCREEN AFTER OPTION 1:


GAME ASKING FOR NAME:

LEVEL 1 SCREEN:
Level 2 screen:
LEVEL 3 SCREEN:

OPTION 2,VWEING SCORES:


OPTION 3,game info:

Option 4,thank note:


BIBLIOGRAPHY

 Sumita Arora – Computer Science with


C++.

 E. Balagurusami – C++.

 Robert Lafore – Turbo C++.

 Google.

You might also like