in house project report_end

Upload: anantagarwal10

Post on 02-Jun-2018

218 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/10/2019 In House Project Report_end

    1/46

    Gaming Console 10.01

    1

    Anant Agarwal A2305211310

    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 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-transferlevel 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.

    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 art, which is more often an expression 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 performan educational, simulational, or psychological role.

  • 8/10/2019 In House Project Report_end

    2/46

    Gaming Console 10.01

    2

    Anant Agarwal A2305211310

    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 the position to play using the Num-Pad of

    your keyboard.

    3. CompCricket: The game is an adapted version of the classic school game Book

    Cricket. It makes use of the random number generator function to play 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 and Methods

  • 8/10/2019 In House Project Report_end

    3/46

    Gaming Console 10.01

    3

    Anant Agarwal A2305211310

    2.1System Requirements

    2.1.1 Hardware Requirements

    1. Processor Pentium 4 or higher

    2. Hard Disk Drive

    3. Graphics Card

    4. RAM

    5. Keyboard

    2.1.2 Software Requirement

    1.

    OS Windows XP or higher2. Graphics compliant C++ Compiler (Turbo C++)

    3. Graphics Library

    4. General Peripheral Drivers

    2.2 Methodology

    1. The programming done for Gaming Console 10.01is entirely based on C++

    2. Graphics programming has been used for the GUI

    3. Keyboard has also been programmed to facilitate movement using arrow keys.

    4. 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 anddeveloped for this project contains four different games which have been

    thoroughly explained below and are as follows:

    1. Maze Game

    2. Tic-Tac-Toe

    3. CompCricket

    4. Bounce

    2.3.2 Maze Game

  • 8/10/2019 In House Project Report_end

    4/46

    Gaming Console 10.01

    4

    Anant Agarwal A2305211310

    The maze game is a classic puzzle game from time immortal. In this particular

    development keyboards arrow keys have been coded andprogrammed 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 marked by an E on the maze.

    4. A counter shows clearly, how many moves, the player takes to solve the 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. Use the Num-Pad from 1-9 to play your move.

    2. Two players required.

    3. Player 1 uses Crosses (X)

    4. Player 2 uses Knots (O)

    5. Whoever gets 3 knots or crosses in a row WINS.

    6. If all places fill out, game is TIED.

    2.3.4 CompCricket

  • 8/10/2019 In House Project Report_end

    5/46

    Gaming Console 10.01

    5

    Anant Agarwal A2305211310

    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. User plays against the computer.

    2. User enters a number from 1-6.

    3. Computer generates a number from 1-6.

    4. If the number matches, the user/computer (whatever the case maybe) is out.

    5. Else the number is added to the users /computers (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 3Results and Discussions

  • 8/10/2019 In House Project Report_end

    6/46

    Gaming Console 10.01

    6

    Anant Agarwal A2305211310

    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 1Welcome Screen

  • 8/10/2019 In House Project Report_end

    7/46

    Gaming Console 10.01

    7

    Anant Agarwal A2305211310

    Fig 2Options Page

    Fig 3Maze Game Page

  • 8/10/2019 In House Project Report_end

    8/46

    Gaming Console 10.01

    8

    Anant Agarwal A2305211310

    Fig 3.1Maze Level 1

    Fig 3.2Maze Loading Page

  • 8/10/2019 In House Project Report_end

    9/46

    Gaming Console 10.01

    9

    Anant Agarwal A2305211310

    Fig 3.3Maze Level 2

    Fig 3.4Maze Level 3

  • 8/10/2019 In House Project Report_end

    10/46

    Gaming Console 10.01

    10

    Anant Agarwal A2305211310

    Fig 3.5Maze Level 4

    Fig 3.6Maze Moves Page

  • 8/10/2019 In House Project Report_end

    11/46

    Gaming Console 10.01

    11

    Anant Agarwal A2305211310

    Fig 3.7Maze Game Over

    Fig 4Tic Tac Toe

  • 8/10/2019 In House Project Report_end

    12/46

    Gaming Console 10.01

    12

    Anant Agarwal A2305211310

    Fig 4.1TicTacToe Board

    Fig 4.2TicTacToe Gameplay

  • 8/10/2019 In House Project Report_end

    13/46

    Gaming Console 10.01

    13

    Anant Agarwal A2305211310

    Fig 4.3TicTacToe Gameplay

    Fig 4.4TicTacToe Win Page

  • 8/10/2019 In House Project Report_end

    14/46

    Gaming Console 10.01

    14

    Anant Agarwal A2305211310

    Fig 5CompCricket Page

    Fig 5.1Name Page

  • 8/10/2019 In House Project Report_end

    15/46

    Gaming Console 10.01

    15

    Anant Agarwal A2305211310

    Fig 5.2CompCricket Gameplay

    Fig 5.3CompCricket Gameplay

  • 8/10/2019 In House Project Report_end

    16/46

    Gaming Console 10.01

    16

    Anant Agarwal A2305211310

    Fig 5.4CompCricket User OUT

    Fig 5.5CompCricket Bowling

  • 8/10/2019 In House Project Report_end

    17/46

    Gaming Console 10.01

    17

    Anant Agarwal A2305211310

    Fig 5.6CompCricket Gameplay

    Fig 5.7CompCricket Winner

  • 8/10/2019 In House Project Report_end

    18/46

    Gaming Console 10.01

    18

    Anant Agarwal A2305211310

    Fig 6.1Bounce 1

    Fig 6.2Bounce 2

  • 8/10/2019 In House Project Report_end

    19/46

    Gaming Console 10.01

    19

    Anant Agarwal A2305211310

    Fig 6.3Bounce 3

    Fig 6.4Bounce 4

  • 8/10/2019 In House Project Report_end

    20/46

    Gaming Console 10.01

    20

    Anant Agarwal A2305211310

    Fig 6.5Bounce 5

    Fig 7Options Page

  • 8/10/2019 In House Project Report_end

    21/46

    Gaming Console 10.01

    21

    Anant Agarwal A2305211310

    Fig 8Exit Page

  • 8/10/2019 In House Project Report_end

    22/46

    Gaming Console 10.01

    22

    Anant Agarwal A2305211310

    Chapter 4Conclusions and Recommendations

    1. The aim of this project was to develop a Gaming Console, in which several differentgames can be programmed and added in a single application.

    2. As ones 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.

  • 8/10/2019 In House Project Report_end

    23/46

    Gaming Console 10.01

    23

    Anant Agarwal A2305211310

    Chapter 5 Implication for Future Research

    1. As a future prospect, one can program and add more and more games to the GamingConsole.

    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 slightly different manner to be able to run on

    Smart Phones as an Application.

  • 8/10/2019 In House Project Report_end

    24/46

    Gaming Console 10.01

    24

    Anant Agarwal A2305211310

    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 GraphicsHearn & Baker

    7.

    Computer ScienceSumita Arora

  • 8/10/2019 In House Project Report_end

    25/46

    Gaming Console 10.01

    25

    Anant Agarwal A2305211310

    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);

  • 8/10/2019 In House Project Report_end

    26/46

    Gaming Console 10.01

    26

    Anant Agarwal A2305211310

    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);

  • 8/10/2019 In House Project Report_end

    27/46

    Gaming Console 10.01

    27

    Anant Agarwal A2305211310

    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);

  • 8/10/2019 In House Project Report_end

    28/46

    Gaming Console 10.01

    28

    Anant Agarwal A2305211310

    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);

  • 8/10/2019 In House Project Report_end

    29/46

    Gaming Console 10.01

    29

    Anant Agarwal A2305211310

    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);

  • 8/10/2019 In House Project Report_end

    30/46

    Gaming Console 10.01

    30

    Anant Agarwal A2305211310

    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);

  • 8/10/2019 In House Project Report_end

    31/46

    Gaming Console 10.01

    31

    Anant Agarwal A2305211310

    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");

  • 8/10/2019 In House Project Report_end

    32/46

    Gaming Console 10.01

    32

    Anant Agarwal A2305211310

    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

  • 8/10/2019 In House Project Report_end

    33/46

    Gaming Console 10.01

    33

    Anant Agarwal A2305211310

    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;

  • 8/10/2019 In House Project Report_end

    34/46

    Gaming Console 10.01

    34

    Anant Agarwal A2305211310

    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);

  • 8/10/2019 In House Project Report_end

    35/46

    Gaming Console 10.01

    35

    Anant Agarwal A2305211310

    gotoxy(70,22);

    cout

  • 8/10/2019 In House Project Report_end

    36/46

    Gaming Console 10.01

    36

    Anant Agarwal A2305211310

    else if(j==2)

    maze_2();

    else if(j==3)

    maze_3();

    }

    clrscr();

    outtextxy(200,200,"You completed Level in ");

    gotoxy(35,16);

    cout

  • 8/10/2019 In House Project Report_end

    37/46

    Gaming Console 10.01

    37

    Anant Agarwal A2305211310

    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()

    {

  • 8/10/2019 In House Project Report_end

    38/46

    Gaming Console 10.01

    38

    Anant Agarwal A2305211310

    clrscr();

    cout

  • 8/10/2019 In House Project Report_end

    39/46

    Gaming Console 10.01

    39

    Anant Agarwal A2305211310

    player=(player%2)?1:2;

    cout

  • 8/10/2019 In House Project Report_end

    40/46

    Gaming Console 10.01

    40

    Anant Agarwal A2305211310

    }

    i=checkwin();

    player++;

    }while(i==-1);

    board();

    if(i==1)

    cout

  • 8/10/2019 In House Project Report_end

    41/46

    Gaming Console 10.01

    41

    Anant Agarwal A2305211310

    for(int k=0;k

  • 8/10/2019 In House Project Report_end

    42/46

    Gaming Console 10.01

    42

    Anant Agarwal A2305211310

    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];

  • 8/10/2019 In House Project Report_end

    43/46

    Gaming Console 10.01

    43

    Anant Agarwal A2305211310

    initgraph(&gd,&gm,"C:\\turboc3\\bgi");

    outtextxy(200,200,"Welcome to CompCricket 3.10");

    outtextxy(220,250,"Press Enter to begin");

    getch();

    clrscr();

    cout

  • 8/10/2019 In House Project Report_end

    44/46

    Gaming Console 10.01

    44

    Anant Agarwal A2305211310

    cout

  • 8/10/2019 In House Project Report_end

    45/46

    Gaming Console 10.01

    45

    Anant Agarwal A2305211310

    else if(score1==score2)

    {

    coutflag;

    if(flag==1)

  • 8/10/2019 In House Project Report_end

    46/46

    Gaming Console 10.01

    maze();

    else if(flag==2)

    tictactoe();

    else if(flag==3)

    compcric();

    else if(flag==4)

    bounce();

    }while(flag!=5);

    clrscr();

    outtextxy(200,180,"Developed By Anant Agarwal");

    outtextxy(200,210,"Enrollment Number: A2305211310");

    outtextxy(200,240,"Department of Computer Science and Engineering");

    outtextxy(200,270,"ASET, AUUP");

    getch();

    }