Gaming Console 10.01
Chapter 1 - Introduction
1.1 Introduction to C++
[1]
C++ is a statically typed, free-form, multi-paradigm, compiled, general purpose programming language. It is regarded as an intermediate-level language, as it comprises both high-level and low-level language features. Developed by Bjarne Stroustrup starting in 1979 at Bell Labs, C++ was originally named C with Classes, adding object oriented features, such as classes, and other enhancements to the C programming language. The language was renamed C++ in 1983, as a pun involving the increment operator. C++ is one of the most popular programming languages and is implemented on a wide variety of hardware and operating system platforms. As an efficient compiler to native code, its application domains include systems s ystems software, application software, device drivers, embedded software, high-performance server and client applications, and entertainment software such as video games. Several groups provide both free and proprietary C++ compiler software, including the GNU Project, LLVM, Microsoft, Intel and Embarcadero Technologies. C++ has greatly influenced many other popular programming languages, most notably C# and Java. C++ is also used for hardware design, where the design is initially described in C++, then analyzed, architecturally constrained, and scheduled to create a register-transfer level hardware description language via high-level synthesis. The language began as enhancements to C, first adding classes, then virtual functions, operator overloading, multiple inheritance, templates and exception handling, among other features. After years of development, the C++ programming language standard was ratified in 1998 as ISO/IEC 14882:1998. 14882:1998.
1.2 Introduction to Games
[1]
A game is structured playing, usually undertaken for enjoyment and or sometimes used as an educational tool. Games are distinct from work, which is usually carried out for remuneration, and from f rom art, which is more often an expression ex pression of aesthetic or ideological elements. However, the distinction is not clear-cut, and many games are also considered to be work or art. Key components of games are goals, rules, challenge, and interaction. Games generally involve mental or physical stimulation, and or often both. Many games help develop practical skills, serve as a form of exercise, or otherwise perform an educational, simulational, or psychological role. 1 Anant Agarwal
A2305211310
Gaming Console 10.01 Attested as early as 2600 BC, games are a universal part of human experience and present in all cultures. The Royal Game of Ur, Senet, andMancala are some of the oldest known games.
1.3 Introduction to Gaming Console 10.01
The “Gaming Console 10.01” is a project work based on C++. It consists of a platform containing many games consolidated in a single application. The console consists of the following games: 1. Maze Game: It is basically the classic puzzle game consisting of many different levels, wherein one needs to solve the maze by moving the block from the „Start‟ position to the „End‟ position using the arrow keys of the keyboard. 2. Tic-Tac-Toe: Another classic game. The name says it all, nothing to describe the classic „knots and crosses‟ game. Select game. Select the position to play using the Num-Pad of your keyboard. 3. CompCricket: The game is an adapted version of the classic school gam e „Book Cricket‟. It makes use of the random number generator function to pla y the game. 4. Bounce: A small screen saver lasting a few seconds, showing a bit of the graphical commands.
The „Gaming Console‟ consists of all the games from the past that are always fun to play, all in a single location. The console can be upgraded and new games can be easily added.
Chapter 2 – Materials Materials and Methods 2 Anant Agarwal
A2305211310
Gaming Console 10.01 Attested as early as 2600 BC, games are a universal part of human experience and present in all cultures. The Royal Game of Ur, Senet, andMancala are some of the oldest known games.
1.3 Introduction to Gaming Console 10.01
The “Gaming Console 10.01” is a project work based on C++. It consists of a platform containing many games consolidated in a single application. The console consists of the following games: 1. Maze Game: It is basically the classic puzzle game consisting of many different levels, wherein one needs to solve the maze by moving the block from the „Start‟ position to the „End‟ position using the arrow keys of the keyboard. 2. Tic-Tac-Toe: Another classic game. The name says it all, nothing to describe the classic „knots and crosses‟ game. Select game. Select the position to play using the Num-Pad of your keyboard. 3. CompCricket: The game is an adapted version of the classic school gam e „Book Cricket‟. It makes use of the random number generator function to pla y the game. 4. Bounce: A small screen saver lasting a few seconds, showing a bit of the graphical commands.
The „Gaming Console‟ consists of all the games from the past that are always fun to play, all in a single location. The console can be upgraded and new games can be easily added.
Chapter 2 – Materials Materials and Methods 2 Anant Agarwal
A2305211310
Gaming Console 10.01
2.1 System Requirements 2.1.1 Hardware Requirements
1. 2. 3. 4. 5. 2.1.2
Processor Pentium 4 or higher Hard Disk Drive Graphics Card RAM Keyboard
Software Requirement
1. 2. 3. 4.
OS Windows XP or higher Graphics compliant C++ Compiler (Turbo C++) Graphics Library General Peripheral Drivers
2.2 Methodology 1. 2. 3. 4.
The programming done for “Gaming Console 10.01” is entirely based on C++ Graphics programming has been used for the GUI Keyboard has also been programmed to facilitate movement using arrow keys. Concept of Object Oriented Programming has been well implemented.
2.3 Concept 2.3.1 Console
The “Gaming Console” is a platform to consolidate and collaborate several different games in a single application. The gaming console programmed and developed for this project contains four different games which have been thoroughly explained below and are as follows: 1. 2. 3. 4.
Maze Game Tic-Tac-Toe CompCricket Bounce
2.3.2 Maze Game
3 Anant Agarwal
A2305211310
Gaming Console 10.01 The maze game is a classic puzzle game from time immortal. In this particular development keyboard‟s arrow keys have been coded and programmed and programmed to move the box across the maze.
How to play? 1. The game has over 4 different levels. 2. Difficulty of each level increases as and when the levels progress. 3. Use the arrow keys to move the box starting from the START position marked by an „S‟ to the END position position marked by an „E‟ on the maze. 4. A counter shows clearly, how many moves, the player takes to solve t he maze. 5. The prime objective should be to reach from „S‟ to „E‟ in as many less moves as possible.
2.3.3 Tic-Tac-Toe
It is an all time favourites among many. No one I believe would be a stranger to this classic game. In this particular adaptation of the game the num pad has been coded and programmed to be used to play the game.
How to play? 1. 2. 3. 4. 5. 6.
Use the Num-Pad from 1-9 to play your move. Two players required. Player 1 uses Crosses („X‟) Player 2 uses Knots („O‟) Whoever gets 3 knots or crosses in a row ro w WINS. If all places fill out, game is TIED.
2.3.4 CompCricket
4 Anant Agarwal
A2305211310
Gaming Console 10.01 It is an adaption of another classic game from the school times called „Book Cricket‟, played using the page numbering of any random text book. In this particular adaptation, the player plays against the computer. The player enters a particular number from 1-6 and the computer generates a number from 1-6 using a random number function generator. If the number matches, the player is OUT.
How to play? 1. 2. 3. 4. 5.
User plays against the computer. User enters a number from 1-6. Computer generates a number from 1-6. If the number matches, the user/computer (whatever the case maybe) is out. Else the number is added to the user‟s /computer‟s (whatever the case maybe) score card. 6. User always bats first. 7. Game terminates as and when a decision is given.
2.3.5 Bounce
It is only a small simulation for a few seconds of a ball bouncing across the screen. It has been coded using the graphics controls present in C++ and is nothing but a showcase of the same.
Chapter 3 – Results and Discussions
5 Anant Agarwal
A2305211310
Gaming Console 10.01
3.1 Result All games have been coded and programmed successfully as per the original idea in mind. The same have also been combined together on a single platform as per the original concept. Screenshots and glimpses of the entire application are shown in detail below.
3.2 Screenshots
[6] [7]
Fig 1 – Welcome Screen
6 Anant Agarwal
A2305211310
Gaming Console 10.01
Fig 2 – Options Page
Fig 3 – Maze Game Page
7 Anant Agarwal
A2305211310
Gaming Console 10.01
Fig 3.1 – Maze Level 1
Fig 3.2 – Maze Loading Page
8 Anant Agarwal
A2305211310
Gaming Console 10.01
Fig 3.3 – Maze Level 2
Fig 3.4 – Maze Level 3
9 Anant Agarwal
A2305211310
Gaming Console 10.01
Fig 3.5 – Maze Level 4
Fig 3.6 – Maze Moves Page
10 Anant Agarwal
A2305211310
Gaming Console 10.01
Fig 3.7 – Maze Game Over
Fig 4 – Tic Tac Toe
11 Anant Agarwal
A2305211310
Gaming Console 10.01
Fig 4.1 – TicTacToe Board
Fig 4.2 – TicTacToe Gameplay
12 Anant Agarwal
A2305211310
Gaming Console 10.01
Fig 4.3 – TicTacToe Gameplay
Fig 4.4 – TicTacToe Win Page
13 Anant Agarwal
A2305211310
Gaming Console 10.01
Fig 5 – CompCricket Page
Fig 5.1 – Name Page
14 Anant Agarwal
A2305211310
Gaming Console 10.01
Fig 5.2 – CompCricket Gameplay
Fig 5.3 – CompCricket Gameplay
15 Anant Agarwal
A2305211310
Gaming Console 10.01
Fig 5.4 – CompCricket User OUT
Fig 5.5 – CompCricket Bowling
16 Anant Agarwal
A2305211310
Gaming Console 10.01
Fig 5.6 – CompCricket Gameplay
Fig 5.7 – CompCricket Winner
17 Anant Agarwal
A2305211310
Gaming Console 10.01
Fig 6.1 – Bounce 1
Fig 6.2 – Bounce 2
18 Anant Agarwal
A2305211310
Gaming Console 10.01
Fig 6.3 – Bounce 3
Fig 6.4 – Bounce 4
19 Anant Agarwal
A2305211310
Gaming Console 10.01
Fig 6.5 – Bounce 5
Fig 7 – Options Page
20 Anant Agarwal
A2305211310
Gaming Console 10.01
Fig 8 – Exit Page
21 Anant Agarwal
A2305211310
Gaming Console 10.01
Chapter 4 – Conclusions and Recommendations
1. The aim of this project was to develop a Gaming Console, in which several different games can be programmed and added in a single application.
2. As one‟s life these days is very hectic and stressful, games help a person to relax and rejuvenate to let him keep working forward.
3. The language used to code this project is C++, which is a very commonly used coding language, because of which this project can be made open source also.
4. There is a lot of scope of development, and many more games can be easily coded and added to the console anytime.
5. The Gaming Console can also be made online by using the help of HTML and PHP coding platforms for people to play it online.
22 Anant Agarwal
A2305211310
Gaming Console 10.01
Chapter 5 – Implication for Future Research
1. As a future prospect, one can program and add more and more games to the Gaming Console.
2. The same code can also be made available online using HTML and PHP, for users to play it online.
3. The same program could also be coded in a s lightly different manner to be able to run on Smart Phones as an Application.
23 Anant Agarwal
A2305211310
Gaming Console 10.01
Chapter 6 – Bibliography and References
1. www.wikipedia.com 2. www.cpluscplus.com 3. www.programmingsimplified.com 4. www.stackoverflow.com 5. www.codeproject.com 6. Computer Graphics – Hearn & Baker 7. Computer Science – Sumita Arora
24 Anant Agarwal
A2305211310
Gaming Console 10.01
Chapter 7 - Appendix
7.1 Source Code
#include
#include #include #include #include #include #include #include #include
#define RTA 0x4D #define LTA 0x4B #define UPA 0x48 #define DWA 0x50
void maze_0() { outtextxy(250,50,"LEVEL 1"); outtextxy(113,113,"S"); outtextxy(233,203,"E"); rectangle(100,100,250,220); line(130,100,130,190);
25 Anant Agarwal
A2305211310
Gaming Console 10.01 line(160,130,160,220); line(190,100,190,190); line(220,130,220,220); }
void maze_1() { outtextxy(113,113,"S"); outtextxy(250,50,"LEVEL 2"); outtextxy(323,263,"E"); rectangle(100,100,340,280); line(130,100,130,160); line(220,100,220,250); line(160,130,160,190); line(250,130,250,190); line(280,190,280,250); line(130,220,130,250); line(160,220,160,250); line(250,220,250,280); line(190,250,190,280); line(310,250,310,280); line(160,130,190,130); line(250,130,310,130); line(190,160,220,160); line(100,190,190,190); line(250,190,310,190); line(100,220,130,220); 26 Anant Agarwal
A2305211310
Gaming Console 10.01 line(160,220,220,220); line(310,220,340,220); line(280,250,310,250); line(280,160,340,160); }
void maze_2() { outtextxy(113,113,"S"); outtextxy(250,50,"LEVEL 3"); outtextxy(413,323,"E"); rectangle(100,100,430,340); line(100,310,130,310); line(130,100,130,160); line(130,190,130,250); line(130,160,160,160); line(130,190,160,190); line(130,250,160,250); line(130,280,160,280); line(160,160,160,190); line(160,250,160,310); line(160,130,250,130); line(160,220,220,220); line(160,310,250,310); line(190,130,190,160); line(190,220,190,280); line(190,160,280,160); 27 Anant Agarwal
A2305211310
Gaming Console 10.01 line(220,190,220,220); line(220,250,220,280); line(220,190,250,190); line(220,250,280,250); line(220,280,370,280); line(250,130,250,160); line(250,190,250,220); line(250,250,280,250); line(280,100,280,130); line(280,160,280,220); line(280,280,280,340); line(280,190,310,190); line(310,100,310,160); line(310,190,310,250); line(310,310,310,340); line(310,160,340,160); line(310,250,400,250); line(310,310,340,310); line(340,190,340,250); line(340,310,340,340); line(340,130,400,130); line(340,190,400,190); line(370,130,370,190); line(370,220,370,250); line(370,280,370,310); line(400,250,400,340); line(400,160,430,160); 28 Anant Agarwal
A2305211310
Gaming Console 10.01 line(400,220,430,220); }
void maze_3() { rectangle(100,100,520,400); outtextxy(113,113,"S"); outtextxy(250,50,"LEVEL 4"); outtextxy(503,383,"E"); line(100,280,130,280); line(100,310,130,310); line(130,130,130,220); line(130,250,130,280); line(130,340,130,370); line(130,130,190,130); line(130,250,160,250); line(130,370,220,370); line(160,160,160,190); line(160,220,160,250); line(160,280,160,310); line(160,160,310,160); line(160,190,190,190); line(160,280,190,280); line(160,340,220,340); line(190,130,190,190); line(190,220,190,280); line(190,310,190,340); 29 Anant Agarwal
A2305211310
Gaming Console 10.01 line(190,220,280,220); line(190,310,280,310); line(220,100,220,130); line(220,190,220,310); line(220,340,220,370); line(220,280,310,280); line(250,100,250,160); line(250,250,250,280); line(250,340,250,400); line(250,190,340,190); line(280,130,280,160); line(280,220,280,250); line(280,310,280,340); line(280,130,310,130); line(280,340,310,340); line(280,370,340,370); line(280,250,370,250); line(310,160,310,190); line(310,220,310,250); line(310,280,310,340); line(340,130,340,220); line(340,280,340,370); line(340,130,430,130); line(370,160,370,370); line(370,160,400,160); line(370,280,490,280); line(370,370,400,370); 30 Anant Agarwal
A2305211310
Gaming Console 10.01 line(400,220,400,280); line(400,190,430,190); line(400,310,490,310); line(400,340,460,340); line(430,130,430,250); line(430,310,430,400); line(430,160,460,160); line(460,130,460,160); line(460,190,460,250); line(460,340,460,400); line(460,190,520,190); line(490,100,490,160); line(490,220,490,280); line(490,340,490,370); line(490,220,520,220); line(490,370,520,370); }
void text() { rectangle(70,70,630,430); rectangle(525,75,625,215); outtextxy(530,100,"Instuctions"); outtextxy(530,130,"Use arrow"); outtextxy(530,150,"keys to move"); outtextxy(530,170,"the box from"); outtextxy(530,190,"S to E"); 31 Anant Agarwal
A2305211310
Gaming Console 10.01 rectangle(525,230,625,425); outtextxy(530,300,"MOVES:"); }
void start() { outtextxy(200,150,"***** MAZE Ver 2.10 *****"); outtextxy(250,170," OBJECTIVE "); outtextxy(100,190,"Use arrow keys to get from Start to End position"); outtextxy(215,250,"Press ENTER to start!"); getch(); }
void maze() { clrscr(); int gd=DETECT,gm,x,y,x1,y1; initgraph(&gd,&gm,"C:\\turboc3\\bgi"); int j, flag=0, count=0; start(); for(j=0;j<4;j++) { flag=0; count=0; clrscr(); text(); if(j==0) 32 Anant Agarwal
A2305211310
Gaming Console 10.01 maze_0(); else if(j==1) maze_1(); else if(j==2) maze_2(); else if(j==3) maze_3(); rectangle(105,105,125,125); int key; x=105; y=105; x1=125; y1=125; for(;flag==0;) { key=bioskey(0); if((key & 0x00FF)>0) key=key & 0x00FF; else key= (key & 0xFF00)>>8; switch(key) { case LTA: if(getpixel((x-5),y)!=15) { count++; x=x-30; x1=x1-30; } break; 33 Anant Agarwal
A2305211310
Gaming Console 10.01 case RTA: if(getpixel((x1+5),y)!=15) { count++; x=x+30; x1=x1+30; } break; case UPA: if(getpixel(x,(y-5))!=15) { count++; y=y-30; y1=y1-30; } break; case DWA: if(getpixel(x1,(y1+5))!=15) { count++; y=y+30; y1=y1+30; } break; } clrscr(); rectangle(x,y,x1,y1); 34 Anant Agarwal
A2305211310
Gaming Console 10.01 gotoxy(70,22); cout<
A2305211310
Gaming Console 10.01 else if(j==2) maze_2(); else if(j==3) maze_3(); } clrscr(); outtextxy(200,200,"You completed Level in "); gotoxy(35,16); cout<
char square[10] = {'o','1','2','3','4','5','6','7','8','9'}; 36 Anant Agarwal
A2305211310
Gaming Console 10.01
int checkwin() { if (square[1] == square[2] && square[2] == square[3]) return 1; else if (square[4] == square[5] && square[5] == square[6]) return 1; else if (square[7] == square[8] && square[8] == square[9]) return 1; else if (square[1] == square[4] && square[4] == square[7]) return 1; else if (square[2] == square[5] && square[5] == square[8]) return 1; else if (square[3] == square[6] && square[6] == square[9]) return 1; else if (square[1] == square[5] && square[5] == square[9]) return 1; else if (square[3] == square[5] && square[5] == square[7]) return 1; else if (square[1] != '1' && square[2] != '2' && square[3] != '3' && square[4] != '4' && square[5] != '5' && square[6] != '6' && square[7] != '7' && square[8] != '8' && square[9] != '9') return 0; else return -1; } void board() { 37 Anant Agarwal
A2305211310
Gaming Console 10.01 clrscr(); cout << "\n\n\tTic Tac Toe\n\n"; cout << "Player 1 (X) - Player 2 (O)" << endl << endl; cout << endl; cout << "\t\t
|
|
" << endl;
cout << "\t\t " << square[1] << " | " << square[2] << " | " << square[3] << endl; cout << "\t\t_____|_____|_____" << endl; cout << "\t\t
|
|
" << endl;
cout << "\t\t " << square[4] << " | " << square[5] << " | " << square[6] << endl; cout << "\t\t_____|_____|_____" << endl; cout << "\t\t
|
|
" << endl;
cout << "\t\t " << square[7] << " | " << square[8] << " | " << square[9] << endl; cout << "\t\t
|
|
" << endl << endl;
}
void tictactoe() { int player = 1,i,choice,option; char mark,choice1; clrscr(); outtextxy(200,180,"***Tic Tac Toe 5.1***"); outtextxy(205,210,"Press Enter to Start"); getch(); clrscr(); do { board(); 38 Anant Agarwal
A2305211310
Gaming Console 10.01 player=(player%2)?1:2; cout << "Player " << player << ", enter a number: "; cin >> choice; mark=(player == 1) ? 'X' : 'O'; if (choice == 1 && square[1] == '1') square[1] = mark; else if (choice == 2 && square[2] == '2') square[2] = mark; else if (choice == 3 && square[3] == '3') square[3] = mark; else if (choice == 4 && square[4] == '4') square[4] = mark; else if (choice == 5 && square[5] == '5') square[5] = mark; else if (choice == 6 && square[6] == '6') square[6] = mark; else if (choice == 7 && square[7] == '7') square[7] = mark; else if (choice == 8 && square[8] == '8') square[8] = mark; else if (choice == 9 && square[9] == '9') square[9] = mark; else { cout<<"Invalid move "; player--; getch(); 39 Anant Agarwal
A2305211310
Gaming Console 10.01 } i=checkwin(); player++; }while(i==-1); board(); if(i==1) cout<<"\aPlayer "<<--player<<" win "; else cout<<"\aGame draw"; getch(); }
void bounce() { int d=DETECT,m; initgraph(&d,&m,"c:\\turboc3\\bgi"); float x=15,y=0.00000,j=.5,count=.1; float r=15; setcolor(14); line(0,215,650,215); sleep(1); circle(20, 115, 15); line(20, 130, 20, 175); line(20, 175,5 , 200); line(20, 175, 35, 200); line(20, 140, 40 , 150); line(20, 140, 35, 160); 40 Anant Agarwal
A2305211310
Gaming Console 10.01 for(int k=0;k<=7;k++) { for(float i=90;i<270;i+=10) { circle(20, 115, 15); line(20, 130, 20, 175); line(20, 175,5 , 200); line(20, 175, 35, 200); line(20, 140, 40 , 150); line(20, 140, 35, 160); y=cos(((i*22/7)/180))/j; if(y>0) y=-y; x+=5; setcolor(14); setfillstyle(1,14); circle(x,y*100+200,r); floodfill(x,y*100+200,14); circle(20, 115, 15); line(20, 130, 20, 175); line(20, 175,5 , 200); line(20, 175, 35, 200); line(20, 140, 40 , 150); line(20, 140, 35, 160); delay(100); setcolor(0); setfillstyle(1,0); 41 Anant Agarwal
A2305211310
Gaming Console 10.01 circle(x,y*100+200,r); floodfill(x,y*100+200,0); circle(20, 115, 15); line(20, 130, 20, 175); line(20, 175,5 , 200); line(20, 175, 35, 200); line(20, 140, 40 , 150); line(20, 140, 35, 160); } circle(20, 115, 15); line(20, 130, 20, 175); line(20, 175,5 , 200); line(20, 175, 35, 200); line(20, 140, 40 , 150); line(20, 140, 35, 160); j+=count; count+=.1; } getch(); }
void compcric() { clrscr(); int a=0, score1=0, score2=0, b=0; int gd=DETECT,gm; char name[10]; 42 Anant Agarwal
A2305211310
Gaming Console 10.01 initgraph(&gd,&gm,"C:\\turboc3\\bgi"); outtextxy(200,200,"Welcome to CompCricket 3.10"); outtextxy(220,250,"Press Enter to begin"); getch(); clrscr(); cout<<"Enter your name: "; gets(name); cout<>a; b=rand()%6+1; cout<<"\nComputer chose: "<
A2305211310
Gaming Console 10.01 cout<<"\n"<>a; b=rand()%6+1; cout<<"\nComputer chose: "<score2) { cout<<"\n"<
A2305211310
Gaming Console 10.01 else if(score1==score2) { cout<<"\nMatch is TIED!!!"; } getch(); }
void main() { clrscr(); int gd=DETECT,gm,x,y,x1,y1; int flag=0; initgraph(&gd,&gm,"C:\\turboc3\\bgi"); outtextxy(200,150,"Welcome To Gaming Console 10.01!!"); outtextxy(240,200,"Press Enter to Start"); getch(); do { clrscr(); outtextxy(200,120,"1. Maze Game"); outtextxy(200,150,"2. Tic Tac Toe"); outtextxy(200,180,"3. CompCricket"); outtextxy(200,210,"4. Bounce"); outtextxy(200,240,"5. Exit"); outtextxy(200,270,"Enter your choice: "); cin>>flag; if(flag==1) 45 Anant Agarwal
A2305211310