Date post: | 04-Apr-2018 |
Category: |
Documents |
Upload: | vikas-gunti |
View: | 233 times |
Download: | 0 times |
of 47
7/29/2019 Adventurous Car Game Final Document
1/47
1
ADVENTUROUS ROAD RACING
A report submitted in partial fulfillment of requirements of the Mini Project of
Bachelor of Technology
In
Computer Science and Engineering
SAI VIKAS GUNTI (11003185)
MANOJ KUMAR ANNBATTHINA (11003034)
SAI VINOD MANNAM (11003179)
SAI DINESH BOORSU (11003179)
Under the Guidance of
DR.RAJESHWARA RAO
Department of Computer Science and Engineering
KL University, Vaddeswaram, Guntur Dt.
2012-13
7/29/2019 Adventurous Car Game Final Document
2/47
2
KL University
Department of CSE
Certificate
This is to certify that the project work entitled
ADVENTUROUS ROAD RACING being submitted to department
of Computer Science and Engineering, KL University by SAI VIKAS
GUNTI (11003185) in partial fulfillment for the Mini Project, is a
bonafide work carried out by them under my supervision.
GUIDE HOD, CSE
DR. RAJESHWARA RAO (Dr.V.Srikanth)
7/29/2019 Adventurous Car Game Final Document
3/47
3
Acknowledgement
I have taken efforts in this project. However, it would not have been
possible without the kind, support and help of Dr. V. Srikanth,
Professor & Head of the Department and Second year coordinator
Mr. K.V.D.Kiran, Assistant Professor. I would like to extend my
sincere thanks to all of them.
I am highly indebted to DR. RAJESHWARA RAO, Professor for his
guidance and constant supervision as well as for providing necessary
information regarding the project & also for his support in completing
the project.
I would like to express my special gratitude and thanks to all the
faculty and staff for giving me such attention and time.
I would like to express my gratitude towards my parents for their kind
co-operation and encouragement which help me in completion of this
project.
My thanks and appreciations also go to my friends in developing the
project and people who have willingly helped me out with their
abilities.
SAI VIKAS GUNTI (11003185)
MANOJ KUMAR ANNABATTHINA (11003034)
SAI VINOD MANNAM (11003104)
SAI DINESH BOORSU (11003179)
7/29/2019 Adventurous Car Game Final Document
4/47
4
Abstract
Our mini project tittle is ADVENTUROUS ROAD RACING USING
C++ we students of II/IV computer science engineering has done
a C++ program for car game. We have done this using the feature
in c++ called class. We have used graphic features of c++. We
have created different functions for different menus in the game.
The main aim of this game is to ride a car using cursor keys. We
can attain this by moving car away from the rectangular obstacles
that we have encountered on the road. We have done this using dos
box compiler. We had tried to reduce maximum problems in our
program. Even though it maycontains several technical and
logical problems. We have done this for mini project as part our
curriculum for the academic year 2012-2013......
7/29/2019 Adventurous Car Game Final Document
5/47
5
Table of Content
Page No.
1.Introduction 1-22.Problem Statement 33.Problem Solution 44.Software and Hardware Specifications 55.Algorithm 6-136.Inputs 147.Source Code 15- 348.Output Screen Shots 35-409.Conclusion 4110. References 42
7/29/2019 Adventurous Car Game Final Document
6/47
6
1. INTRODUCTION
Our mini project title is adventurous car game using c++ For this we have used c++ programming We have used a special future in c++ called class. We have used many other graphic functions for this game design
..
The main aim of this game is to ride a car using cursor keys .Bymoving away from the rectangular obstacles that we have
encountered on the road
will be rectangle obstacles on road we have to drive through thatroad by moving away from these obstacles ..
These obstacles are created by using some graphic futures. The following are futures used for program coding :
I) Class. II) Constructers III) Graphic functions.
I) Definition for class:
Class: A class is a type definition of an Object Oriented
Programming object in the C++ and C# languages.
II) Definition for constructor:
7/29/2019 Adventurous Car Game Final Document
7/47
7
III) Definition for graphic functions:
The graphic functions are mostly predefined functions in compiler
which are used to create graphic objects on the screen.
By using these features of c++ we have written code for the carthe game by writing several functions we have achieved the
task.
The following are the features of our game :I) Easily accessible menu.
II) Three chance every time.
III) Fast moving attractive car.
IV) Road full of obstacles.
V) Attractive environment.
VI) Saving scores.
We have done this using dos box compiler. We had tried to reduce maximum problems in our program.
Even though it may contains several technical and logical
problems. We have done this for mini project as part ourcurriculum for the academic year 2012-2013......
7/29/2019 Adventurous Car Game Final Document
8/47
8
2. PROBLEM STATEMENT
Comparison with real world:
Many of us in this world have desire to ride a car with speed, and
want to ride it in the adventurously, want to ride it in a road full of
obstacles. This is one of the problems which leaded us to design this
game.
In reference to kids:
Manly kids want to play car racing game which gives them lots of
fun. They want to play the games which are having good graphical
features. Different Colors gives them joy .so they wants to play
mostly car games which are having color full environment .This is
one of the problem which leads us to design the game like this.
In reference to adults:
Many of the employees and other business people have many
problems and they came home with tiredness. In order to get relieved
from that tiredness they want to play games. For such people we have
designed this game.
These are the main three problems which we have thought about for
the design of the game.
7/29/2019 Adventurous Car Game Final Document
9/47
9
3. PROBLEM SOLVING
We have discussed problems which we have thought for severaldays. Then we the team members discussed among us about
these problems which several people are suffering in this world.
Then our team members come up with a good idea to create a
car game which consists of obstacles, good environment, and
with color full car and road side environment.
Then we have decided to design a game with graphic featuresusing c++ language. We have designed a game in which there
are the features which are required for the different types of
people which we have discussed before in the problem
statement.
The game we have designed gives fun to kids, thrill to adultsand refreshing to working people.
Thus we have named our game as Adventurous Road racing".
Then finally our car games which we have designed become thetool to solve those problems.
7/29/2019 Adventurous Car Game Final Document
10/47
10
4.SOFTWARE AND HARDWARE REQUIREMENT
Software:Dosbox0.74
Hardware:*processor: Intel core i3-2310M (2.1 GHz, 3MB).
*Operating system: Windows7 professional 64-bit/windows xp
/windows vista/windows 98.
* Ram: 4GB DDR3 1333 MHZ/2GB/any other lower (or) higher
capacity rams.
*Hard disk: 500GB 7200rpm/250 GB/ any other higher (or) lower
capacity disk.
7/29/2019 Adventurous Car Game Final Document
11/47
11
5. ALGORITHM
Step1:First create a class with named car;In this class define functions for score , and after that define a overload anotherfunction in that define level scores .
In class car define variables for velocity, initiation of scores players names.
Step2: create functions in which directions the car have to move .They are : void right()
void right()
void right()
{
if(car.cp180)
{
car.cp-=10;
}
return;
}
7/29/2019 Adventurous Car Game Final Document
12/47
12
Step3: Initialize functions for store scores and display the score .Void score store ()
Here in this functions we have created a file and store players names in it.
Use open& write functions.
Void disp_score ()
Use if stream function to display the score.
Step4: create function for display of car and to move it.Void bgmove ()
Here in this function we have graphic related functions like setcolor,
Setfillstyle, bar, sector.
In this function create obstacles using bar function in graphics mode.
setcolor (RED);
setfillstyle(SOLID_FILL,RED);
sector(car.cp+20,330,0,180,20,30);
setfillstyle(SOLID_FILL,YELLOW);
bar3d(car.cp,333,car.cp+37,360,4,4);
sector(car.cp+20,362,180,360,20,10);
for(int i=car.init;i
7/29/2019 Adventurous Car Game Final Document
13/47
13
Step5:Intialize functions for creation of logo, and create functions forloss and win of game and score of game.
Void logo()
In this function use graphic mode functions setcolor,
Settextstyle, outtextxy, bar3d, setfillstyle
Void loss ()
If we hit the obstacle then we will lose one chance
Void over()
If loss three chances then this function will be executed.
Void win()
If we win two levels then this function will be executed.
void logo ()
{
for(int i=1;i
7/29/2019 Adventurous Car Game Final Document
14/47
14
}
delay(2000);
cleardevice();
return;
void loss(void)
{
setcolor(10);
settextstyle(2,0,9);
outtextxy(180,150,"ONE CHANCE LOST");
delay(1000);
return;
}
void win()
{
cleardevice();
for(int k=0;k
7/29/2019 Adventurous Car Game Final Document
15/47
15
delay(150);
}
}
delay(3000);
score_store();
return;
}
Step6:create function for play in this stepHere in this function we have assign keys to run the car
In this function we have used a keyword called as kbhit()
if(kbhit())
{
m=getch();
switch(m)
{
case LEFT: left();
break;
case RIGHT: right();
break;
case 'q':exit(0);
}
}
else{
delay(100); }
7/29/2019 Adventurous Car Game Final Document
16/47
16
}
getch();
return(0);
}
Step7: crea te funct ion fo r m enu o f gameVoid main()
Here in this function use graphic mode functions for display of menu .
These functions are setcolor, outtextxy, settextstyle
Next by using switch case define up and down movement of cursor.
switch(a)
{
case UP:if(p>140)
{
p-=30;
s--;
}
break;
case DOWN:if(p
7/29/2019 Adventurous Car Game Final Document
17/47
17
break;
default:break;
}
}
while(a!=1);
switch(s)
{
case 1:play();
break;
case 2:disp_score();
break;
case 3:help();
break;
case 4:about();
break;
case 5:exit(0);
default:cprintf("Invalid choice");
break;
}
}
while(t==0);
getch();
}
7/29/2019 Adventurous Car Game Final Document
18/47
18
Step 8: Write main() function with graphics initiations and close it .
void main()
{
int gdriver=DETECT,gmode,errorcode;
initgraph(&gdriver,&gmode,"");cleardevice();
logo();
menu();
closegraph();
}
7/29/2019 Adventurous Car Game Final Document
19/47
19
6. INPUTS
Class input:
Create a class using a name called car, define all variables
required for the coding and function members inside the class.
Constructer input:
Create a constructer and write the code .
Graphical input:
The predefined graphical functions are used in this coding
they are:
Setcolor.
Settextstyle.
Outtextxy.
Ifstream.
Setfillstyle.
Sector.
Setfillstyle.
Bar3d.
Kbhit.
7/29/2019 Adventurous Car Game Final Document
20/47
20
7. SOURCE CODE
#include
#include
#include
#include
#include
#include
#include
#define LEFT 75
#define RIGHT 77
#define UP 72
#define DOWN 80
#define ENTER 13
class CAR
{
public:
int vel,cp,init,op1,op2,op3,level;
long score;
long lev_score[5];
char player[20];
CAR::CAR()
{
level=1;
vel=1;
7/29/2019 Adventurous Car Game Final Document
21/47
21
cp=300;
init=0;
op1=0;
op2=-20;
op3=-40;
score=0;
lev_score[0]=10000;lev_score[1]=30000;lev_score[2]=60000;lev_score[3]=100
000;lev_score[4]=150000;
}
}car;
int randx(void)
{
int x=random(56*8);
if(x
7/29/2019 Adventurous Car Game Final Document
22/47
22
return;
}
void left()
{
if(car.cp>180)
{
car.cp-=10;
}
return;
}
void score_store()
{
cleardevice();
setcolor(4);
settextstyle(2,0,6);
outtextxy(10,0,"Your score is");
gotoxy(20,2);cout
7/29/2019 Adventurous Car Game Final Document
23/47
23
void disp_score()
{
cleardevice();
setcolor(5);
settextstyle(2,0,9);
outtextxy(200,20,"SCORE BOARD");
ifstream score("score.dat");
char ch; int i=0;gotoxy(1,5);
while(score.get(ch))
{
score.seekg(i,ios::beg);
score.get(ch);
cout
7/29/2019 Adventurous Car Game Final Document
24/47
24
else
{
car.init+=car.vel;
}
setcolor(RED);
setfillstyle(SOLID_FILL,RED);
sector(car.cp+20,330,0,180,20,30);
setfillstyle(SOLID_FILL,YELLOW);
bar3d(car.cp,333,car.cp+37,360,4,4);
sector(car.cp+20,362,180,360,20,10);
for(int i=car.init;i
7/29/2019 Adventurous Car Game Final Document
25/47
25
setfillstyle(1,RED);
bar3d(x1,car.op1,x1+30,car.op1+30,2,3);
}
else
{
car.op1=0;
}
return;
}
void opp2(int x2)
{
if(car.op2
7/29/2019 Adventurous Car Game Final Document
26/47
26
{
if(car.op3
7/29/2019 Adventurous Car Game Final Document
27/47
27
for(i=0;i
7/29/2019 Adventurous Car Game Final Document
28/47
28
{
setcolor(YELLOW);setfillstyle(SOLID_FILL,YELLOW);
settextstyle(4,HORIZ_DIR,5);
outtextxy(100,100,"adventerous ROAD");
outtextxy(200,140,"RACING");
bar3d(50,200,550,220,10,40);
setcolor(GREEN);
settextstyle(1,HORIZ_DIR,2);
outtextxy(100,400,"LOADING");setfillstyle(SOLID_FILL,GREEN);
bar(190,400,190+i,420);
delay(25);
}
delay(2000);
cleardevice();
return;
}
void loss(void)
{
setcolor(10);
settextstyle(2,0,9);
outtextxy(180,150,"ONE CHANCE LOST");
delay(1000);
return;
}
7/29/2019 Adventurous Car Game Final Document
29/47
29
void over(void)
{
for(int i=1;i
7/29/2019 Adventurous Car Game Final Document
30/47
30
void win()
{
cleardevice();
for(int k=0;k
7/29/2019 Adventurous Car Game Final Document
31/47
31
{
car.level++;
if(car.vel
7/29/2019 Adventurous Car Game Final Document
32/47
32
while(!kbhit())
{
for(int i=300;i
7/29/2019 Adventurous Car Game Final Document
33/47
33
outtextxy(350,600-i,"kluniversity");
setfillstyle(1,4);
bar3d(180,380,450,460,4,6);
setcolor(1);
settextstyle(2,0,10);
outtextxy(280,380,"Section F");
outtextxy(215,420,"20012-2013");
delay(60);
}
}
getch();
return;
}
int play(void)
{
int life=3,m,x1,x2,x3,s;
re:
while(life)
{
cleardevice();
if(car.op1==0)
{
x1=randx();
car.op1++;
7/29/2019 Adventurous Car Game Final Document
34/47
34
}
else
{
opp1(x1);
}
if(car.op2==0)
{
x2=randx();
car.op2++;
}
else if(car.op2
7/29/2019 Adventurous Car Game Final Document
35/47
35
{
opp3(x3);
}
setcolor(10);
setfillstyle(0,0);
bar3d(0,0,80,70,4,3);
bgmove();
level();
score();
settextstyle(2,0,6);
setcolor(5);
outtextxy(4,44,"Life");
gotoxy(8,4);cout
7/29/2019 Adventurous Car Game Final Document
36/47
36
goto re;
}
if(kbhit())
{
m=getch();
switch(m)
{
case LEFT: left();
break;
case RIGHT: right();
break;
case 'q':exit(0);
}
}
else{
delay(100); }
}
getch();
return(0);
}
void help()
{
cleardevice();
settextstyle(4,0,6);setcolor(13);
7/29/2019 Adventurous Car Game Final Document
37/47
37
outtextxy(200,10,"HELP");textcolor(YELLOW);gotoxy(3,6);
cout
7/29/2019 Adventurous Car Game Final Document
38/47
38
outtextxy(220,197,"HELP");
outtextxy(220,227,"ABOUT");
outtextxy(220,257,"EXIT");
setcolor(RED);
rectangle(200,p,350,p+20);
a=getch();
switch(a)
{
case UP:if(p>140)
{p-=30;
s--;}
break;
case DOWN:if(p
7/29/2019 Adventurous Car Game Final Document
39/47
39
break;
case 2:disp_score();
break;
case 3:help();
break;
case 4:about();
break;
case 5:exit(0);
default:cprintf("Invalid choice");
break;
}
}while(t==0);
getch();
}
void main()
{
int gdriver=DETECT,gmode,errorcode;
initgraph(&gdriver,&gmode,"");cleardevice();
logo();
menu();
closegraph();
}
7/29/2019 Adventurous Car Game Final Document
40/47
40
8. OUTPUT SCREENS
1)
This output screen shows the opening screen of the game.
7/29/2019 Adventurous Car Game Final Document
41/47
41
2)
This output screen shows the menu of the game and we have to
Select the appropriate menu which we required
7/29/2019 Adventurous Car Game Final Document
42/47
42
3)
This output screen shows the scoreboard of the players who
played game .
7/29/2019 Adventurous Car Game Final Document
43/47
43
4)
This output screen shows the help menu of the game which will
be more help full for new users.
7/29/2019 Adventurous Car Game Final Document
44/47
44
5)
This output screen shows the about menu in the game which
says about game developers.
7/29/2019 Adventurous Car Game Final Document
45/47
45
6)
This output screen shows the main screen of the game while car
is running.
7/29/2019 Adventurous Car Game Final Document
46/47
46
10.CONCLUSION
Thus we the students of II/IV computer science department havedesigned a car game as our mini project.
This Adventurous road racing game is game designed by team workour team members, the credits must belongs to all the members in our
team.
It is a very easy game with only one car with colorful environmentaround the car ,and hope this will liked by many.
We had tried to reduce maximum problems in our program. Eventhough it may contains several technical and logical problems.
We have done this for mini project as part our curriculum for theacademic year 2012-2013......
Finally we hope that there will some enjoyment for those who playour game .
We are very much thankful to our guide Dr.Rajeshwara Rao sir forhis guidance and prior encouragement .
We sincerely thankful to Mrs.Diyva mam(asso.professer)departmentof computer science kl university for her guidance in making of
reports and for outcome this final document of our mini project.
7/29/2019 Adventurous Car Game Final Document
47/47
10.REFERENCES
THE COMPLETE REFRENCE TO C++BY HERBERT SCHILDT.
C++ HOW TO PROGRAMBY DEITEL&DEITEL.
h t tp : / /www. f r eecodesou rce .com.h t tp : / /www.sourcecodeswor ld .com/source h t tp : / /cp lus .abou t .com