SlideShare a Scribd company logo
UNDER THE GUIDANCE OF:
MRS.JINI
SUBMITTED BY:
G.MEENALOSHINI
CLASS XII A
REGISTER NO:
Acknowledgement
In the accomplishment of this project successfully, many people have
best owned upon me their blessings and the heart pledged support.
This time I am utilising to thank all the people who have been
concerned with this project.
Firstly, I would thank god for being able to complete this project with
triumph. Then I would like to thank my parents and family members
who helped me with their valuable suggestions.
Secondly, I would like to express my special thanks of gratitude to my
computer-science facilitator Mrs.Jini as well as our principal Mrs.G.Jigi
Mol who gave me the golden opportunity to do this wonderful project
on the topic ”TETRIS ROYALE-GAME”, which also helped me in doing a
lot of research and I came to know about so many new things.
Last but not the least I would like to thank all my friends and
classmates for their guidance in various phases of the completion of
the project.
Regards,
G.Meenaloshini
TABLE OF CONTENTS
S.NO TOPICS
1. INTRODUCTION
2.
SYSTEM OBJECTIVES & AIM OF THE
PROJECT
3. HARDWARE & SOFTWARE REQUIREMENTS
4. THEORY
5. HEADER FILES INCLUDED
6. SOURCE CODE
7. OUTPUT SCREENS
8. BIBLIOGRAPHY
INTRODUCTION
Tetris game code with sounds, high scores and gravity. It is intended as a learning tool with its
extensive comments and laid out code with easy get-around and simple functions. The code
explores things such as loops and if statements, patch, save/load, GUI techniques, call-backs and
sound generation.
Description
“Tetris is a game involving dropping blocks. Points are scored for each block which comes to rest
on the gradually collecting pile of blocks. Different blocks in different orientations score different
points. The goal is to prevent the pile from reaching the top and ending the game. Whenever a row
of blocks is completely filled, it is removed and all blocks above it drop down to fill the empty
row.”
Game Walkthrough
A random sequence of tetrominoes (sometimes called "tetrads" in older versions)—shapes
composed of four square blocks each—fall down the playing field (a rectangular vertical shaft,
called the "well" or "matrix"). The object of the game is to manipulate these tetrominoes, by moving
each one sideways and rotating it by 90 degree units, with the aim of creating a horizontal line of
blocks without gaps. When such a line is created, it disappears, and any block above the deleted
line will fall. As the game progresses, the tetrominoes fall faster, and the game ends when the
stack of tetrominoes reaches the top of the playing field and no new tetrominoes are able to enter.
Game Objectives
 Complete levels by clearing a set number of lines
 Clear lines to stop stack from reaching top of screen
 Clear more lines at once for higher point values
Increasing difficulty
As players complete more levels, the difficulty of the game increases. Not only do players keep
the lines that they did not clear from the previous levels, but pieces also begin to fall faster, forcing
the player to think faster in order to clear lines.
SYSTEM OBJECTIVES & AIM OF THE PROJECT
The Tetris Effect
The Tetris Effect is a catchy term that players use to
describe the way they are inspired by the game and see
Tetriminos in everyday situations. Because Tetris, like the
real world, challenges players to make order out of chaos
using a specific organization system, the game
components translate easily into lifestyle interpretations.
Whether you're packing the trunk of your car,
loading a dishwasher, or organizing your
shelves, you're likely thinking about how each
object will fit together strategically with
minimal empty space. This is the Tetris Effect!
Learning Objectives
 Recognize spatial requirements to clear lines by rotating and dropping pieces
 Plan ahead by setting up lines for easy clearing
 Adapt to faster falling pieces
Educational Outcomes
Tetris has been one the most recognized and enjoyed video games since its creation 25 years ago. Even today the game still
enjoys popularity as it has gained new interest through platforms such as the iPhone and Facebook. Because of its extensive
social influences, many researchers have attempted measure the effects of Tetris, each with varying results.
Spatial ability is the first area of learning that most people would point to improvement. However in two experiments
conducted by Valerie Sims and Richard Mayer, researchers found that spatial expertise is highly-domain specific. The
experiment compared skilled Tetris players, non-Tetris players, and participants who played Tetris for 12 hours. Researchers
discovered that Tetris players perform better in spatial ability than non-Tetris players when using identical or similar shapes to
Tetris pieces. Tetris players were able to mentally place these shapes faster and often rotated the shapes in alternative
ways. However, Tetris and non-Tetris players displayed little difference when performing spatial ability tests with non-Tetris
shapes.
Researchers at the Mind Research Network discovered differing results. Over a three-month period, researchers studied two
groups of adolescent girls, one group consistently played Tetris while the other did not. After analyzing the girls’ MRIs after
three months, researchers found that the girls who played Tetris displayed changes in their cortex. The increase in cortical
thickness is correlated with an increase in grey matter, which leads to greater brain efficiency when completing complex tasks.
HARDWARE REQUIREMENT
COMPONENTS REQUIREMENTS
Processor Intel(R) Pentium(R) CPU N3520 @
2.16GHz
Ram 2 GB
Hard disk drive 465 GB
Graphics memory 775 MB
SOFTWARE ENVIRONMENT
COMPONENTS REQUIREMENTS
Os 64-bit operating
system(WINDOWS 7)
Graphics Intel(R) HD Graphics
Programming Language TURBO C7 (C++)
FILES GENERATED
Text file: tetris.txt
Programme file: tetris.cpp
Object file: tetris.obj
Execution file: tetris.exe
C++ is a multi-paradigm programming language that supports object-oriented programming (OOP),
created by Bjarne Stroustrup in 1983 at Bell Labs, C++ is an extension(superset) of C programming and
the programs are written in C language can run in C++ compilers.
C++ is used by programmers to create computer software. It is used to create general systems
software, drivers for various computer devices, software for servers and software for specific applications
and also widely used in the creation of video games.
USES:
C++ is used by many programmers of different types and coming from different fields. C++ is mostly used
to write device driver programs, system software, and applications that depend on direct hardware
manipulation under real-time constraints. It is also used to teach the basics of object-oriented features
because it is simple and is also used in the fields of research. Also, many primary user
interfaces and system files of Windows and Macintosh are written using C++. So, C++ is a popular,
strong and frequently used programming language of this modern programming era.
FEATURES:
The main focus remains on data rather than
procedures.
Object-oriented programs are segmented into
parts called objects.
Data structures are designed to categorize the
objects.
Data member and functions are tied together as a
data structure.
Data can be hidden and cannot be accessed by
external functions using access specifier.
Objects can communicate among themselves
using functions.
New data and functions can be easily added
anywhere within a program whenever required.
Since this is an object-oriented programming language, it follows a bottom up approach, i.e. the
execution of codes starts from the main which resides at the lower section and then based on the
member function call the working is done from the classes.
Object Oriented Programming in C++
Object Oriented programming is a programming style that is associated with the concept of Class, Objects and
various other concepts revolving around these two, like Inheritance, Polymorphism, Abstraction, Encapsulation etc.
Encapsulation
Encapsulationis a process of combining data and
function into a single unit like capsule. This is to avoid
the access of private data members from outside the
class. To achieve encapsulation, we make all data
members of class private and create public functions,
using them we can get the values from these data
members or set the value to these data members.
Abstraction:
Abstractionis a process of hiding irrelevant details from
user.
Inheritance
Inheritanceis a feature using which an object of child class acquires the properties of parent class.
Polymorphism
Function overloadingand Operator
overloading are examples of polymorphism.
Polymorphism is a feature using which an
object behaves differently in different
situation.
MODULARITY:
Modularity: the written program can be splitted up in to modules by using classes and each class can
be considered as a module.
File Handling using File Streams in C++
File represents storage medium for storing data or information. Streams refer to sequence of bytes. In
Files we store data i.e. text or binary data permanently and use these data to read or write in the form of
input output operations by transferring bytes of data. So we use the term File Streams/File handling. We
use the header file <fstream>
 ofstream: It represents output Stream and this is used for writing in
files.
 ifstream: It represents input Stream and this is used for reading
from files.
 fstream: It represents both output Stream and input Stream. So it
can read from files and write to files.
Operations in File Handling:
 Creating a file: open()
 Reading data: read()
 Writing new data: write()
 Closing a file: close()
SPECIAL OPERATIONS IN A FILE
There are few important functions to be used with file streams like:
 tellp() - It tells the current position of the put pointer.
Syntax: filepointer.tellp()
 tellg() - It tells the current position of the get pointer.
Syntax: filepointer.tellg()
 seekp() - It moves the put pointer to mentioned location.
Syntax: filepointer.seekp(no of bytes,reference mode)
 seekg() - It moves get pointer(input) to a specified
location.
Syntax: filepointer.seekg((no of bytes,reference point)
 put() - It writes a single character to file.
 get() - It reads a single character from file.
Header files included
///PreDefined HeaderFile
#include<iostream.h> Used as a stream of Input and Output.
#include<graphics.h> C graphics using graphics.h functions can be used to draw
different shapes, display text in different fonts, change colors and many more.
#include<stdlib.h> Perform standard utility functions like dynamic memory
allocation.
#include<conio.h> Perform console input and console output operations like clrscr()
to clear the screen and getch() to get the character from the keyboard.
#include<process.h> C header file which contains function declarations and macros
used in working with threads and processes.
#include<dos.h> header file of C language contains functions for handling
interrupts, producing sound, date and time functions etc.
#include<string.h> Perform string manipulation operations like strlen and strcpy.
#include<fstream.h> Contains function prototypes for functions that perform input
from files on disk and output to files on disk.
///User Defined Header File(modularity concept)
#include"C:TCbinsecond.cpp"
#include"C:TCincludekeyb.h"
#include"C:TCbinmainclas.cpp"
#include"C:TCbinlineobj.cpp"
#include"C:TCbinsqureobj.cpp"
#include"C:TCbintemp.cpp"
SOURCE CODE
SOURCE CODE
#include<iostream.h> #include<graphics.h> #include<stdlib.h> #include<conio.h> #include<process.h> #include<dos.h>
#include<string.h> #include<fstream.h>
#include"C:TCbinsecond.cpp" #include"C:TCincludekeyb.h"
enum BOOL{FALSE=0,TRUE,END,OVER};
enum POS{SLEEP=1001,STANDING,LLightSleep,LLightStanding,RLightSleep,RLightStanding,SQURE,
Cross1,Cross2,Cross3,Cross4,LL1,LL2,LL3,LL4};
const short BOX=180;
const ROW=20;
const COL=15;
struct board{
short xy[20][15];
};
struct coordinate{
short x,y;
};
class MainClass
{ protected:
static board Board; coordinate ShapeCoordinate[4];coordinate ShapeTemp[4];
char Player[20];
public:
static unsigned long LineCleared,OLineClear,Score,Level;
static int Speed;
static short id;
POS pos;
MainClass();
void showarray();
void StartMainClass();
void StartObject(short);
virtual void RotateObject(){};
BOOL MoveObject(short);
BOOL DetectCollision(short,coordinate []);
virtual void PutNewObjectOnBoard(BOOL){};
void RemoveLine(int);
void MsgBox(int,char *,BOOL);
BOOL CheckBoard(int[],coordinate[]);
void CheckForLine();
void DrawBrick(int,int,int);
void UpdateScore(); ///Update Score
void DrawScreen(); ///Drawbackground ANd other nessecary thing
void SoundDrop();
void DisplayNextBrick(short);
void PreScreen();
};
board MainClass::Board;
unsigned long MainClass::LineCleared;
unsigned long MainClass::OLineClear;
unsigned long MainClass::Level;
unsigned long MainClass::Score;
short MainClass::id;
int MainClass::Speed;
#include"C:TCbinmainclas.cpp"
#include"C:TCbinlineobj.cpp"
#include"C:TCbinsqureobj.cpp"
#include"C:TCbintemp.cpp"
class ObjectCross:public MainClass
{
public:
void PutNewObjectOnBoard(BOOL bDraw);
void RotateObject();
};
class ObjectLL:public MainClass
{
public:
void PutNewObjectOnBoard(BOOL bDraw);
void RotateObject();
};
class ObjectRL:public MainClass
{
public:
void PutNewObjectOnBoard(BOOL bDraw);
void RotateObject();
};
class ObjectLLighting:public MainClass
{
public:
void PutNewObjectOnBoard(BOOL bDraw);
void RotateObject();
};
class ObjectRLighting:public MainClass
{
public:
void PutNewObjectOnBoard(BOOL bDraw);
void RotateObject();
};
void main()
{
BOOL Check;
//dynamically alloting memory
MainClass *MainObject=new MainClass;
int Counter=0;
short n;
if(MainObject==NULL)
{
cout<<"Memory Allocation Error";
exit(0);
}
setpalette(BROWN,62);
// MainObject->OLineClear=MainObject->LineCleared;
//shapes deleclartion
ObjectLine Line;
ObjectSqure Squre;
ObjectLLighting LLight;
ObjectRLighting RLight;
ObjectCross Cross;
ObjectLL Ll;
ObjectRL Rl;
MainObject->StartMainClass();
randomize();//inisiating Random no generator
MainObject=&Line;
MainObject->pos=SLEEP;
MainObject->PutNewObjectOnBoard(TRUE);
MainObject->id=0;
MainObject->StartObject(0);
int ch=0;
short ChoiceOfObject;
n=1;
MainObject->DisplayNextBrick(n);
while(ch!=EXIT)
{
if(Check==OVER)
{
cleardevice();
settextstyle(1,0,6);setcolor(RED);
outtextxy(150,100,"GAME OVER");
delay(200);
ch=EXIT;
}
if(Check==END)
{
while(kbhit()) getch();
MainObject->MsgBox(200,"",TRUE);
Check=TRUE;
for(int o=0;o<5;o++){
MainObject->CheckForLine();
delay(50);
}
if((MainObject->OLineClear-MainObject->LineCleared)>0)
{
if(MainObject->OLineClear%20==0)
{
if(MainObject->LineCleared>1){
MainObject->Level++;
MainObject->Speed=MainObject->Speed -5;
MainObject->MsgBox(210,"level Change",TRUE);
sound(100);
delay(200);
MainObject->UpdateScore();
}
}
}
switch((MainObject->OLineClear)-(MainObject->LineCleared))
{
case 1:MainObject->Score+=10;
MainObject->LineCleared++;
MainObject->MsgBox(210,"1 Line",FALSE);
MainObject->MsgBox(240,"Nice!!",FALSE);
break;
case 2:MainObject->Score+=30;
MainObject->LineCleared+=2;
MainObject->MsgBox(210,"2 Line",FALSE);
MainObject->MsgBox(240,"Very Nice!!",FALSE);
break;
case 3:MainObject->Score+=60;
MainObject->LineCleared+=3;
MainObject->MsgBox(210,"3 Line",FALSE);
MainObject->MsgBox(240,"Wow!!",FALSE);
break;
case 4:MainObject->Score+=100;
MainObject->LineCleared+=4;
MainObject->MsgBox(210,"4 Line",FALSE);
MainObject->MsgBox(240,"Excellent",FALSE);
MainObject->MsgBox(270,"100 pt Bonus",FALSE);
break;
}
MainObject->UpdateScore();
ChoiceOfObject=n;
MainObject->id=ChoiceOfObject;
switch(ChoiceOfObject)
{
case 0: MainObject=&Line;
MainObject->pos=SLEEP;
break;
case 1: MainObject=&Squre;
MainObject->pos=SQURE;
break;
case 2: MainObject=&LLight;
MainObject->pos=LLightStanding;
break;
case 3: MainObject=&Ll;
MainObject->pos=Cross1;
break;
case 4: MainObject=&Rl;
MainObject->pos=LL1;
break;
case 5: MainObject=&RLight;
MainObject->pos=RLightStanding;
break;
case 6: MainObject=&Cross;
MainObject->pos=Cross1;
break;
}
MainObject->PutNewObjectOnBoard(TRUE);
MainObject->StartObject(ChoiceOfObject);
n=rand()%7;
MainObject->DisplayNextBrick(n);
// MainObject->showarray();
while(kbhit()) getch();
}
if(++Counter >= MainObject->Speed) {
Counter=0;
Check=MainObject->MoveObject(KEY_DOWN);
MainObject->SoundDrop();
}
delay(8);
while(kbhit())
{
ch=getch();
switch(ch)
{
case KEY_UP:Check=MainObject->MoveObject(KEY_UP);
break;
case KEY_DOWN:Check=MainObject->MoveObject(KEY_DOWN);
MainObject->Score+=1;
MainObject->UpdateScore();
break;
case KEY_RIGHT:Check=MainObject->MoveObject(KEY_RIGHT);
break;
case KEY_ENTER: MainObject->MsgBox(210,"Pause",TRUE);
getch();
MainObject->MsgBox(210,"",TRUE);
break;
case KEY_LEFT:Check=MainObject->MoveObject(KEY_LEFT);
break;
case KEY_ESC:
ch=EXIT;
//exit(0);
} //end switch
MainObject->SoundDrop();
delay(5);
} //end while
}
delete MainObject;
closegraph();
restorecrtmode();
getch();
}
MainClass::MainClass()
{ Speed=100;
}
void MainClass::StartMainClass()
{ int GD=DETECT,GM;
initgraph(&GD,&GM,"C:TCbgi");
cleardevice();
PreScreen();
LineCleared=Score=0;
DrawScreen();
UpdateScore();}
void MainClass::SoundDrop() {for(int i=5; i<10; i++)
{sound(200*i)
delay(1);
nosound();
} }
void MainClass::StartObject(short id)
{ coordinate temp[4];
for(int i=0;i<4;i++)
{
temp[i]=ShapeCoordinate[i];
}
switch(id)
{ case 0:for(i=0;i<4;i++)
{ Board.xy[ShapeCoordinate[i].x][ShapeCoordinate[i].y]=RED;
DrawBrick(60+temp[i].y*20,temp[i].x*20+40,RED);
}
break;
case 1: for(i=0;i<4;i++)
{ Board.xy[ShapeCoordinate[i].x][ShapeCoordinate[i].y]=GREEN;
DrawBrick(60+temp[i].y*20,temp[i].x*20+40,GREEN);
}
break;
case 2: for(i=0;i<4;i++)
{ Board.xy[ShapeCoordinate[i].x][ShapeCoordinate[i].y]=BLUE;
DrawBrick(60+temp[i].y*20,temp[i].x*20+40,BLUE);
}
break;
case 3:
for(i=0;i<4;i++)
{ Board.xy[ShapeCoordinate[i].x][ShapeCoordinate[i].y]=MAGENTA;
DrawBrick(60+temp[i].y*20,temp[i].x*20+40,MAGENTA);
}
break;
case 4: for(i=0;i<4;i++)
{ Board.xy[ShapeCoordinate[i].x][ShapeCoordinate[i].y]=CYAN;
DrawBrick(60+temp[i].y*20,temp[i].x*20+40,CYAN); } break;
case 5: for(i=0;i<4;i++)
{ Board.xy[ShapeCoordinate[i].x][ShapeCoordinate[i].y]=BROWN;
DrawBrick(60+temp[i].y*20,temp[i].x*20+40,BROWN); }
break;
case 6: for(i=0;i<4;i++)
{
Board.xy[ShapeCoordinate[i].x][ShapeCoordinate[i].y]=DARKGRAY;
DrawBrick(60+temp[i].y*20,temp[i].x*20+40,DARKGRAY);
}
break;
case 7: for(i=0;i<4;i++)
{
Board.xy[ShapeCoordinate[i].x][ShapeCoordinate[i].y]=BLACK;
DrawBrick(60+temp[i].y*20,temp[i].x*20+40,BLACK);
}
}
}
void ObjectRL::PutNewObjectOnBoard(BOOL bDraw)
{
ShapeTemp[0].x=0;
ShapeTemp[1].x=1;
ShapeTemp[2].x=1;
ShapeTemp[3].x=1;
ShapeTemp[0].y=7;
ShapeTemp[1].y=5;
ShapeTemp[2].y=6;
ShapeTemp[3].y=7;
if(bDraw==TRUE)
for(int i=0;i<4;i++)
ShapeCoordinate[i]=ShapeTemp[i];
}
void ObjectLL::PutNewObjectOnBoard(BOOL bDraw)
{
ShapeTemp[0].x=0;
ShapeTemp[1].x=1;
ShapeTemp[2].x=1;
ShapeTemp[3].x=1;
ShapeTemp[0].y=5;
ShapeTemp[1].y=5;
ShapeTemp[2].y=6;
ShapeTemp[3].y=7;
if(bDraw==TRUE)
for(int i=0;i<4;i++)
ShapeCoordinate[i]=ShapeTemp[i];
}
void ObjectCross::PutNewObjectOnBoard(BOOL bDraw)
{
ShapeTemp[0].x=0;
ShapeTemp[1].x=1;
ShapeTemp[2].x=1;
ShapeTemp[3].x=1;
ShapeTemp[0].y=6;
ShapeTemp[1].y=5;
ShapeTemp[2].y=6;
ShapeTemp[3].y=7;
if(bDraw==TRUE)
for(int i=0;i<4;i++)
ShapeCoordinate[i]=ShapeTemp[i];
}
void ObjectLLighting::PutNewObjectOnBoard(BOOL bDraw)
{
ShapeTemp[0].x=0;
ShapeTemp[1].x=1;
ShapeTemp[2].x=1;
ShapeTemp[3].x=2;
ShapeTemp[0].y=5;
ShapeTemp[1].y=5;
ShapeTemp[2].y=6;
ShapeTemp[3].y=6;
if(bDraw==TRUE)
for(int i=0;i<4;i++)
ShapeCoordinate[i]=ShapeTemp[i];
}
void ObjectRLighting::PutNewObjectOnBoard(BOOL bDraw)
{
ShapeTemp[0].x=0;
ShapeTemp[1].x=1;
ShapeTemp[2].x=1;
ShapeTemp[3].x=2;
ShapeTemp[0].y=6;
ShapeTemp[1].y=6;
ShapeTemp[2].y=5;
ShapeTemp[3].y=5;
if(bDraw==TRUE)
for(int i=0;i<4;i++)
ShapeCoordinate[i]=ShapeTemp[i];
}
BOOL MainClass::MoveObject(short key)
{
coordinate temp[4];
for(int i=0;i<4;i++)
{
temp[i]=ShapeCoordinate[i];
}
StartObject(7);
if((DetectCollision(key,temp)==END)||(DetectCollision(key,temp)==FALSE))
{
StartObject(id);
for(i=4;i<9;i++)
{
if (Board.xy[1][i]!=0)return OVER;
}
return(DetectCollision(key,temp));
}
switch(key)
{
case KEY_UP:
RotateObject();
break;
case KEY_DOWN:
ShapeCoordinate[0].x+=1;
ShapeCoordinate[1].x+=1;
ShapeCoordinate[2].x+=1;
ShapeCoordinate[3].x+=1;
break;
case KEY_RIGHT:
ShapeCoordinate[0].y +=1;
ShapeCoordinate[1].y +=1;
ShapeCoordinate[2].y +=1;
ShapeCoordinate[3].y +=1;
break;
case KEY_LEFT:
ShapeCoordinate[0].y-=1;
ShapeCoordinate[1].y-=1;
ShapeCoordinate[2].y-=1;
ShapeCoordinate[3].y-=1;
break;
}
StartObject(id);
return TRUE;
}
BOOL MainClass::DetectCollision(short key,coordinate temp1[4])
{
coordinate temp[4];
for(int i=0;i<4;i++)
{
temp[i]=ShapeCoordinate[i];
}
switch(key)
{
case KEY_UP: if(temp1[0].x>=19)return FALSE;
if(temp1[1].x>=19)return FALSE;
if(temp1[2].x>=19)return FALSE;
if(temp1[3].x>=19)return FALSE;
if(temp1[0].y>14)return FALSE;
if(temp1[1].y>14)return FALSE;
if(temp1[2].y>14)return FALSE;
if(temp1[3].y>14)return FALSE;
if(temp1[0].y<0)return FALSE;
if(temp1[1].y<0)return FALSE;
if(temp1[2].y<0)return FALSE;
if(temp1[3].y<0)return FALSE;
if(Board.xy[temp1[0].x][temp1[0].y]!=0)return FALSE;
if(Board.xy[temp1[1].x][temp1[1].y]!=0)return FALSE;
if(Board.xy[temp1[2].x][temp1[2].y]!=0)return FALSE;
if(Board.xy[temp1[3].x][temp1[3].y]!=0)return FALSE;
break;
case KEY_DOWN:
if(temp[0].x==19)return END;
if(temp[1].x==19)return END;
if(temp[2].x==19)return END;
if(temp[3].x==19)return END;
if(temp[0].x==0)
{
if(Board.xy[2][temp[0].y]!=0)return OVER;
if(Board.xy[2][temp[1].y]!=0)return OVER;
if(Board.xy[2][temp[2].y]!=0)return OVER;
if(Board.xy[2][temp[3].y]!=0)return OVER;
}
temp[0].x+=1;
temp[1].x+=1;
temp[2].x+=1;
temp[3].x+=1;
if(Board.xy[temp[0].x][temp[0].y]!=0)return END;
if(Board.xy[temp[1].x][temp[1].y]!=0)return END;
if(Board.xy[temp[2].x][temp[2].y]!=0)return END;
if(Board.xy[temp[3].x][temp[3].y]!=0)return END;
//for game over
break;
case KEY_RIGHT: if(temp[0].y==14)return FALSE;
if(temp[1].y==14)return FALSE;
if(temp[2].y==14)return FALSE;
if(temp[3].y==14)return FALSE;
temp[0].y+=1;
temp[1].y+=1;
temp[2].y+=1;
temp[3].y+=1;
if(Board.xy[temp[0].x][temp[0].y]!=0)return FALSE;
if(Board.xy[temp[1].x][temp[1].y]!=0)return FALSE;
if(Board.xy[temp[2].x][temp[2].y]!=0)return FALSE;
if(Board.xy[temp[3].x][temp[3].y]!=0)return FALSE;
break;
case KEY_LEFT: if(temp[0].y==0)return FALSE;
if(temp[1].y==0)return FALSE;
if(temp[2].y==0)return FALSE;
if(temp[3].y==0)return FALSE;
temp[0].y-=1;
temp[1].y-=1;
temp[2].y-=1;
temp[3].y-=1;
if(Board.xy[temp[0].x][temp[0].y]!=0)return FALSE;
if(Board.xy[temp[1].x][temp[1].y]!=0)return FALSE;
if(Board.xy[temp[2].x][temp[2].y]!=0)return FALSE;
if(Board.xy[temp[3].x][temp[3].y]!=0)return FALSE;
break;
}
return TRUE;
}
void ObjectLLighting::RotateObject()
{
coordinate temp[4];
for(int i=0;i<4;i++)
temp[i]=ShapeCoordinate[i];
if(pos==LLightSleep)
{
temp[0].y=temp[0].y+1;
temp[0].x=temp[0].x-2;
temp[1].y=temp[1].y;
temp[1].x=temp[1].x-1;
temp[2].y=temp[2].y+1;
temp[2].x=temp[2].x;
temp[3].y=temp[3].y;
temp[3].x=temp[3].x+1;
BOOL ch=DetectCollision(KEY_UP,temp);//checking new position is valid
if(ch==FALSE)return;
pos=LLightStanding;
}
else if(pos==LLightStanding)
{
temp[0].y=temp[0].y-1;
temp[0].x=temp[0].x+2;
temp[1].y=temp[1].y;
temp[1].x=temp[1].x+1;
temp[2].y=temp[2].y-1;
temp[2].x=temp[2].x;
temp[3].y=temp[3].y;
temp[3].x=temp[3].x-1;
BOOL ch=DetectCollision(KEY_UP,temp);//checking new position is valid
if(ch==FALSE)return;
pos=LLightSleep;
}
for(i=0;i<4;i++)
ShapeCoordinate[i]=temp[i];//sending information back to main shape
}
void ObjectRLighting::RotateObject()
{
coordinate temp[4];
for(int i=0;i<4;i++)
temp[i]=ShapeCoordinate[i];
if(pos==RLightSleep)
{
temp[0].y=temp[0].y-1;
temp[0].x=temp[0].x-2;
temp[1].y=temp[1].y;
temp[1].x=temp[1].x-1;
temp[2].y=temp[2].y-1;
temp[2].x=temp[2].x;
temp[3].y=temp[3].y;
temp[3].x=temp[3].x+1;
BOOL ch=DetectCollision(KEY_UP,temp);//checking new position is valid
if(ch==FALSE)return;
pos=RLightStanding;
}
else
if(pos==RLightStanding)
{
temp[0].y=temp[0].y+1;
temp[0].x=temp[0].x+2;
temp[1].y=temp[1].y;
temp[1].x=temp[1].x+1;
temp[2].y=temp[2].y+1;
temp[2].x=temp[2].x;
temp[3].y=temp[3].y;
temp[3].x=temp[3].x-1;
BOOL ch=DetectCollision(KEY_UP,temp);//checking new position is valid
if(ch==FALSE)return;
pos=RLightSleep;
}
for(i=0;i<4;i++)
ShapeCoordinate[i]=temp[i];//sending information back to main shape
}
void ObjectCross::RotateObject()
{
coordinate temp[4];
for(int i=0;i<4;i++)
temp[i]=ShapeCoordinate[i];
BOOL ch;
switch(pos)
{
case Cross1:
temp[0].x=temp[0].x+1;
temp[0].y=temp[0].y+1;
temp[1].x=temp[1].x-1;
temp[1].y=temp[1].y+1;
temp[2].x=temp[2].x;
temp[2].y=temp[2].y;
temp[3].x=temp[3].x+1;
temp[3].y=temp[3].y-1;
ch=DetectCollision(KEY_UP,temp);//checking new position is valid
if(ch==FALSE)return;
pos=Cross2;
break;
case Cross2:
temp[0].x=temp[0].x+1;
temp[0].y=temp[0].y-1;
temp[1].x=temp[1].x+1;
temp[1].y=temp[1].y+1;
temp[2].x=temp[2].x;
temp[2].y=temp[2].y;
temp[3].x=temp[3].x-1;
temp[3].y=temp[3].y-1;
ch=DetectCollision(KEY_UP,temp);//checking new position is valid if(ch==FALSE)return;
pos=Cross3;
break;
case Cross3:
temp[0].x=temp[0].x-1;
temp[0].y=temp[0].y-1;
temp[1].x=temp[1].x+1;
temp[1].y=temp[1].y-1;
temp[2].x=temp[2].x;
temp[2].y=temp[2].y;
temp[3].x=temp[3].x-1;
temp[3].y=temp[3].y+1;
ch=DetectCollision(KEY_UP,temp);//checking new position is valid
if(ch==FALSE)return;
pos=Cross4;
break;
case Cross4:
temp[0].x=temp[0].x-1;
temp[0].y=temp[0].y+1;
temp[1].x=temp[1].x-1;
temp[1].y=temp[1].y-1;
temp[2].x=temp[2].x;
temp[2].y=temp[2].y;
temp[3].x=temp[3].x+1;
temp[3].y=temp[3].y+1;
ch=DetectCollision(KEY_UP,temp);//checking new position is valid
if(ch==FALSE)return;
pos=Cross1;
break;
}
for(i=0;i<4;i++)
ShapeCoordinate[i]=temp[i];//sending information back to main shape
}
void ObjectRL::RotateObject()
{
coordinate temp[4];
for(int i=0;i<4;i++)
temp[i]=ShapeCoordinate[i];
BOOL ch;
switch(pos)
{
case LL1:
temp[0].x=temp[0].x+2;
temp[0].y=temp[0].y;
temp[1].x=temp[1].x-1;
temp[1].y=temp[1].y+1;
temp[2].x=temp[2].x;
temp[2].y=temp[2].y;
temp[3].x=temp[3].x+1;
temp[3].y=temp[3].y-1;
ch=DetectCollision(KEY_UP,temp);//checking new position is valid
if(ch==FALSE)return;
pos=LL2;
break;
case LL2:
temp[0].x=temp[0].x;
temp[0].y=temp[0].y-2;
temp[1].x=temp[1].x+1;
temp[1].y=temp[1].y+1;
temp[2].x=temp[2].x;
temp[2].y=temp[2].y;
temp[3].x=temp[3].x-1;
temp[3].y=temp[3].y-1;
ch=DetectCollision(KEY_UP,temp);//checking new position is valid if(ch==FALSE)return;
pos=LL3;
break;
case LL3:
temp[0].x=temp[0].x-2;
temp[0].y=temp[0].y;
temp[1].x=temp[1].x+1;
temp[1].y=temp[1].y-1;
temp[2].x=temp[2].x;
temp[2].y=temp[2].y;
temp[3].x=temp[3].x-1;
temp[3].y=temp[3].y+1;
ch=DetectCollision(KEY_UP,temp);//checking new position is valid
if(ch==FALSE)return;
pos=LL4;
break;
case LL4:
temp[0].x=temp[0].x;
temp[0].y=temp[0].y+2;
temp[1].x=temp[1].x-1;
temp[1].y=temp[1].y-1;
temp[2].x=temp[2].x;
temp[2].y=temp[2].y;
temp[3].x=temp[3].x+1;
temp[3].y=temp[3].y+1;
ch=DetectCollision(KEY_UP,temp);//checking new position is valid
if(ch==FALSE)return;
pos=LL1;
break;
}
for(i=0;i<4;i++)
ShapeCoordinate[i]=temp[i];//sending information back to main shape
}
void ObjectLL::RotateObject()
{
coordinate temp[4];
for(int i=0;i<4;i++)
temp[i]=ShapeCoordinate[i];
BOOL ch;
switch(pos)
{
case Cross1:
temp[0].x=temp[0].x;
temp[0].y=temp[0].y+2;
temp[1].x=temp[1].x-1;
temp[1].y=temp[1].y+1;
temp[2].x=temp[2].x;
temp[2].y=temp[2].y;
temp[3].x=temp[3].x+1;
temp[3].y=temp[3].y-1;
ch=DetectCollision(KEY_UP,temp);//checking new position is valid
if(ch==FALSE)return;
pos=Cross2;
break;
case Cross2:
temp[0].x=temp[0].x+2;
temp[0].y=temp[0].y;
temp[1].x=temp[1].x+1;
temp[1].y=temp[1].y+1;
temp[2].x=temp[2].x;
temp[2].y=temp[2].y;
temp[3].x=temp[3].x-1;
temp[3].y=temp[3].y-1;
ch=DetectCollision(KEY_UP,temp);//checking new position is valid if(ch==FALSE)return;
pos=Cross3;
break;
case Cross3:
temp[0].x=temp[0].x;
temp[0].y=temp[0].y-2;
temp[1].x=temp[1].x+1;
temp[1].y=temp[1].y-1;
temp[2].x=temp[2].x;
temp[2].y=temp[2].y;
temp[3].x=temp[3].x-1;
temp[3].y=temp[3].y+1;
ch=DetectCollision(KEY_UP,temp);//checking new position is valid
if(ch==FALSE)return;
pos=Cross4;
break;
case Cross4:
temp[0].x=temp[0].x-2;
temp[0].y=temp[0].y;
temp[1].x=temp[1].x-1;
temp[1].y=temp[1].y-1;
temp[2].x=temp[2].x;
temp[2].y=temp[2].y;
temp[3].x=temp[3].x+1;
temp[3].y=temp[3].y+1;
ch=DetectCollision(KEY_UP,temp);//checking new position is valid
if(ch==FALSE)return;
pos=Cross1;
break;
}
for(i=0;i<4;i++)
ShapeCoordinate[i]=temp[i];//sending information back to main shape
}
void MainClass::PreScreen()
{ int j=40;
settextstyle(7,0,5);
char g[][2]={"T","E","T","R","I","S"," ","R","O","Y","A","L","E"};
for(int p=0;p<13;p++)
{
for(int h=480;h>=j;h-=20)
{
if(strcmp(g[p]," "))
{
setcolor((p+2)/2);
outtextxy(h,100,g[p]);
setcolor(BLACK);
outtextxy(h+20,100,g[p]);
delay(20);
}
}
j+=20;
}
settextstyle(6,0,3);
setcolor(MAGENTA);
outtextxy(200,150,"COMPUTER INVESTIGATORY PROJECT");
delay(600);
cleardevice();
setcolor(YELLOW);
settextstyle(6,0,5);
outtextxy(100,200,"BY MEENALOSHINI");
getch();
cout<<"Enter Player Name : ";
cin>>Player;
fstream file;
file.open("name.txt",ios::app);
file<<"name of the player:"<<Player<<endl;
file.close();
cleardevice(); }
----------------------------------------------------------------------------------------------------------------------
TEMP CPP FILE:
void MainClass::DisplayNextBrick(short next)
{
setfillstyle(1,0);
bar(410,205,495,290);
coordinate temp[4];
int i;
switch(next)
{ case 0:
temp[0].x=temp[1].x=temp[2].x=temp[3].x=0;
temp[0].y=5;temp[1].y=6;temp[2].y=7;temp[3].y=8;
setcolor(RED);
for(i=0;i<4;i++)
DrawBrick(315+temp[i].y*20,temp[i].x*20+220,RED);
break;
case 1: temp[0].x=0;
temp[1].x=0;
temp[2].x=1;
temp[3].x=1;
temp[0].y=5;
temp[1].y=6;
temp[2].y=5;
temp[3].y=6;
setcolor(GREEN);
for(i=0;i<4;i++)
DrawBrick(315+temp[i].y*20,temp[i].x*20+220,GREEN);
break;
case 2:
temp[0].x=0;
temp[1].x=1;
temp[2].x=1;
temp[3].x=2;
temp[0].y=5;
temp[1].y=5;
temp[2].y=6;
temp[3].y=6;
setcolor(1);
for(i=0;i<4;i++)
DrawBrick(315+temp[i].y*20,temp[i].x*20+220,BLUE);
break;
case 3:
temp[0].x=0;
temp[1].x=1;
temp[2].x=1;
temp[3].x=1;
temp[0].y=5;
temp[1].y=5;
temp[2].y=6;
temp[3].y=7;
setcolor(MAGENTA);
for(i=0;i<4;i++)
DrawBrick(315+temp[i].y*20,temp[i].x*20+220,MAGENTA);
break;
case 4:
temp[0].x=0;
temp[1].x=1;
temp[2].x=1;
temp[3].x=1;
temp[0].y=7;
temp[1].y=5;
temp[2].y=6;
temp[3].y=7;
setcolor(CYAN);
for(i=0;i<4;i++)
DrawBrick(315+temp[i].y*20,temp[i].x*20+220,CYAN);
break;
case 5:
temp[0].x=0;
temp[1].x=1;
temp[2].x=1;
temp[3].x=2;
temp[0].y=6;
temp[1].y=6;
temp[2].y=5;
temp[3].y=5;
setcolor(6);
for(i=0;i<4;i++)
DrawBrick(315+temp[i].y*20,temp[i].x*20+220,BROWN); break;
case 6:
temp[0].x=0;
temp[1].x=1;
temp[2].x=1;
temp[3].x=1;
temp[0].y=6;
temp[1].y=5;
temp[2].y=6;
temp[3].y=7;
setcolor(DARKGRAY);
for(i=0;i<4;i++)
DrawBrick(315+temp[i].y*20,temp[i].x*20+220,DARKGRAY);
break; } }
SECOND CPP FILE:
struct bitmap
{
short bit[20][20];
};
class BITMAP
{
void *character;
public:
// BITMAP();
void* DrawImage(bitmap &bit,int x,int y);
};
void* BITMAP::DrawImage(bitmap &bit,int x,int y)
{
int i,j;
for(j=y;j<y+20;j++)
{
for(i=x;i<x+20;i++)
{
putpixel(i,j,bit.bit[j-y][i-x]);
}
}
int size=imagesize(x,y,x+20,y+20);
character=malloc(size);
getimage(x,y,x+20,y+20,character);
putimage(x,y,character,XOR_PUT);
return character;
};
void button(int x,int y,int Color,int Color1)
{
int utri[6] = { x+1,y+1, x+19,y, x,y+19 };
int ltri[6] = { x+19,y+19, x+19,y+1, x+1,y+19 };
setcolor(BLACK);
setfillstyle(1,Color1);
fillpoly(3, utri);
setfillstyle(1,BLACK);
fillpoly(3, ltri);
setfillstyle(1,Color);
bar(x+5, y+5, x+15, y+15);
};
SQUREOBJECT CPP FILE:
class ObjectSqure:public MainClass
{
public:
void PutNewObjectOnBoard(BOOL bDraw);
};
void ObjectSqure::PutNewObjectOnBoard(BOOL bDraw)
{
ShapeTemp[0].x=0;
ShapeTemp[1].x=0;
ShapeTemp[2].x=1;
ShapeTemp[3].x=1;
ShapeTemp[0].y=5;
ShapeTemp[1].y=6;
ShapeTemp[2].y=5;
ShapeTemp[3].y=6;
if(bDraw==TRUE)
for(int i=0;i<4;i++)
ShapeCoordinate[i]=ShapeTemp[i];
}
LINEOBJECT CPP FILE:
class ObjectLine:public MainClass
{
public:
void PutNewObjectOnBoard(BOOL bDraw);
void RotateObject();
BOOL MoveObject(short key);
};
void ObjectLine::PutNewObjectOnBoard(BOOL bDraw)
{
ShapeTemp[0].x=ShapeTemp[1].x=ShapeTemp[2].x=ShapeTemp[3].x=0;
ShapeTemp[0].y=5;ShapeTemp[1].y=6;ShapeTemp[2].y=7;ShapeTemp[3].y=8;
if(bDraw==TRUE)
for(int i=0;i<4;i++)
ShapeCoordinate[i]=ShapeTemp[i];
};
void ObjectLine::RotateObject()
{
coordinate temp[4];
for(int i=0;i<4;i++)
{
temp[i]=ShapeCoordinate[i];
}
if(pos==SLEEP)
{
temp[1].x=temp[0].x+1;
temp[1].y=temp[0].y;
temp[2].x=temp[0].x+2;
temp[2].y=temp[0].y;
temp[3].x=temp[0].x+3;
temp[3].y=temp[0].y;
BOOL ch=DetectCollision(KEY_UP,temp);//checking new position is valid
if(ch==FALSE)return;
pos=STANDING;
}
else if(pos==STANDING)
{
temp[1].y=temp[0].y+1;
temp[1].x=temp[0].x;
temp[2].y=temp[0].y+2;
temp[2].x=temp[0].x;
temp[3].y=temp[0].y+3;
temp[3].x=temp[0].x;
BOOL ch=DetectCollision(KEY_UP,temp);//checking new position is valid
if(ch==FALSE)return;
pos=SLEEP;
}
for(i=0;i<4;i++)
ShapeCoordinate[i]=temp[i];//sending information back to main shape
}
MAINCLAS CPP FILE:
void MainClass::DrawScreen()
{
setfillstyle(1,LIGHTGRAY); //setting initial color to grey
bar(50,30,370,450);
setfillstyle(1,0);
bar(56,36,364,444);
setcolor(DARKGRAY); //setting color white to give 3d look
rectangle(55,35,364,445);
rectangle(52,32,367,448);
setcolor(WHITE);
rectangle(53,33,366,447);
rectangle(50,30,369,450);
///Darwing SideBlock Containing Other Information
setcolor(DARKGRAY); //setting color white to give 3d look
rectangle(405,35,604,445);
rectangle(402,32,607,448);
line(405,290,604,290);
line(405,293,604,293);
line(405,180,604,180);
line(405,184,604,184);
line(500,180,500,290);
line(504,184,504,294);
setcolor(LIGHTGRAY);
rectangle(404,34,605,446);
rectangle(401,31,608,449);
line(405,291,604,291);
line(405,293,604,293);
line(405,181,604,181);
line(405,183,604,183);
line(501,181,501,291);
line(503,183,503,293);
setcolor(WHITE);
rectangle(403,33,606,447);
rectangle(400,30,609,450);
line(405,292,604,292);
line(402,182,604,182);
line(502,182,502,292);
//Feeding Box INformation
settextstyle(3,0,1);
setcolor(CYAN);
outtextxy(460,300,"Key Help");
char *y;
if(!(y=new char[2]))
{cout<<"Insufficent Memory";
exit(1);
} //checking is required amount memory provided
y[1]=char(26);
y[2]='0';
setcolor(LIGHTMAGENTA);
settextstyle(DEFAULT_FONT,0,1);
outtextxy(420,330,y);
y[1]=char(27);
outtextxy(420,350,y);
y[1]=char(24);
outtextxy(420,370,y);
y[1]=char(25);
outtextxy(420,390,y);
outtextxy(480,330,": Move Left ");
outtextxy(480,350,": Move Right ");
outtextxy(480,370,": Rotate Object");
outtextxy(480,390,": Drop Object");
outtextxy(430,410,"ENTER : Pause");
outtextxy(430,430,"Esc : Exit");
setcolor(0);
bar(415,325,425,400);
setcolor(RED);
settextstyle(DEFAULT_FONT,0,1);
rectangle(400,30,609,450);
setcolor(YELLOW);
outtextxy(410,40, "Score:");
rectangle(410,50,490,70);
outtextxy(520,40, "Level:");
rectangle(520,50,600,70);
outtextxy(410,90, "Speed:");
rectangle(410,100,490,120);
outtextxy(520,90, "Lines Up:");
rectangle(520,100,600,120);
outtextxy(420,140, "Player Name");
rectangle(420,150,600,170);
setcolor(BROWN);
outtextxy(410,190,"Next Brick");
outtextxy(510,190,"Message Box");
setcolor(GREEN);
outtextxy(425,155,Player);
/* outtextxy(410,50,"Player Name");
outtextxy(410,125,"No. of Lines");
outtextxy(410,200,"Total Score");
setlinestyle(0,0,1);
//the score rectangle
rectangle(449,84,591,116);
rectangle(449,159,591,191);
rectangle(449,234,591,266);
*/
setcolor(YELLOW);
rectangle(59,39,361,441);
};
void MainClass::DrawBrick(int x,int y,int color)
{
int color2=color+8;
if(color==BLACK)color2=BLACK;
if(color==DARKGRAY)color2=LIGHTGRAY;
button(x,y,color,color2);
/* int size=imagesize(x,y,x+20,y+20);
Buff=malloc(size);
getimage(x,y,x+20,y+20,Buff);
putimage(x,y,Buff,XOR_PUT);
return Buff;
*/
}
void MainClass::CheckForLine()
{
int i=ROW,j=0;
int check;
for(;i>0;i--)
{ check=0;
while(j!=COL)
{
if(Board.xy[i][j]==0) break;
check++;
if(check==15)
RemoveLine(i);
j++;
}
j=0;//making cols zero again ti begin next testing routine
}
}
void MainClass::RemoveLine(int LineNumber)
{
int i,j;
for(i=0; i<COL; i++)
Board.xy[LineNumber][i]=0;
for(i=LineNumber; i>0; i--)
for(j=0; j<COL; j++)
{
Board.xy[i][j] = Board.xy[i-1][j];
Board.xy[i-1][j]=0;
}
setfillstyle(SOLID_FILL,BLACK);
bar(60,40,360,440);
for(i=0; i<ROW; i++)
for(j=0; j<COL; j++)
if(Board.xy[i][j]!=0)
{
switch(Board.xy[i][j])
{
case RED: DrawBrick(60+j*20,i*20+40,RED);break;
case BLUE:DrawBrick(60+j*20,i*20+40,BLUE);break;
case CYAN:DrawBrick(60+j*20,i*20+40,CYAN);break;
case MAGENTA:DrawBrick(60+j*20,i*20+40,MAGENTA);break;
case DARKGRAY:DrawBrick(60+j*20,i*20+40,DARKGRAY);break;
case BROWN:DrawBrick(60+j*20,i*20+40,BROWN);break;
case GREEN:DrawBrick(60+j*20,i*20+40,GREEN);break;
}
} //
//Now doing Cleansing up And Incrementing Score
OLineClear++;
// Score+=10;
UpdateScore();
}
void MainClass::MsgBox(int x,char *string,BOOL bErase)
{
setfillstyle(SOLID_FILL,BLACK);
setcolor(YELLOW);
if(bErase==TRUE) bar(505,200,603,290);
settextstyle(SMALL_FONT,0,5);
outtextxy(510,x,string);
}
void MainClass::UpdateScore()
{
char string[10];
settextstyle(SMALL_FONT,0,6);
setfillstyle(SOLID_FILL,BLACK);
setcolor(LIGHTBLUE);
//Score
bar(411,51,489,69);
ultoa(Score,string,10);
outtextxy(420,52,string);
//Level
bar(521,51,599,69);
ultoa(Level,string,10);
outtextxy(530,52,string);
//Speed
bar(411,101,489,119);
itoa((100-Speed),string,10);
outtextxy(420,102,string);
//Lines Up
bar(521,101,599,119);
ultoa(LineCleared,string,10);
outtextxy(530,102,string);
}
void MainClass::showarray()
{
setfillstyle(1,0);
bar(0,0,600,30);
gotoxy(40,1);
int i;
for(i=0;i<ROW;i++)
{gotoxy(40,i);
for(int j=0;j<COL;j++)
{
cout<<Board.xy[i][j]<<" ";
}
}
}
OUTPUT SCREEN
OPENING SCREEN
MAIN GAME SCREEN
FILE SCREEN
SCREEN TO ENTER
NAME AND DOB
SCREEN OF
GAME OVER
BIBLIOGRAPHY
https://www.planet-source-
code.com/vb/scripts/ShowCode.asp?txtCodeId=1086&lngWId=3 (source
code)
https://www.w3schools.com/cpp/cpp_getstarted.asp (c++ introduction)
https://www.tutorialspoint.com/cplusplus/cpp_polymorphism.html
(polymorphism)
https://www.geeksforgeeks.org/inheritance-in-c/ (inheritance)
https://beginnersbook.com/2017/09/cpp-encapsulation/ (encapsulation)
https://en.wikipedia.org/wiki/Tetris (tetris game)
https://www.studytonight.com/cpp/file-streams-in-cpp.php (file streams)
https://www.quora.com/How-is-modularity-introduced-in-c++ (modularity)
https://www.w3schools.in/cplusplus-tutorial/data-abstraction/
(abstraction)

More Related Content

Similar to Computer investigatroy project c++ class 12

Deep Learning Demystified
Deep Learning DemystifiedDeep Learning Demystified
Deep Learning Demystified
Affine Analytics
 
Data Science Accelerator Program
Data Science Accelerator ProgramData Science Accelerator Program
Data Science Accelerator Program
GoDataDriven
 
Machine Learning ICS 273A
Machine Learning ICS 273AMachine Learning ICS 273A
Machine Learning ICS 273A
butest
 
Machine Learning ICS 273A
Machine Learning ICS 273AMachine Learning ICS 273A
Machine Learning ICS 273A
butest
 
Social Network Analysis Introduction including Data Structure Graph overview.
Social Network Analysis Introduction including Data Structure Graph overview. Social Network Analysis Introduction including Data Structure Graph overview.
Social Network Analysis Introduction including Data Structure Graph overview.
Doug Needham
 
These questions will be a bit advanced level 2
These questions will be a bit advanced level 2These questions will be a bit advanced level 2
These questions will be a bit advanced level 2
sadhana312471
 
Ch.1 oop introduction, classes and objects
Ch.1 oop introduction, classes and objectsCh.1 oop introduction, classes and objects
Ch.1 oop introduction, classes and objects
ITNet
 
Deep learning tutorial 9/2019
Deep learning tutorial 9/2019Deep learning tutorial 9/2019
Deep learning tutorial 9/2019
Amr Rashed
 
Deep Learning Tutorial
Deep Learning TutorialDeep Learning Tutorial
Deep Learning Tutorial
Amr Rashed
 
Tic toc game presentation
Tic toc game presentationTic toc game presentation
Tic toc game presentation
REZAUL KARIM REFATH
 
TeelTech - Advancing Mobile Device Forensics (online version)
TeelTech - Advancing Mobile Device Forensics (online version)TeelTech - Advancing Mobile Device Forensics (online version)
TeelTech - Advancing Mobile Device Forensics (online version)
Mike Felch
 
Object oriented concepts
Object oriented conceptsObject oriented concepts
Object oriented concepts
Pranali Chaudhari
 
Introduction to deep learning
Introduction to deep learningIntroduction to deep learning
Introduction to deep learning
Amr Rashed
 
Oops ppt
Oops pptOops ppt
Oops ppt
abhayjuneja
 
Roelof Temmingh FIRST07 slides
Roelof Temmingh FIRST07 slidesRoelof Temmingh FIRST07 slides
Roelof Temmingh FIRST07 slides
Leon Kuunders
 
The Ring programming language version 1.8 book - Part 7 of 202
The Ring programming language version 1.8 book - Part 7 of 202The Ring programming language version 1.8 book - Part 7 of 202
The Ring programming language version 1.8 book - Part 7 of 202
Mahmoud Samir Fayed
 
Deep learning with tensorflow
Deep learning with tensorflowDeep learning with tensorflow
Deep learning with tensorflow
Charmi Chokshi
 
Machine Learning and Deep Learning with R
Machine Learning and Deep Learning with RMachine Learning and Deep Learning with R
Machine Learning and Deep Learning with R
Poo Kuan Hoong
 
C# classes
C#   classesC#   classes
C# classes
Tiago
 
detailed experience
detailed experiencedetailed experience
detailed experience
Bryan Yan
 

Similar to Computer investigatroy project c++ class 12 (20)

Deep Learning Demystified
Deep Learning DemystifiedDeep Learning Demystified
Deep Learning Demystified
 
Data Science Accelerator Program
Data Science Accelerator ProgramData Science Accelerator Program
Data Science Accelerator Program
 
Machine Learning ICS 273A
Machine Learning ICS 273AMachine Learning ICS 273A
Machine Learning ICS 273A
 
Machine Learning ICS 273A
Machine Learning ICS 273AMachine Learning ICS 273A
Machine Learning ICS 273A
 
Social Network Analysis Introduction including Data Structure Graph overview.
Social Network Analysis Introduction including Data Structure Graph overview. Social Network Analysis Introduction including Data Structure Graph overview.
Social Network Analysis Introduction including Data Structure Graph overview.
 
These questions will be a bit advanced level 2
These questions will be a bit advanced level 2These questions will be a bit advanced level 2
These questions will be a bit advanced level 2
 
Ch.1 oop introduction, classes and objects
Ch.1 oop introduction, classes and objectsCh.1 oop introduction, classes and objects
Ch.1 oop introduction, classes and objects
 
Deep learning tutorial 9/2019
Deep learning tutorial 9/2019Deep learning tutorial 9/2019
Deep learning tutorial 9/2019
 
Deep Learning Tutorial
Deep Learning TutorialDeep Learning Tutorial
Deep Learning Tutorial
 
Tic toc game presentation
Tic toc game presentationTic toc game presentation
Tic toc game presentation
 
TeelTech - Advancing Mobile Device Forensics (online version)
TeelTech - Advancing Mobile Device Forensics (online version)TeelTech - Advancing Mobile Device Forensics (online version)
TeelTech - Advancing Mobile Device Forensics (online version)
 
Object oriented concepts
Object oriented conceptsObject oriented concepts
Object oriented concepts
 
Introduction to deep learning
Introduction to deep learningIntroduction to deep learning
Introduction to deep learning
 
Oops ppt
Oops pptOops ppt
Oops ppt
 
Roelof Temmingh FIRST07 slides
Roelof Temmingh FIRST07 slidesRoelof Temmingh FIRST07 slides
Roelof Temmingh FIRST07 slides
 
The Ring programming language version 1.8 book - Part 7 of 202
The Ring programming language version 1.8 book - Part 7 of 202The Ring programming language version 1.8 book - Part 7 of 202
The Ring programming language version 1.8 book - Part 7 of 202
 
Deep learning with tensorflow
Deep learning with tensorflowDeep learning with tensorflow
Deep learning with tensorflow
 
Machine Learning and Deep Learning with R
Machine Learning and Deep Learning with RMachine Learning and Deep Learning with R
Machine Learning and Deep Learning with R
 
C# classes
C#   classesC#   classes
C# classes
 
detailed experience
detailed experiencedetailed experience
detailed experience
 

More from meenaloshiniG

CONFERENCE POSTER PHARMACOGNOSY.pdf
CONFERENCE POSTER PHARMACOGNOSY.pdfCONFERENCE POSTER PHARMACOGNOSY.pdf
CONFERENCE POSTER PHARMACOGNOSY.pdf
meenaloshiniG
 
HAP-CONNECTIVE TISSUE-MEENALOSHINI.pptx
HAP-CONNECTIVE TISSUE-MEENALOSHINI.pptxHAP-CONNECTIVE TISSUE-MEENALOSHINI.pptx
HAP-CONNECTIVE TISSUE-MEENALOSHINI.pptx
meenaloshiniG
 
peripheral nervous system.pptx
peripheral nervous system.pptxperipheral nervous system.pptx
peripheral nervous system.pptx
meenaloshiniG
 
SUSPENSION PHARMACEUTICS-1 BPHARM 1ST YEAR.pdf
SUSPENSION PHARMACEUTICS-1 BPHARM 1ST YEAR.pdfSUSPENSION PHARMACEUTICS-1 BPHARM 1ST YEAR.pdf
SUSPENSION PHARMACEUTICS-1 BPHARM 1ST YEAR.pdf
meenaloshiniG
 
PHYSICS INVESTIGATORY PROJECT ON THEORY OF RELATIVITY HYPOTHESIS AND CONCLUSI...
PHYSICS INVESTIGATORY PROJECT ON THEORY OF RELATIVITY HYPOTHESIS AND CONCLUSI...PHYSICS INVESTIGATORY PROJECT ON THEORY OF RELATIVITY HYPOTHESIS AND CONCLUSI...
PHYSICS INVESTIGATORY PROJECT ON THEORY OF RELATIVITY HYPOTHESIS AND CONCLUSI...
meenaloshiniG
 
cbse Biology investigatory project class 12 on neuro-biological and systemic...
 cbse Biology investigatory project class 12 on neuro-biological and systemic... cbse Biology investigatory project class 12 on neuro-biological and systemic...
cbse Biology investigatory project class 12 on neuro-biological and systemic...
meenaloshiniG
 
Solar desalination chemistry investigatory project class 12 cbse
Solar desalination chemistry investigatory project class 12 cbse Solar desalination chemistry investigatory project class 12 cbse
Solar desalination chemistry investigatory project class 12 cbse
meenaloshiniG
 

More from meenaloshiniG (7)

CONFERENCE POSTER PHARMACOGNOSY.pdf
CONFERENCE POSTER PHARMACOGNOSY.pdfCONFERENCE POSTER PHARMACOGNOSY.pdf
CONFERENCE POSTER PHARMACOGNOSY.pdf
 
HAP-CONNECTIVE TISSUE-MEENALOSHINI.pptx
HAP-CONNECTIVE TISSUE-MEENALOSHINI.pptxHAP-CONNECTIVE TISSUE-MEENALOSHINI.pptx
HAP-CONNECTIVE TISSUE-MEENALOSHINI.pptx
 
peripheral nervous system.pptx
peripheral nervous system.pptxperipheral nervous system.pptx
peripheral nervous system.pptx
 
SUSPENSION PHARMACEUTICS-1 BPHARM 1ST YEAR.pdf
SUSPENSION PHARMACEUTICS-1 BPHARM 1ST YEAR.pdfSUSPENSION PHARMACEUTICS-1 BPHARM 1ST YEAR.pdf
SUSPENSION PHARMACEUTICS-1 BPHARM 1ST YEAR.pdf
 
PHYSICS INVESTIGATORY PROJECT ON THEORY OF RELATIVITY HYPOTHESIS AND CONCLUSI...
PHYSICS INVESTIGATORY PROJECT ON THEORY OF RELATIVITY HYPOTHESIS AND CONCLUSI...PHYSICS INVESTIGATORY PROJECT ON THEORY OF RELATIVITY HYPOTHESIS AND CONCLUSI...
PHYSICS INVESTIGATORY PROJECT ON THEORY OF RELATIVITY HYPOTHESIS AND CONCLUSI...
 
cbse Biology investigatory project class 12 on neuro-biological and systemic...
 cbse Biology investigatory project class 12 on neuro-biological and systemic... cbse Biology investigatory project class 12 on neuro-biological and systemic...
cbse Biology investigatory project class 12 on neuro-biological and systemic...
 
Solar desalination chemistry investigatory project class 12 cbse
Solar desalination chemistry investigatory project class 12 cbse Solar desalination chemistry investigatory project class 12 cbse
Solar desalination chemistry investigatory project class 12 cbse
 

Recently uploaded

Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
taiba qazi
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
Celine George
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
paigestewart1632
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
WaniBasim
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
Katrina Pritchard
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
amberjdewit93
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
Celine George
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
NgcHiNguyn25
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
ak6969907
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
Celine George
 

Recently uploaded (20)

Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
 

Computer investigatroy project c++ class 12

  • 1. UNDER THE GUIDANCE OF: MRS.JINI SUBMITTED BY: G.MEENALOSHINI CLASS XII A REGISTER NO:
  • 2. Acknowledgement In the accomplishment of this project successfully, many people have best owned upon me their blessings and the heart pledged support. This time I am utilising to thank all the people who have been concerned with this project. Firstly, I would thank god for being able to complete this project with triumph. Then I would like to thank my parents and family members who helped me with their valuable suggestions. Secondly, I would like to express my special thanks of gratitude to my computer-science facilitator Mrs.Jini as well as our principal Mrs.G.Jigi Mol who gave me the golden opportunity to do this wonderful project on the topic ”TETRIS ROYALE-GAME”, which also helped me in doing a lot of research and I came to know about so many new things. Last but not the least I would like to thank all my friends and classmates for their guidance in various phases of the completion of the project. Regards, G.Meenaloshini
  • 3. TABLE OF CONTENTS S.NO TOPICS 1. INTRODUCTION 2. SYSTEM OBJECTIVES & AIM OF THE PROJECT 3. HARDWARE & SOFTWARE REQUIREMENTS 4. THEORY 5. HEADER FILES INCLUDED 6. SOURCE CODE 7. OUTPUT SCREENS 8. BIBLIOGRAPHY
  • 4. INTRODUCTION Tetris game code with sounds, high scores and gravity. It is intended as a learning tool with its extensive comments and laid out code with easy get-around and simple functions. The code explores things such as loops and if statements, patch, save/load, GUI techniques, call-backs and sound generation. Description “Tetris is a game involving dropping blocks. Points are scored for each block which comes to rest on the gradually collecting pile of blocks. Different blocks in different orientations score different points. The goal is to prevent the pile from reaching the top and ending the game. Whenever a row of blocks is completely filled, it is removed and all blocks above it drop down to fill the empty row.” Game Walkthrough A random sequence of tetrominoes (sometimes called "tetrads" in older versions)—shapes composed of four square blocks each—fall down the playing field (a rectangular vertical shaft, called the "well" or "matrix"). The object of the game is to manipulate these tetrominoes, by moving each one sideways and rotating it by 90 degree units, with the aim of creating a horizontal line of blocks without gaps. When such a line is created, it disappears, and any block above the deleted line will fall. As the game progresses, the tetrominoes fall faster, and the game ends when the stack of tetrominoes reaches the top of the playing field and no new tetrominoes are able to enter. Game Objectives  Complete levels by clearing a set number of lines  Clear lines to stop stack from reaching top of screen  Clear more lines at once for higher point values Increasing difficulty As players complete more levels, the difficulty of the game increases. Not only do players keep the lines that they did not clear from the previous levels, but pieces also begin to fall faster, forcing the player to think faster in order to clear lines.
  • 5. SYSTEM OBJECTIVES & AIM OF THE PROJECT The Tetris Effect The Tetris Effect is a catchy term that players use to describe the way they are inspired by the game and see Tetriminos in everyday situations. Because Tetris, like the real world, challenges players to make order out of chaos using a specific organization system, the game components translate easily into lifestyle interpretations. Whether you're packing the trunk of your car, loading a dishwasher, or organizing your shelves, you're likely thinking about how each object will fit together strategically with minimal empty space. This is the Tetris Effect! Learning Objectives  Recognize spatial requirements to clear lines by rotating and dropping pieces  Plan ahead by setting up lines for easy clearing  Adapt to faster falling pieces Educational Outcomes Tetris has been one the most recognized and enjoyed video games since its creation 25 years ago. Even today the game still enjoys popularity as it has gained new interest through platforms such as the iPhone and Facebook. Because of its extensive social influences, many researchers have attempted measure the effects of Tetris, each with varying results. Spatial ability is the first area of learning that most people would point to improvement. However in two experiments conducted by Valerie Sims and Richard Mayer, researchers found that spatial expertise is highly-domain specific. The experiment compared skilled Tetris players, non-Tetris players, and participants who played Tetris for 12 hours. Researchers discovered that Tetris players perform better in spatial ability than non-Tetris players when using identical or similar shapes to Tetris pieces. Tetris players were able to mentally place these shapes faster and often rotated the shapes in alternative ways. However, Tetris and non-Tetris players displayed little difference when performing spatial ability tests with non-Tetris shapes. Researchers at the Mind Research Network discovered differing results. Over a three-month period, researchers studied two groups of adolescent girls, one group consistently played Tetris while the other did not. After analyzing the girls’ MRIs after three months, researchers found that the girls who played Tetris displayed changes in their cortex. The increase in cortical thickness is correlated with an increase in grey matter, which leads to greater brain efficiency when completing complex tasks.
  • 6. HARDWARE REQUIREMENT COMPONENTS REQUIREMENTS Processor Intel(R) Pentium(R) CPU N3520 @ 2.16GHz Ram 2 GB Hard disk drive 465 GB Graphics memory 775 MB SOFTWARE ENVIRONMENT COMPONENTS REQUIREMENTS Os 64-bit operating system(WINDOWS 7) Graphics Intel(R) HD Graphics Programming Language TURBO C7 (C++) FILES GENERATED Text file: tetris.txt Programme file: tetris.cpp Object file: tetris.obj Execution file: tetris.exe
  • 7. C++ is a multi-paradigm programming language that supports object-oriented programming (OOP), created by Bjarne Stroustrup in 1983 at Bell Labs, C++ is an extension(superset) of C programming and the programs are written in C language can run in C++ compilers. C++ is used by programmers to create computer software. It is used to create general systems software, drivers for various computer devices, software for servers and software for specific applications and also widely used in the creation of video games. USES: C++ is used by many programmers of different types and coming from different fields. C++ is mostly used to write device driver programs, system software, and applications that depend on direct hardware manipulation under real-time constraints. It is also used to teach the basics of object-oriented features because it is simple and is also used in the fields of research. Also, many primary user interfaces and system files of Windows and Macintosh are written using C++. So, C++ is a popular, strong and frequently used programming language of this modern programming era. FEATURES: The main focus remains on data rather than procedures. Object-oriented programs are segmented into parts called objects. Data structures are designed to categorize the objects. Data member and functions are tied together as a data structure. Data can be hidden and cannot be accessed by external functions using access specifier. Objects can communicate among themselves using functions. New data and functions can be easily added anywhere within a program whenever required. Since this is an object-oriented programming language, it follows a bottom up approach, i.e. the execution of codes starts from the main which resides at the lower section and then based on the member function call the working is done from the classes.
  • 8. Object Oriented Programming in C++ Object Oriented programming is a programming style that is associated with the concept of Class, Objects and various other concepts revolving around these two, like Inheritance, Polymorphism, Abstraction, Encapsulation etc. Encapsulation Encapsulationis a process of combining data and function into a single unit like capsule. This is to avoid the access of private data members from outside the class. To achieve encapsulation, we make all data members of class private and create public functions, using them we can get the values from these data members or set the value to these data members. Abstraction: Abstractionis a process of hiding irrelevant details from user. Inheritance Inheritanceis a feature using which an object of child class acquires the properties of parent class.
  • 9. Polymorphism Function overloadingand Operator overloading are examples of polymorphism. Polymorphism is a feature using which an object behaves differently in different situation. MODULARITY: Modularity: the written program can be splitted up in to modules by using classes and each class can be considered as a module.
  • 10. File Handling using File Streams in C++ File represents storage medium for storing data or information. Streams refer to sequence of bytes. In Files we store data i.e. text or binary data permanently and use these data to read or write in the form of input output operations by transferring bytes of data. So we use the term File Streams/File handling. We use the header file <fstream>  ofstream: It represents output Stream and this is used for writing in files.  ifstream: It represents input Stream and this is used for reading from files.  fstream: It represents both output Stream and input Stream. So it can read from files and write to files. Operations in File Handling:  Creating a file: open()  Reading data: read()  Writing new data: write()  Closing a file: close() SPECIAL OPERATIONS IN A FILE There are few important functions to be used with file streams like:  tellp() - It tells the current position of the put pointer. Syntax: filepointer.tellp()  tellg() - It tells the current position of the get pointer. Syntax: filepointer.tellg()  seekp() - It moves the put pointer to mentioned location. Syntax: filepointer.seekp(no of bytes,reference mode)  seekg() - It moves get pointer(input) to a specified location. Syntax: filepointer.seekg((no of bytes,reference point)  put() - It writes a single character to file.  get() - It reads a single character from file.
  • 11. Header files included ///PreDefined HeaderFile #include<iostream.h> Used as a stream of Input and Output. #include<graphics.h> C graphics using graphics.h functions can be used to draw different shapes, display text in different fonts, change colors and many more. #include<stdlib.h> Perform standard utility functions like dynamic memory allocation. #include<conio.h> Perform console input and console output operations like clrscr() to clear the screen and getch() to get the character from the keyboard. #include<process.h> C header file which contains function declarations and macros used in working with threads and processes. #include<dos.h> header file of C language contains functions for handling interrupts, producing sound, date and time functions etc. #include<string.h> Perform string manipulation operations like strlen and strcpy. #include<fstream.h> Contains function prototypes for functions that perform input from files on disk and output to files on disk. ///User Defined Header File(modularity concept) #include"C:TCbinsecond.cpp" #include"C:TCincludekeyb.h" #include"C:TCbinmainclas.cpp" #include"C:TCbinlineobj.cpp" #include"C:TCbinsqureobj.cpp" #include"C:TCbintemp.cpp"
  • 13. SOURCE CODE #include<iostream.h> #include<graphics.h> #include<stdlib.h> #include<conio.h> #include<process.h> #include<dos.h> #include<string.h> #include<fstream.h> #include"C:TCbinsecond.cpp" #include"C:TCincludekeyb.h" enum BOOL{FALSE=0,TRUE,END,OVER}; enum POS{SLEEP=1001,STANDING,LLightSleep,LLightStanding,RLightSleep,RLightStanding,SQURE, Cross1,Cross2,Cross3,Cross4,LL1,LL2,LL3,LL4}; const short BOX=180; const ROW=20; const COL=15; struct board{ short xy[20][15]; }; struct coordinate{ short x,y; }; class MainClass { protected: static board Board; coordinate ShapeCoordinate[4];coordinate ShapeTemp[4]; char Player[20]; public: static unsigned long LineCleared,OLineClear,Score,Level; static int Speed; static short id; POS pos; MainClass(); void showarray(); void StartMainClass(); void StartObject(short); virtual void RotateObject(){}; BOOL MoveObject(short); BOOL DetectCollision(short,coordinate []); virtual void PutNewObjectOnBoard(BOOL){}; void RemoveLine(int); void MsgBox(int,char *,BOOL); BOOL CheckBoard(int[],coordinate[]); void CheckForLine(); void DrawBrick(int,int,int); void UpdateScore(); ///Update Score void DrawScreen(); ///Drawbackground ANd other nessecary thing void SoundDrop(); void DisplayNextBrick(short); void PreScreen(); }; board MainClass::Board; unsigned long MainClass::LineCleared; unsigned long MainClass::OLineClear; unsigned long MainClass::Level; unsigned long MainClass::Score; short MainClass::id; int MainClass::Speed; #include"C:TCbinmainclas.cpp" #include"C:TCbinlineobj.cpp"
  • 14. #include"C:TCbinsqureobj.cpp" #include"C:TCbintemp.cpp" class ObjectCross:public MainClass { public: void PutNewObjectOnBoard(BOOL bDraw); void RotateObject(); }; class ObjectLL:public MainClass { public: void PutNewObjectOnBoard(BOOL bDraw); void RotateObject(); }; class ObjectRL:public MainClass { public: void PutNewObjectOnBoard(BOOL bDraw); void RotateObject(); }; class ObjectLLighting:public MainClass { public: void PutNewObjectOnBoard(BOOL bDraw); void RotateObject(); }; class ObjectRLighting:public MainClass { public: void PutNewObjectOnBoard(BOOL bDraw); void RotateObject(); }; void main() { BOOL Check; //dynamically alloting memory MainClass *MainObject=new MainClass; int Counter=0; short n; if(MainObject==NULL) { cout<<"Memory Allocation Error"; exit(0); } setpalette(BROWN,62); // MainObject->OLineClear=MainObject->LineCleared; //shapes deleclartion ObjectLine Line;
  • 15. ObjectSqure Squre; ObjectLLighting LLight; ObjectRLighting RLight; ObjectCross Cross; ObjectLL Ll; ObjectRL Rl; MainObject->StartMainClass(); randomize();//inisiating Random no generator MainObject=&Line; MainObject->pos=SLEEP; MainObject->PutNewObjectOnBoard(TRUE); MainObject->id=0; MainObject->StartObject(0); int ch=0; short ChoiceOfObject; n=1; MainObject->DisplayNextBrick(n); while(ch!=EXIT) { if(Check==OVER) { cleardevice(); settextstyle(1,0,6);setcolor(RED); outtextxy(150,100,"GAME OVER"); delay(200); ch=EXIT; } if(Check==END) { while(kbhit()) getch(); MainObject->MsgBox(200,"",TRUE); Check=TRUE; for(int o=0;o<5;o++){ MainObject->CheckForLine(); delay(50); } if((MainObject->OLineClear-MainObject->LineCleared)>0) { if(MainObject->OLineClear%20==0) { if(MainObject->LineCleared>1){ MainObject->Level++; MainObject->Speed=MainObject->Speed -5; MainObject->MsgBox(210,"level Change",TRUE); sound(100); delay(200); MainObject->UpdateScore(); }
  • 16. } } switch((MainObject->OLineClear)-(MainObject->LineCleared)) { case 1:MainObject->Score+=10; MainObject->LineCleared++; MainObject->MsgBox(210,"1 Line",FALSE); MainObject->MsgBox(240,"Nice!!",FALSE); break; case 2:MainObject->Score+=30; MainObject->LineCleared+=2; MainObject->MsgBox(210,"2 Line",FALSE); MainObject->MsgBox(240,"Very Nice!!",FALSE); break; case 3:MainObject->Score+=60; MainObject->LineCleared+=3; MainObject->MsgBox(210,"3 Line",FALSE); MainObject->MsgBox(240,"Wow!!",FALSE); break; case 4:MainObject->Score+=100; MainObject->LineCleared+=4; MainObject->MsgBox(210,"4 Line",FALSE); MainObject->MsgBox(240,"Excellent",FALSE); MainObject->MsgBox(270,"100 pt Bonus",FALSE); break; } MainObject->UpdateScore(); ChoiceOfObject=n; MainObject->id=ChoiceOfObject; switch(ChoiceOfObject) { case 0: MainObject=&Line; MainObject->pos=SLEEP; break; case 1: MainObject=&Squre; MainObject->pos=SQURE; break; case 2: MainObject=&LLight; MainObject->pos=LLightStanding; break; case 3: MainObject=&Ll; MainObject->pos=Cross1; break; case 4: MainObject=&Rl; MainObject->pos=LL1;
  • 17. break; case 5: MainObject=&RLight; MainObject->pos=RLightStanding; break; case 6: MainObject=&Cross; MainObject->pos=Cross1; break; } MainObject->PutNewObjectOnBoard(TRUE); MainObject->StartObject(ChoiceOfObject); n=rand()%7; MainObject->DisplayNextBrick(n); // MainObject->showarray(); while(kbhit()) getch(); } if(++Counter >= MainObject->Speed) { Counter=0; Check=MainObject->MoveObject(KEY_DOWN); MainObject->SoundDrop(); } delay(8); while(kbhit()) { ch=getch(); switch(ch) { case KEY_UP:Check=MainObject->MoveObject(KEY_UP); break; case KEY_DOWN:Check=MainObject->MoveObject(KEY_DOWN); MainObject->Score+=1; MainObject->UpdateScore(); break; case KEY_RIGHT:Check=MainObject->MoveObject(KEY_RIGHT); break; case KEY_ENTER: MainObject->MsgBox(210,"Pause",TRUE); getch(); MainObject->MsgBox(210,"",TRUE); break; case KEY_LEFT:Check=MainObject->MoveObject(KEY_LEFT); break; case KEY_ESC: ch=EXIT; //exit(0); } //end switch
  • 18. MainObject->SoundDrop(); delay(5); } //end while } delete MainObject; closegraph(); restorecrtmode(); getch(); } MainClass::MainClass() { Speed=100; } void MainClass::StartMainClass() { int GD=DETECT,GM; initgraph(&GD,&GM,"C:TCbgi"); cleardevice(); PreScreen(); LineCleared=Score=0; DrawScreen(); UpdateScore();} void MainClass::SoundDrop() {for(int i=5; i<10; i++) {sound(200*i) delay(1); nosound(); } } void MainClass::StartObject(short id) { coordinate temp[4]; for(int i=0;i<4;i++) { temp[i]=ShapeCoordinate[i]; } switch(id) { case 0:for(i=0;i<4;i++) { Board.xy[ShapeCoordinate[i].x][ShapeCoordinate[i].y]=RED; DrawBrick(60+temp[i].y*20,temp[i].x*20+40,RED); } break; case 1: for(i=0;i<4;i++) { Board.xy[ShapeCoordinate[i].x][ShapeCoordinate[i].y]=GREEN; DrawBrick(60+temp[i].y*20,temp[i].x*20+40,GREEN); } break; case 2: for(i=0;i<4;i++) { Board.xy[ShapeCoordinate[i].x][ShapeCoordinate[i].y]=BLUE; DrawBrick(60+temp[i].y*20,temp[i].x*20+40,BLUE); } break; case 3: for(i=0;i<4;i++) { Board.xy[ShapeCoordinate[i].x][ShapeCoordinate[i].y]=MAGENTA; DrawBrick(60+temp[i].y*20,temp[i].x*20+40,MAGENTA);
  • 19. } break; case 4: for(i=0;i<4;i++) { Board.xy[ShapeCoordinate[i].x][ShapeCoordinate[i].y]=CYAN; DrawBrick(60+temp[i].y*20,temp[i].x*20+40,CYAN); } break; case 5: for(i=0;i<4;i++) { Board.xy[ShapeCoordinate[i].x][ShapeCoordinate[i].y]=BROWN; DrawBrick(60+temp[i].y*20,temp[i].x*20+40,BROWN); } break; case 6: for(i=0;i<4;i++) { Board.xy[ShapeCoordinate[i].x][ShapeCoordinate[i].y]=DARKGRAY; DrawBrick(60+temp[i].y*20,temp[i].x*20+40,DARKGRAY); } break; case 7: for(i=0;i<4;i++) { Board.xy[ShapeCoordinate[i].x][ShapeCoordinate[i].y]=BLACK; DrawBrick(60+temp[i].y*20,temp[i].x*20+40,BLACK); } } } void ObjectRL::PutNewObjectOnBoard(BOOL bDraw) { ShapeTemp[0].x=0; ShapeTemp[1].x=1; ShapeTemp[2].x=1; ShapeTemp[3].x=1; ShapeTemp[0].y=7; ShapeTemp[1].y=5; ShapeTemp[2].y=6; ShapeTemp[3].y=7; if(bDraw==TRUE) for(int i=0;i<4;i++) ShapeCoordinate[i]=ShapeTemp[i]; } void ObjectLL::PutNewObjectOnBoard(BOOL bDraw) { ShapeTemp[0].x=0; ShapeTemp[1].x=1; ShapeTemp[2].x=1; ShapeTemp[3].x=1; ShapeTemp[0].y=5;
  • 20. ShapeTemp[1].y=5; ShapeTemp[2].y=6; ShapeTemp[3].y=7; if(bDraw==TRUE) for(int i=0;i<4;i++) ShapeCoordinate[i]=ShapeTemp[i]; } void ObjectCross::PutNewObjectOnBoard(BOOL bDraw) { ShapeTemp[0].x=0; ShapeTemp[1].x=1; ShapeTemp[2].x=1; ShapeTemp[3].x=1; ShapeTemp[0].y=6; ShapeTemp[1].y=5; ShapeTemp[2].y=6; ShapeTemp[3].y=7; if(bDraw==TRUE) for(int i=0;i<4;i++) ShapeCoordinate[i]=ShapeTemp[i]; } void ObjectLLighting::PutNewObjectOnBoard(BOOL bDraw) { ShapeTemp[0].x=0; ShapeTemp[1].x=1; ShapeTemp[2].x=1; ShapeTemp[3].x=2; ShapeTemp[0].y=5; ShapeTemp[1].y=5; ShapeTemp[2].y=6; ShapeTemp[3].y=6; if(bDraw==TRUE) for(int i=0;i<4;i++) ShapeCoordinate[i]=ShapeTemp[i]; } void ObjectRLighting::PutNewObjectOnBoard(BOOL bDraw) { ShapeTemp[0].x=0; ShapeTemp[1].x=1; ShapeTemp[2].x=1; ShapeTemp[3].x=2; ShapeTemp[0].y=6; ShapeTemp[1].y=6; ShapeTemp[2].y=5; ShapeTemp[3].y=5; if(bDraw==TRUE) for(int i=0;i<4;i++) ShapeCoordinate[i]=ShapeTemp[i];
  • 21. } BOOL MainClass::MoveObject(short key) { coordinate temp[4]; for(int i=0;i<4;i++) { temp[i]=ShapeCoordinate[i]; } StartObject(7); if((DetectCollision(key,temp)==END)||(DetectCollision(key,temp)==FALSE)) { StartObject(id); for(i=4;i<9;i++) { if (Board.xy[1][i]!=0)return OVER; } return(DetectCollision(key,temp)); } switch(key) { case KEY_UP: RotateObject(); break; case KEY_DOWN: ShapeCoordinate[0].x+=1; ShapeCoordinate[1].x+=1; ShapeCoordinate[2].x+=1; ShapeCoordinate[3].x+=1; break; case KEY_RIGHT: ShapeCoordinate[0].y +=1; ShapeCoordinate[1].y +=1; ShapeCoordinate[2].y +=1; ShapeCoordinate[3].y +=1; break; case KEY_LEFT: ShapeCoordinate[0].y-=1; ShapeCoordinate[1].y-=1; ShapeCoordinate[2].y-=1; ShapeCoordinate[3].y-=1; break; } StartObject(id); return TRUE; } BOOL MainClass::DetectCollision(short key,coordinate temp1[4]) {
  • 22. coordinate temp[4]; for(int i=0;i<4;i++) { temp[i]=ShapeCoordinate[i]; } switch(key) { case KEY_UP: if(temp1[0].x>=19)return FALSE; if(temp1[1].x>=19)return FALSE; if(temp1[2].x>=19)return FALSE; if(temp1[3].x>=19)return FALSE; if(temp1[0].y>14)return FALSE; if(temp1[1].y>14)return FALSE; if(temp1[2].y>14)return FALSE; if(temp1[3].y>14)return FALSE; if(temp1[0].y<0)return FALSE; if(temp1[1].y<0)return FALSE; if(temp1[2].y<0)return FALSE; if(temp1[3].y<0)return FALSE; if(Board.xy[temp1[0].x][temp1[0].y]!=0)return FALSE; if(Board.xy[temp1[1].x][temp1[1].y]!=0)return FALSE; if(Board.xy[temp1[2].x][temp1[2].y]!=0)return FALSE; if(Board.xy[temp1[3].x][temp1[3].y]!=0)return FALSE; break; case KEY_DOWN: if(temp[0].x==19)return END; if(temp[1].x==19)return END; if(temp[2].x==19)return END; if(temp[3].x==19)return END; if(temp[0].x==0) { if(Board.xy[2][temp[0].y]!=0)return OVER; if(Board.xy[2][temp[1].y]!=0)return OVER; if(Board.xy[2][temp[2].y]!=0)return OVER; if(Board.xy[2][temp[3].y]!=0)return OVER; } temp[0].x+=1; temp[1].x+=1; temp[2].x+=1; temp[3].x+=1; if(Board.xy[temp[0].x][temp[0].y]!=0)return END; if(Board.xy[temp[1].x][temp[1].y]!=0)return END; if(Board.xy[temp[2].x][temp[2].y]!=0)return END; if(Board.xy[temp[3].x][temp[3].y]!=0)return END; //for game over break; case KEY_RIGHT: if(temp[0].y==14)return FALSE; if(temp[1].y==14)return FALSE; if(temp[2].y==14)return FALSE; if(temp[3].y==14)return FALSE;
  • 23. temp[0].y+=1; temp[1].y+=1; temp[2].y+=1; temp[3].y+=1; if(Board.xy[temp[0].x][temp[0].y]!=0)return FALSE; if(Board.xy[temp[1].x][temp[1].y]!=0)return FALSE; if(Board.xy[temp[2].x][temp[2].y]!=0)return FALSE; if(Board.xy[temp[3].x][temp[3].y]!=0)return FALSE; break; case KEY_LEFT: if(temp[0].y==0)return FALSE; if(temp[1].y==0)return FALSE; if(temp[2].y==0)return FALSE; if(temp[3].y==0)return FALSE; temp[0].y-=1; temp[1].y-=1; temp[2].y-=1; temp[3].y-=1; if(Board.xy[temp[0].x][temp[0].y]!=0)return FALSE; if(Board.xy[temp[1].x][temp[1].y]!=0)return FALSE; if(Board.xy[temp[2].x][temp[2].y]!=0)return FALSE; if(Board.xy[temp[3].x][temp[3].y]!=0)return FALSE; break; } return TRUE; } void ObjectLLighting::RotateObject() { coordinate temp[4]; for(int i=0;i<4;i++) temp[i]=ShapeCoordinate[i]; if(pos==LLightSleep) { temp[0].y=temp[0].y+1; temp[0].x=temp[0].x-2; temp[1].y=temp[1].y; temp[1].x=temp[1].x-1; temp[2].y=temp[2].y+1; temp[2].x=temp[2].x; temp[3].y=temp[3].y; temp[3].x=temp[3].x+1;
  • 24. BOOL ch=DetectCollision(KEY_UP,temp);//checking new position is valid if(ch==FALSE)return; pos=LLightStanding; } else if(pos==LLightStanding) { temp[0].y=temp[0].y-1; temp[0].x=temp[0].x+2; temp[1].y=temp[1].y; temp[1].x=temp[1].x+1; temp[2].y=temp[2].y-1; temp[2].x=temp[2].x; temp[3].y=temp[3].y; temp[3].x=temp[3].x-1; BOOL ch=DetectCollision(KEY_UP,temp);//checking new position is valid if(ch==FALSE)return; pos=LLightSleep; } for(i=0;i<4;i++) ShapeCoordinate[i]=temp[i];//sending information back to main shape } void ObjectRLighting::RotateObject() { coordinate temp[4]; for(int i=0;i<4;i++) temp[i]=ShapeCoordinate[i]; if(pos==RLightSleep) { temp[0].y=temp[0].y-1; temp[0].x=temp[0].x-2; temp[1].y=temp[1].y; temp[1].x=temp[1].x-1; temp[2].y=temp[2].y-1; temp[2].x=temp[2].x; temp[3].y=temp[3].y; temp[3].x=temp[3].x+1;
  • 25. BOOL ch=DetectCollision(KEY_UP,temp);//checking new position is valid if(ch==FALSE)return; pos=RLightStanding; } else if(pos==RLightStanding) { temp[0].y=temp[0].y+1; temp[0].x=temp[0].x+2; temp[1].y=temp[1].y; temp[1].x=temp[1].x+1; temp[2].y=temp[2].y+1; temp[2].x=temp[2].x; temp[3].y=temp[3].y; temp[3].x=temp[3].x-1; BOOL ch=DetectCollision(KEY_UP,temp);//checking new position is valid if(ch==FALSE)return; pos=RLightSleep; } for(i=0;i<4;i++) ShapeCoordinate[i]=temp[i];//sending information back to main shape } void ObjectCross::RotateObject() { coordinate temp[4]; for(int i=0;i<4;i++) temp[i]=ShapeCoordinate[i]; BOOL ch; switch(pos) { case Cross1: temp[0].x=temp[0].x+1; temp[0].y=temp[0].y+1; temp[1].x=temp[1].x-1; temp[1].y=temp[1].y+1; temp[2].x=temp[2].x; temp[2].y=temp[2].y; temp[3].x=temp[3].x+1; temp[3].y=temp[3].y-1;
  • 26. ch=DetectCollision(KEY_UP,temp);//checking new position is valid if(ch==FALSE)return; pos=Cross2; break; case Cross2: temp[0].x=temp[0].x+1; temp[0].y=temp[0].y-1; temp[1].x=temp[1].x+1; temp[1].y=temp[1].y+1; temp[2].x=temp[2].x; temp[2].y=temp[2].y; temp[3].x=temp[3].x-1; temp[3].y=temp[3].y-1; ch=DetectCollision(KEY_UP,temp);//checking new position is valid if(ch==FALSE)return; pos=Cross3; break; case Cross3: temp[0].x=temp[0].x-1; temp[0].y=temp[0].y-1; temp[1].x=temp[1].x+1; temp[1].y=temp[1].y-1; temp[2].x=temp[2].x; temp[2].y=temp[2].y; temp[3].x=temp[3].x-1; temp[3].y=temp[3].y+1; ch=DetectCollision(KEY_UP,temp);//checking new position is valid if(ch==FALSE)return; pos=Cross4; break; case Cross4: temp[0].x=temp[0].x-1; temp[0].y=temp[0].y+1; temp[1].x=temp[1].x-1; temp[1].y=temp[1].y-1; temp[2].x=temp[2].x; temp[2].y=temp[2].y;
  • 27. temp[3].x=temp[3].x+1; temp[3].y=temp[3].y+1; ch=DetectCollision(KEY_UP,temp);//checking new position is valid if(ch==FALSE)return; pos=Cross1; break; } for(i=0;i<4;i++) ShapeCoordinate[i]=temp[i];//sending information back to main shape } void ObjectRL::RotateObject() { coordinate temp[4]; for(int i=0;i<4;i++) temp[i]=ShapeCoordinate[i]; BOOL ch; switch(pos) { case LL1: temp[0].x=temp[0].x+2; temp[0].y=temp[0].y; temp[1].x=temp[1].x-1; temp[1].y=temp[1].y+1; temp[2].x=temp[2].x; temp[2].y=temp[2].y; temp[3].x=temp[3].x+1; temp[3].y=temp[3].y-1; ch=DetectCollision(KEY_UP,temp);//checking new position is valid if(ch==FALSE)return; pos=LL2; break; case LL2: temp[0].x=temp[0].x; temp[0].y=temp[0].y-2; temp[1].x=temp[1].x+1; temp[1].y=temp[1].y+1;
  • 28. temp[2].x=temp[2].x; temp[2].y=temp[2].y; temp[3].x=temp[3].x-1; temp[3].y=temp[3].y-1; ch=DetectCollision(KEY_UP,temp);//checking new position is valid if(ch==FALSE)return; pos=LL3; break; case LL3: temp[0].x=temp[0].x-2; temp[0].y=temp[0].y; temp[1].x=temp[1].x+1; temp[1].y=temp[1].y-1; temp[2].x=temp[2].x; temp[2].y=temp[2].y; temp[3].x=temp[3].x-1; temp[3].y=temp[3].y+1; ch=DetectCollision(KEY_UP,temp);//checking new position is valid if(ch==FALSE)return; pos=LL4; break; case LL4: temp[0].x=temp[0].x; temp[0].y=temp[0].y+2; temp[1].x=temp[1].x-1; temp[1].y=temp[1].y-1; temp[2].x=temp[2].x; temp[2].y=temp[2].y; temp[3].x=temp[3].x+1; temp[3].y=temp[3].y+1; ch=DetectCollision(KEY_UP,temp);//checking new position is valid if(ch==FALSE)return; pos=LL1; break; } for(i=0;i<4;i++) ShapeCoordinate[i]=temp[i];//sending information back to main shape
  • 29. } void ObjectLL::RotateObject() { coordinate temp[4]; for(int i=0;i<4;i++) temp[i]=ShapeCoordinate[i]; BOOL ch; switch(pos) { case Cross1: temp[0].x=temp[0].x; temp[0].y=temp[0].y+2; temp[1].x=temp[1].x-1; temp[1].y=temp[1].y+1; temp[2].x=temp[2].x; temp[2].y=temp[2].y; temp[3].x=temp[3].x+1; temp[3].y=temp[3].y-1; ch=DetectCollision(KEY_UP,temp);//checking new position is valid if(ch==FALSE)return; pos=Cross2; break; case Cross2: temp[0].x=temp[0].x+2; temp[0].y=temp[0].y; temp[1].x=temp[1].x+1; temp[1].y=temp[1].y+1; temp[2].x=temp[2].x; temp[2].y=temp[2].y; temp[3].x=temp[3].x-1; temp[3].y=temp[3].y-1; ch=DetectCollision(KEY_UP,temp);//checking new position is valid if(ch==FALSE)return; pos=Cross3; break; case Cross3:
  • 30. temp[0].x=temp[0].x; temp[0].y=temp[0].y-2; temp[1].x=temp[1].x+1; temp[1].y=temp[1].y-1; temp[2].x=temp[2].x; temp[2].y=temp[2].y; temp[3].x=temp[3].x-1; temp[3].y=temp[3].y+1; ch=DetectCollision(KEY_UP,temp);//checking new position is valid if(ch==FALSE)return; pos=Cross4; break; case Cross4: temp[0].x=temp[0].x-2; temp[0].y=temp[0].y; temp[1].x=temp[1].x-1; temp[1].y=temp[1].y-1; temp[2].x=temp[2].x; temp[2].y=temp[2].y; temp[3].x=temp[3].x+1; temp[3].y=temp[3].y+1; ch=DetectCollision(KEY_UP,temp);//checking new position is valid if(ch==FALSE)return; pos=Cross1; break; } for(i=0;i<4;i++) ShapeCoordinate[i]=temp[i];//sending information back to main shape } void MainClass::PreScreen() { int j=40; settextstyle(7,0,5); char g[][2]={"T","E","T","R","I","S"," ","R","O","Y","A","L","E"}; for(int p=0;p<13;p++) { for(int h=480;h>=j;h-=20) { if(strcmp(g[p]," ")) {
  • 31. setcolor((p+2)/2); outtextxy(h,100,g[p]); setcolor(BLACK); outtextxy(h+20,100,g[p]); delay(20); } } j+=20; } settextstyle(6,0,3); setcolor(MAGENTA); outtextxy(200,150,"COMPUTER INVESTIGATORY PROJECT"); delay(600); cleardevice(); setcolor(YELLOW); settextstyle(6,0,5); outtextxy(100,200,"BY MEENALOSHINI"); getch(); cout<<"Enter Player Name : "; cin>>Player; fstream file; file.open("name.txt",ios::app); file<<"name of the player:"<<Player<<endl; file.close(); cleardevice(); } ---------------------------------------------------------------------------------------------------------------------- TEMP CPP FILE: void MainClass::DisplayNextBrick(short next) { setfillstyle(1,0); bar(410,205,495,290); coordinate temp[4]; int i; switch(next) { case 0: temp[0].x=temp[1].x=temp[2].x=temp[3].x=0; temp[0].y=5;temp[1].y=6;temp[2].y=7;temp[3].y=8; setcolor(RED); for(i=0;i<4;i++) DrawBrick(315+temp[i].y*20,temp[i].x*20+220,RED); break; case 1: temp[0].x=0; temp[1].x=0; temp[2].x=1; temp[3].x=1; temp[0].y=5; temp[1].y=6;
  • 33. setcolor(CYAN); for(i=0;i<4;i++) DrawBrick(315+temp[i].y*20,temp[i].x*20+220,CYAN); break; case 5: temp[0].x=0; temp[1].x=1; temp[2].x=1; temp[3].x=2; temp[0].y=6; temp[1].y=6; temp[2].y=5; temp[3].y=5; setcolor(6); for(i=0;i<4;i++) DrawBrick(315+temp[i].y*20,temp[i].x*20+220,BROWN); break; case 6: temp[0].x=0; temp[1].x=1; temp[2].x=1; temp[3].x=1; temp[0].y=6; temp[1].y=5; temp[2].y=6; temp[3].y=7; setcolor(DARKGRAY); for(i=0;i<4;i++) DrawBrick(315+temp[i].y*20,temp[i].x*20+220,DARKGRAY); break; } } SECOND CPP FILE: struct bitmap { short bit[20][20]; }; class BITMAP { void *character; public: // BITMAP(); void* DrawImage(bitmap &bit,int x,int y); }; void* BITMAP::DrawImage(bitmap &bit,int x,int y) { int i,j; for(j=y;j<y+20;j++)
  • 34. { for(i=x;i<x+20;i++) { putpixel(i,j,bit.bit[j-y][i-x]); } } int size=imagesize(x,y,x+20,y+20); character=malloc(size); getimage(x,y,x+20,y+20,character); putimage(x,y,character,XOR_PUT); return character; }; void button(int x,int y,int Color,int Color1) { int utri[6] = { x+1,y+1, x+19,y, x,y+19 }; int ltri[6] = { x+19,y+19, x+19,y+1, x+1,y+19 }; setcolor(BLACK); setfillstyle(1,Color1); fillpoly(3, utri); setfillstyle(1,BLACK); fillpoly(3, ltri); setfillstyle(1,Color); bar(x+5, y+5, x+15, y+15); }; SQUREOBJECT CPP FILE: class ObjectSqure:public MainClass { public: void PutNewObjectOnBoard(BOOL bDraw); }; void ObjectSqure::PutNewObjectOnBoard(BOOL bDraw) { ShapeTemp[0].x=0; ShapeTemp[1].x=0; ShapeTemp[2].x=1; ShapeTemp[3].x=1; ShapeTemp[0].y=5; ShapeTemp[1].y=6; ShapeTemp[2].y=5; ShapeTemp[3].y=6;
  • 35. if(bDraw==TRUE) for(int i=0;i<4;i++) ShapeCoordinate[i]=ShapeTemp[i]; } LINEOBJECT CPP FILE: class ObjectLine:public MainClass { public: void PutNewObjectOnBoard(BOOL bDraw); void RotateObject(); BOOL MoveObject(short key); }; void ObjectLine::PutNewObjectOnBoard(BOOL bDraw) { ShapeTemp[0].x=ShapeTemp[1].x=ShapeTemp[2].x=ShapeTemp[3].x=0; ShapeTemp[0].y=5;ShapeTemp[1].y=6;ShapeTemp[2].y=7;ShapeTemp[3].y=8; if(bDraw==TRUE) for(int i=0;i<4;i++) ShapeCoordinate[i]=ShapeTemp[i]; }; void ObjectLine::RotateObject() { coordinate temp[4]; for(int i=0;i<4;i++) { temp[i]=ShapeCoordinate[i]; } if(pos==SLEEP) { temp[1].x=temp[0].x+1; temp[1].y=temp[0].y; temp[2].x=temp[0].x+2; temp[2].y=temp[0].y; temp[3].x=temp[0].x+3; temp[3].y=temp[0].y; BOOL ch=DetectCollision(KEY_UP,temp);//checking new position is valid if(ch==FALSE)return; pos=STANDING; } else if(pos==STANDING) { temp[1].y=temp[0].y+1;
  • 36. temp[1].x=temp[0].x; temp[2].y=temp[0].y+2; temp[2].x=temp[0].x; temp[3].y=temp[0].y+3; temp[3].x=temp[0].x; BOOL ch=DetectCollision(KEY_UP,temp);//checking new position is valid if(ch==FALSE)return; pos=SLEEP; } for(i=0;i<4;i++) ShapeCoordinate[i]=temp[i];//sending information back to main shape } MAINCLAS CPP FILE: void MainClass::DrawScreen() { setfillstyle(1,LIGHTGRAY); //setting initial color to grey bar(50,30,370,450); setfillstyle(1,0); bar(56,36,364,444); setcolor(DARKGRAY); //setting color white to give 3d look rectangle(55,35,364,445); rectangle(52,32,367,448); setcolor(WHITE); rectangle(53,33,366,447); rectangle(50,30,369,450); ///Darwing SideBlock Containing Other Information setcolor(DARKGRAY); //setting color white to give 3d look rectangle(405,35,604,445); rectangle(402,32,607,448); line(405,290,604,290); line(405,293,604,293); line(405,180,604,180); line(405,184,604,184); line(500,180,500,290); line(504,184,504,294); setcolor(LIGHTGRAY); rectangle(404,34,605,446); rectangle(401,31,608,449); line(405,291,604,291); line(405,293,604,293); line(405,181,604,181); line(405,183,604,183);
  • 37. line(501,181,501,291); line(503,183,503,293); setcolor(WHITE); rectangle(403,33,606,447); rectangle(400,30,609,450); line(405,292,604,292); line(402,182,604,182); line(502,182,502,292); //Feeding Box INformation settextstyle(3,0,1); setcolor(CYAN); outtextxy(460,300,"Key Help"); char *y; if(!(y=new char[2])) {cout<<"Insufficent Memory"; exit(1); } //checking is required amount memory provided y[1]=char(26); y[2]='0'; setcolor(LIGHTMAGENTA); settextstyle(DEFAULT_FONT,0,1); outtextxy(420,330,y); y[1]=char(27); outtextxy(420,350,y); y[1]=char(24); outtextxy(420,370,y); y[1]=char(25); outtextxy(420,390,y); outtextxy(480,330,": Move Left "); outtextxy(480,350,": Move Right "); outtextxy(480,370,": Rotate Object"); outtextxy(480,390,": Drop Object"); outtextxy(430,410,"ENTER : Pause"); outtextxy(430,430,"Esc : Exit"); setcolor(0); bar(415,325,425,400); setcolor(RED); settextstyle(DEFAULT_FONT,0,1); rectangle(400,30,609,450); setcolor(YELLOW); outtextxy(410,40, "Score:");
  • 38. rectangle(410,50,490,70); outtextxy(520,40, "Level:"); rectangle(520,50,600,70); outtextxy(410,90, "Speed:"); rectangle(410,100,490,120); outtextxy(520,90, "Lines Up:"); rectangle(520,100,600,120); outtextxy(420,140, "Player Name"); rectangle(420,150,600,170); setcolor(BROWN); outtextxy(410,190,"Next Brick"); outtextxy(510,190,"Message Box"); setcolor(GREEN); outtextxy(425,155,Player); /* outtextxy(410,50,"Player Name"); outtextxy(410,125,"No. of Lines"); outtextxy(410,200,"Total Score"); setlinestyle(0,0,1); //the score rectangle rectangle(449,84,591,116); rectangle(449,159,591,191); rectangle(449,234,591,266); */ setcolor(YELLOW); rectangle(59,39,361,441); }; void MainClass::DrawBrick(int x,int y,int color) { int color2=color+8; if(color==BLACK)color2=BLACK; if(color==DARKGRAY)color2=LIGHTGRAY; button(x,y,color,color2); /* int size=imagesize(x,y,x+20,y+20); Buff=malloc(size); getimage(x,y,x+20,y+20,Buff); putimage(x,y,Buff,XOR_PUT); return Buff; */ } void MainClass::CheckForLine() {
  • 39. int i=ROW,j=0; int check; for(;i>0;i--) { check=0; while(j!=COL) { if(Board.xy[i][j]==0) break; check++; if(check==15) RemoveLine(i); j++; } j=0;//making cols zero again ti begin next testing routine } } void MainClass::RemoveLine(int LineNumber) { int i,j; for(i=0; i<COL; i++) Board.xy[LineNumber][i]=0; for(i=LineNumber; i>0; i--) for(j=0; j<COL; j++) { Board.xy[i][j] = Board.xy[i-1][j]; Board.xy[i-1][j]=0; } setfillstyle(SOLID_FILL,BLACK); bar(60,40,360,440); for(i=0; i<ROW; i++) for(j=0; j<COL; j++) if(Board.xy[i][j]!=0) { switch(Board.xy[i][j]) { case RED: DrawBrick(60+j*20,i*20+40,RED);break; case BLUE:DrawBrick(60+j*20,i*20+40,BLUE);break; case CYAN:DrawBrick(60+j*20,i*20+40,CYAN);break; case MAGENTA:DrawBrick(60+j*20,i*20+40,MAGENTA);break; case DARKGRAY:DrawBrick(60+j*20,i*20+40,DARKGRAY);break; case BROWN:DrawBrick(60+j*20,i*20+40,BROWN);break;
  • 40. case GREEN:DrawBrick(60+j*20,i*20+40,GREEN);break; } } // //Now doing Cleansing up And Incrementing Score OLineClear++; // Score+=10; UpdateScore(); } void MainClass::MsgBox(int x,char *string,BOOL bErase) { setfillstyle(SOLID_FILL,BLACK); setcolor(YELLOW); if(bErase==TRUE) bar(505,200,603,290); settextstyle(SMALL_FONT,0,5); outtextxy(510,x,string); } void MainClass::UpdateScore() { char string[10]; settextstyle(SMALL_FONT,0,6); setfillstyle(SOLID_FILL,BLACK); setcolor(LIGHTBLUE); //Score bar(411,51,489,69); ultoa(Score,string,10); outtextxy(420,52,string); //Level bar(521,51,599,69); ultoa(Level,string,10); outtextxy(530,52,string); //Speed bar(411,101,489,119); itoa((100-Speed),string,10); outtextxy(420,102,string); //Lines Up bar(521,101,599,119); ultoa(LineCleared,string,10); outtextxy(530,102,string); }
  • 43. FILE SCREEN SCREEN TO ENTER NAME AND DOB SCREEN OF GAME OVER
  • 44. BIBLIOGRAPHY https://www.planet-source- code.com/vb/scripts/ShowCode.asp?txtCodeId=1086&lngWId=3 (source code) https://www.w3schools.com/cpp/cpp_getstarted.asp (c++ introduction) https://www.tutorialspoint.com/cplusplus/cpp_polymorphism.html (polymorphism) https://www.geeksforgeeks.org/inheritance-in-c/ (inheritance) https://beginnersbook.com/2017/09/cpp-encapsulation/ (encapsulation) https://en.wikipedia.org/wiki/Tetris (tetris game) https://www.studytonight.com/cpp/file-streams-in-cpp.php (file streams) https://www.quora.com/How-is-modularity-introduced-in-c++ (modularity) https://www.w3schools.in/cplusplus-tutorial/data-abstraction/ (abstraction)