game
game
ON
SHOOTING GAME
Submitted to
DEPARTMENT OF COMPUTER SCIENCE
SESSION : 2022-2023
Submitted BY :
ARTI KUMARI
COURSE NAME : BCA 2ND YEAR (4th Sem)
ROLL NO : 1211803011004
UNDER THE SUPERVISION OF : MRS. PREETI SHARMA
AGGARWAL COLLEGE BALLABGARH
(AFFILIATED TO MDU UNIVERSITY, ROHTAK)
DECLARATION
The project entitled " SHOOTING GAME ” is an authentic work done by me under
the supervision of Mrs. PREETI SHARMA, Assistant Professor, Department of
Computer Science, Aggarwal College Ballabgarh. This project work has not been
presented in any university or college for the partial fulfillment of the award of any
degree or diploma.
ARTI
KUMARI BCA
IV SEM
CERTIFICATE
I am Aarti, here by declare that the work presented this mini project entitled
EXAMPAEDIA, in partial fulfilment of the requirements of BCA of MDU, is an
authentic record of my own work carried out under the guidance of Mrs. Preeti
sharma, Assistant Professor, Department of Computer Science, Aggarwal
College Ballabgarh (ACB), Faridabad.
The work reported in this mini project has not been submitted by me for award
of any other degree or diploma.
Name of the Student: Arti Kumari
Roll No. : 1211803011004
Signature of the Student :
Place:
Date :
ACKNOWLEDGEMENT
I would also like to thank my family and friends for their constant help, hours
of sitting together and frequent lively discussions, and support throughout the
entire span of my course.
Arti
Roll No : 1211803011004
BCA (2nd YEAR)
INDEX
SR.NO DESCRIPTION
1 CERTIFICATE
2 ACKNOWLEDGEMENT
3 PREFACE
4 INTRODUCTION
5 SOURCE CODE
6 OUTPUT
7 CONCLUSION
8 SYSTEM REQIUREMENT
9 BIBLIOGRAPHY
PREFACE
C++ gives programmers a high level of control over system resources and
memory.
The language was updated 4 major times in 2011, 2014, 2017, and 2020 to
C++11, C++14, C++17, C++20
C++ was made available outside Bell Laboratories in 1985. The first commercial
C++ compiler, Cfront, was released in 1985. It was only a front-end compiler
for C. The American National Standard Institute (ANSI) formed a committee for
(precise description of computer language) C++, in 1989. The first draft
standards were published in 1995.
ADVANTAGES OF C++
1. Portability
C++ offers the feature of portability or platform independence which allows
the user to run the same program on different operating systems or interfaces
at ease.
Suppose you write a program in LINUX OS and for some apparent reason you
switch to Windows OS, you would be able to run the same program in
windows as well without any error. This feature proves to be of great
convenience to the programmer.
2. Object-oriented
One of the biggest advantages of C++ is the feature of object-oriented
programming which includes concepts like classes, inheritance, polymorphism,
data abstraction, and encapsulation that allow code reusability and makes a
program even more reliable.
Not only this, it helps us deal with real-world problems by treating data as an
object. C lacked this feature and hence it was created, proving to be of great
significance.
3. Multi-paradigm
C++ is a multi-paradigm programming language. The term “Paradigm” refers to
the style of programming. It includes logic, structure, and procedure of the
program. Generic, imperative, and object-oriented are three paradigms of C++.
Let us now try to understand what generic programming means. Generic
programming refers to the use of a single idea to serve several
purposes. Imperative programming, on the other hand, refers to the use of
statements that change a program’s state.
4. Low-level Manipulation
Since C++ is closely associated with C, which is a procedural language closely
related to the machine language, C++ allows low-level manipulation of data at
a certain level. Embedded systems and compiler are created with the help of
C++.
5. Memory Management
C++ gives the programmer the provision of total control over memory
management. This can be considered both as an asset and a liability as this
increases the responsibility of the user to manage memory rather than it being
managed by the Garbage collector. This concept is implemented with the help
of DMA (Dynamic memory allocation) using pointers.
7. Compatibility with C
C++ is pretty much compatible with C. Virtually; every error-free C program is a
valid C++ program. Depending on the compiler used, every program of C++ can
run on a file with .cpp extension.
8. Scalability
Scalability refers to the ability of a program to scale. It means that
the ++ program is capable of running on a small scale as well as a large scale of
data. We can also build applications that are resource intensive.
OUTPUT
#include <stdlib.h>
#include <windows.h>
#include <iostream>
using namespace std;
struct GAMEINFO {
COORD PlayerOnePosition;
COORD PlayerTwoPosition;
COORD PlayerOneBullet;
COORD PlayerTwoBullet;
COORD PlayerOneBullet2;
COORD PlayerTwoBullet2;
COORD ZeroZero;
};
int main()
{
GAMEINFO GameInfo;
hInput = GetStdHandle(STD_INPUT_HANDLE);
hOutput = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleMode(hOutput, ENABLE_PROCESSED_INPUT);
GameInfo.PlayerOnePosition.X = 19;
GameInfo.PlayerOnePosition.Y = 12;
GameInfo.PlayerTwoPosition.X = 61;
GameInfo.PlayerTwoPosition.Y = 12;
GameInfo.PlayerOneBullet.X = 0;
GameInfo.PlayerOneBullet.Y = 0;
GameInfo.PlayerTwoBullet.X = 79;
GameInfo.PlayerTwoBullet.Y = 0;
GameInfo.PlayerOneBullet2.X = 1;
GameInfo.PlayerOneBullet2.Y = 0;
GameInfo.PlayerTwoBullet2.X = 78;
GameInfo.PlayerTwoBullet2.Y = 0;
GameInfo.ZeroZero.X = 0;
GameInfo.ZeroZero.Y = 0;
int i;
GameInfo.ZeroZero.Y = 24;
for(i = 0; i < 79; i++){
SetConsoleCursorPosition(hOutput, GameInfo.ZeroZero);
cout << ".";
GameInfo.ZeroZero.X++;
}
Draw(GameInfo);
while(1){
Movement(GameInfo);
}
return 0;
}
void Movement(GAMEINFO &GameInfo)
{
INPUT_RECORD InputRecord;
DWORD Events = 0;
if(InputRecord.EventType == KEY_EVENT){
if(InputRecord.Event.KeyEvent.wVirtualKeyCode == VK_ESCAPE)
exit(0);
}
FlushConsoleInputBuffer(hInput);
}
SetConsoleCursorPosition(hOutput, GameInfo.PlayerTwoPosition);
cout << "|";
SetConsoleCursorPosition(hOutput, GameInfo.PlayerOneBullet);
cout << ".";
SetConsoleCursorPosition(hOutput, GameInfo.PlayerTwoBullet);
cout << ".";
SetConsoleCursorPosition(hOutput, GameInfo.PlayerOneBullet2);
cout << ".";
SetConsoleCursorPosition(hOutput, GameInfo.PlayerTwoBullet2);
cout << ".";
GameInfo.ZeroZero.X = 0;
GameInfo.ZeroZero.Y = 0;
int i;
for(i = 0; i < 79; i++){
SetConsoleCursorPosition(hOutput, GameInfo.ZeroZero);
cout << ".";
GameInfo.ZeroZero.X++;
}
SetConsoleCursorPosition(hOutput, GameInfo.PlayerTwoPosition);
cout << " ";
SetConsoleCursorPosition(hOutput, GameInfo.PlayerOneBullet);
cout << " ";
SetConsoleCursorPosition(hOutput, GameInfo.PlayerTwoBullet);
cout << " ";
SetConsoleCursorPosition(hOutput, GameInfo.PlayerOneBullet2);
cout << " ";
SetConsoleCursorPosition(hOutput, GameInfo.PlayerTwoBullet2);
cout << " ";
}
int move;
move = Wait();
switch(move){
case 1:
Erase(GameInfo);
GameInfo.PlayerOnePosition.Y--;
if(GameInfo.PlayerOnePosition.Y <
0)
GameInfo.PlayerOnePosition.Y++;
break;
case 2:
Erase(GameInfo);
GameInfo.PlayerOnePosition.Y++;
if(GameInfo.PlayerOnePosition.Y > 24)
GameInfo.PlayerOnePosition.Y--;
break;
case 3:
Erase(GameInfo);
GameInfo.PlayerTwoPosition.Y--;
if(GameInfo.PlayerTwoPosition.Y <
0)
GameInfo.PlayerTwoPosition.Y++;
break;
case 4:
Erase(GameInfo);
GameInfo.PlayerTwoPosition.Y++;
if(GameInfo.PlayerTwoPosition.Y > 24)
GameInfo.PlayerTwoPosition.Y--;
break;
case 5:
LaunchBullet2(GameInfo, 1);
return 0;
break;
case 6:
LaunchBullet2(GameInfo, 2);
return 0;
break;
}
Draw(GameInfo);
Erase(GameInfo);
if(GameInfo.PlayerOneBullet.X == GameInfo.PlayerTwoPosition.X)
if(GameInfo.PlayerOneBullet.Y == GameInfo.PlayerTwoPosition.Y){
system("cls");
cout << "\aPlayer 1 Wins" << endl;
system("pause");
exit(0);
}
}
GameInfo.PlayerOneBullet.Y = 0;
GameInfo.PlayerOneBullet.X = 0;
Draw(GameInfo);
}
if(PlayerNumber == 2){
GameInfo.PlayerTwoBullet.Y = GameInfo.PlayerTwoPosition.Y;
GameInfo.PlayerTwoBullet.X = GameInfo.PlayerTwoPosition.X - 1;
Draw(GameInfo);
Erase(GameInfo);
for(i = 0; i < 77; i++){
GameInfo.PlayerTwoBullet.X -= 1;
Draw(GameInfo);
int move;
move = Wait();
switch(move){
case 1:
Erase(GameInfo);
GameInfo.PlayerOnePosition.Y--;
if(GameInfo.PlayerOnePosition.Y <
0)
GameInfo.PlayerOnePosition.Y++;
break;
case 2:
Erase(GameInfo);
GameInfo.PlayerOnePosition.Y++;
if(GameInfo.PlayerOnePosition.Y > 24)
GameInfo.PlayerOnePosition.Y--;
break;
case 3:
Erase(GameInfo);
GameInfo.PlayerTwoPosition.Y--;
if(GameInfo.PlayerTwoPosition.Y <
0)
GameInfo.PlayerTwoPosition.Y++;
break;
case 4:
Erase(GameInfo);
GameInfo.PlayerTwoPosition.Y++;
if(GameInfo.PlayerTwoPosition.Y > 24)
GameInfo.PlayerTwoPosition.Y--;
break;
case 5:
LaunchBullet2(GameInfo, 1);
return 0;
break;
case 6:
LaunchBullet2(GameInfo, 2);
return 0;
break;
}
Draw(GameInfo);
Erase(GameInfo);
if(GameInfo.PlayerTwoBullet.X == GameInfo.PlayerOnePosition.X)
if(GameInfo.PlayerTwoBullet.Y == GameInfo.PlayerOnePosition.Y){
system("cls");
cout << "\aPlayer 2 Wins" << endl;
system("pause");
exit(0);
}
}
GameInfo.PlayerTwoBullet.Y = 0;
GameInfo.PlayerTwoBullet.X = 79;
Draw(GameInfo);
}
return 0;
}
int Wait()
{
INPUT_RECORD InputRecord;
DWORD Events = 0;
if(WAIT_TIMEOUT == WaitForSingleObject(hInput,1))
return 0;
ReadConsoleInput(hInput, &InputRecord, 1, &Events);
if(InputRecord.EventType == KEY_EVENT)
{ if(InputRecord.Event.KeyEvent.wVirtualKeyCode == VK_Q &&
InputRecord.Event.KeyEvent.bKeyDown == 1)
return 1;
if(InputRecord.Event.KeyEvent.wVirtualKeyCode == VK_A &&
InputRecord.Event.KeyEvent.bKeyDown == 1)
return 2;
Draw(GameInfo);
Erase(GameInfo);
int i;
for(i = 0; i < 77; i++)
{ GameInfo.PlayerOneBullet.X +=
1;
GameInfo.PlayerOneBullet2.X += 1;
GameInfo.PlayerTwoBullet.X -= 1;
GameInfo.PlayerTwoBullet2.X -= 1;
Draw(GameInfo);
int move;
move = Wait();
switch(move){
case 1:
Erase(GameInfo);
GameInfo.PlayerOnePosition.Y--;
if(GameInfo.PlayerOnePosition.Y <
0)
GameInfo.PlayerOnePosition.Y++;
break;
case 2:
Erase(GameInfo);
GameInfo.PlayerOnePosition.Y++;
if(GameInfo.PlayerOnePosition.Y > 24)
GameInfo.PlayerOnePosition.Y--;
break;
case 3:
Erase(GameInfo);
GameInfo.PlayerTwoPosition.Y--;
if(GameInfo.PlayerTwoPosition.Y <
0)
GameInfo.PlayerTwoPosition.Y++;
break;
case 4:
Erase(GameInfo);
GameInfo.PlayerTwoPosition.Y++;
if(GameInfo.PlayerTwoPosition.Y > 24)
GameInfo.PlayerTwoPosition.Y--;
break;
}
Draw(GameInfo);
Erase(GameInfo);
if(GameInfo.PlayerOneBullet.X == GameInfo.PlayerTwoPosition.X)
if(GameInfo.PlayerOneBullet.Y == GameInfo.PlayerTwoPosition.Y){
system("cls");
cout << "\aPlayer 1 Wins" << endl;
system("pause");
exit(0);
}
if(GameInfo.PlayerOneBullet2.X == GameInfo.PlayerTwoPosition.X)
if(GameInfo.PlayerOneBullet2.Y == GameInfo.PlayerTwoPosition.Y){
system("cls");
cout << "\aPlayer 1 Wins" << endl;
system("pause");
exit(0);
}
}
GameInfo.PlayerOneBullet.Y = 0;
GameInfo.PlayerOneBullet.X = 0;
GameInfo.PlayerOneBullet2.Y = 0;
GameInfo.PlayerOneBullet2.X = 1;
Draw(GameInfo);
}
if(PlayerNumber == 2){
GameInfo.PlayerTwoBullet2.Y = GameInfo.PlayerTwoPosition.Y;
GameInfo.PlayerTwoBullet2.X = GameInfo.PlayerTwoPosition.X - 1;
Draw(GameInfo);
Erase(GameInfo);
int i;
for(i = 0; i < 77; i++)
{ GameInfo.PlayerTwoBullet.X -= 1;
GameInfo.PlayerTwoBullet2.X -= 1;
GameInfo.PlayerOneBullet.X += 1;
GameInfo.PlayerOneBullet2.X += 1;
Draw(GameInfo);
int move;
move = Wait();
switch(move){
case 1:
Erase(GameInfo);
GameInfo.PlayerOnePosition.Y--;
if(GameInfo.PlayerOnePosition.Y <
0)
GameInfo.PlayerOnePosition.Y++;
break;
case 2:
Erase(GameInfo);
GameInfo.PlayerOnePosition.Y++;
if(GameInfo.PlayerOnePosition.Y > 24)
GameInfo.PlayerOnePosition.Y--;
break;
case 3:
Erase(GameInfo);
GameInfo.PlayerTwoPosition.Y--;
if(GameInfo.PlayerTwoPosition.Y <
0)
GameInfo.PlayerTwoPosition.Y++;
break;
case 4:
Erase(GameInfo);
GameInfo.PlayerTwoPosition.Y++;
if(GameInfo.PlayerTwoPosition.Y > 24)
GameInfo.PlayerTwoPosition.Y--;
break;
}
Draw(GameInfo);
Erase(GameInfo);
if(GameInfo.PlayerTwoBullet.X == GameInfo.PlayerOnePosition.X)
if(GameInfo.PlayerTwoBullet.Y == GameInfo.PlayerOnePosition.Y){
system("cls");
cout << "\aPlayer 2 Wins" << endl;
system("pause");
exit(0);
}
if(GameInfo.PlayerTwoBullet2.X == GameInfo.PlayerOnePosition.X)
if(GameInfo.PlayerTwoBullet2.Y == GameInfo.PlayerOnePosition.Y){
system("cls");
cout << "\aPlayer 2 Wins" << endl;
system("pause");
exit(0);
}
}
GameInfo.PlayerOneBullet.Y = 0;
GameInfo.PlayerOneBullet.X = 0;
GameInfo.PlayerOneBullet2.Y = 0;
GameInfo.PlayerOneBullet2.X = 1;
Draw(GameInfo);
}
}
OUTPUT
CONCLUSION
We originally set out to explore the strengths and weaknesses of five of the
most commonly used programming languages. This exploration was guided
by the aim to be able to make more informed decisions of which
programming language might be best suited for a particular situation. We
have looked at C, Java, JavaScript, Python, and C++ over the course of the
past few weeks, and today we will recap what has been learned about what
types of application are suited for each language. C was the first
programming language we looked at.
WWW.GOOGLE.COM
WWW.QUORO.COM