0% found this document useful (0 votes)
6 views20 pages

Maharashtra State Board of Technical Education

The document is a micro-project report on a C++ program simulating a turn-based battle between two game characters, created by students at Ashokrao Mane Polytechnic. It includes details on the game's structure, character attributes, battle mechanics, and future enhancements. The project emphasizes fundamental programming concepts such as classes, user input, and game logic, and is guided by Dr. S.A. Lakade.

Uploaded by

patilharshada974
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views20 pages

Maharashtra State Board of Technical Education

The document is a micro-project report on a C++ program simulating a turn-based battle between two game characters, created by students at Ashokrao Mane Polytechnic. It includes details on the game's structure, character attributes, battle mechanics, and future enhancements. The project emphasizes fundamental programming concepts such as classes, user input, and game logic, and is guided by Dr. S.A. Lakade.

Uploaded by

patilharshada974
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 20

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION

MICRO-PROJECT REPORT ON
“ Game Character ”
Diploma in Computer
Engineering
Submitted By

Subject: Sr.No Name Roll No


Object
Oriente
1 Aditi Sandip Patil 2013
d
Progra
2 Atharv Krushnat Mulik 2014
mming
Using 3 Pratik Babaso kamble 2015
C++
(313304
).
Guide: Dr. S. A. Lakade.

ASHOKRAO MANE POLYTECHNIC, VATHAR


Department of Computer
Engineering A.Y. 2024-25
DECLARATION

I hereby declare that the Micro-Project Report entitled “Object Oriented Programming Using C++ ”
with Module “Game Character.” is an authentic record of my own work as requirements of Micro Project
during the period from / / 2024 to / / 2024 in partial fulfillment of Second Year in Computer
Engineering,
at Ashokrao Mane Polytechnic, Vathar under the guidance of Dr. S.A. Lakade.

Sr.No Name Signature

1 Aditi Sandip Patil

2 Atharv Krushnat Mulik

3 Pratik Babaso kamble

Date: / / 2024

Place: Vathar, Kolhapur.


ACKNOWLEDGMENT

The successful presentation of the “Game Character ” would be incomplete without the mention of the
people who made it possible and whose constant guidance crowned my effort with success.

I would like to extend my gratitude to HOD of Computer Department D r . S.A. Lakade, for providing all
the facilities to present this Micro-Project.

I would like to thank our Project Guide, D r .S .A . Lakade Department of Computer


Engineering, Ashokrao Mane Polytechnic, Vathar, for their constant guidance and inputs.

Sincerely,

Sr.No Name Roll No

1 Aditi Sandip Patil 2013


2 Atharv Krushnat Mulik 2014
3 Pratik Babaso kamble 2015

Place: Vathar , Kolhapur.

Date: / / 2024
Abstract

This C++ code simulates a simple turn-based battle between two game characters, utilizing Turbo C++
specific libraries like conio.h for screen clearing and getch() for waiting for user input. It defines a
GameCharacter class with attributes for the character's name, health, and attack power, along with methods
to perform actions such as attacking another character, taking damage, and checking if the character is
alive. The main() function facilitates character creation by accepting user input for the name, health, and
attack power of two characters. A battle loop runs, where each character alternately attacks the other until
one character's health reaches zero, and the winner is announced. Decorative borders and titles are printed
throughout to enhance the visual appeal.After the battle a message is displayed, indicating that the code has
executed successfully. The game is simple and focuses on simulating basic combat mechanics between two
characters. It also ensures that health cannot drop below zero and provides a clear win condition. This
structure could be expanded with more features like special abilities, healing, or multiple rounds for a more
complex battle system.
4o mini
INDEX

Sr.No Content

1 Abstract

2 Title

3 Introduction

4 Proposed System

5 Requirement

6 Source Code Of Project

7 Output of Project

8 Future Scope

9 Conclusion

10 References
Title

Game Character
Game Character Ashokrao Mane Polytechnic

1. Introduction

This C++ program is a basic text-based game where two characters battle each other. Each character has a
name, health, and attack power, which are set by the user at the beginning of the game. During the battle,
the two characters take turns attacking each other, reducing their health based on the damage they deal. The
program checks after each attack if either character's health has dropped to zero, and if so, the game ends.
The game continues until one character’s health drops to zero, and the other character is declared the
winner. The program prints out updates after each attack, showing how much damage was taken and how
much health is left. This allows the user to follow the battle step by step. At the end of the game, the
character with remaining health is declared the winner. The program also makes use of visual elements like
borders and formatted titles to organize the output, making it more appealing and easier to follow. It
provides a simple yet effective introduction to programming concepts such as classes, loops, conditionals,
and user input. By understanding how this basic game works, beginners can learn how to apply these
programming fundamentals and expand the game by adding additional features such as special moves,
multiple levels, or character upgrades.
4o mini
Game Character Ashokrao Mane Polytechnic

2. Proposed System

1. GameCharacter Class:

This class represents a game character with the following attributes:

o name (a fixed-size character array for the name of the character),


o health (an integer representing the character’s health points),
o attackPower (an integer representing the character’s attack strength).
 The class has several methods:

o GameCharacter() constructor: Initializes the character’s name, health, and attack power.
o getName(): Returns the character’s name.
o getHealth(): Returns the current health of the character.
o getAttackPower(): Returns the character’s attack power.
o attack(): Allows a character to attack another character. This method decreases the target
character's health.
o takeDamage(): Reduces the health of the character when damage is taken. It ensures that health
doesn't drop below 0.
o isAlive(): Returns whether the character is still alive (health > 0).

2. Input and Character Creation:

 The user is prompted to input the name, health, and attack power for two game characters.
 The cin object is used to read input from the user for each attribute.

3. Battle Simulation:

 The battle is performed in rounds using a while loop. Each round consists of:
o Character 1 attacks character 2.
o If character 2 is still alive, they retaliate and attack character 1.
o The health of both characters is updated after each attack.
o The loop continues until one character’s health drops to 0 or below.
Game Character Ashokrao Mane Polytechnic

4. Winner Determination:

 After the battle concludes, the program checks which character is still alive and announces the winner.

5. Decorative Elements:

 The printBorder() and printTitle() functions are used to format the output with borders and titles, making
the program more visually engaging.
 The clrscr() function clears the screen before starting, which is typical in Turbo C++ environments.
 The getch() function pauses the program at the end, waiting for the user to press a key before closing the
program.
Game Character Ashokrao Mane Polytechnic

Workflow:-

1. Start Program:

The screen is cleared, and the title "Character Creation" is printed.

2. Character Creation:

 User enters the name, health, and attack power for Character 1.
 A GameCharacter object for Character 1 is created.
 User enters the same information for Character 2.
 A GameCharacter object for Character 2 is created.

3. Battle Begins:

 A battle loop starts where each character takes turns attacking each other until one’s health reaches 0.
 Each round:

o Character 1 attacks Character 2, reducing its health.


o If Character 2 is alive, it retaliates by attacking Character 1.

4. Battle End:

 The loop stops when one character's health reaches 0.


 The winner is declared based on who is still alive.

5. Program End:

 The program displays "The Code is successfully Executed" and waits for user input before closing.
Game Character Ashokrao Mane Polytechnic

3. Requirements

Software Requirement:-

1. Turbo C++ Compiler and IDE

DOSBox (for running Turbo C++ on modern systems).

2. Visual Studio Code (Cross-platform, with C++ extensions.

Concept of C++ :-

Classes: GameCharacter is the class that represents each character in the game.

Objects: Instances of the GameCharacter class (e.g., character1 and character2) represent individual
characters in the game.

Encapsulation: Character attributes (like health and attack power) are kept private, and access to them is
provided through public methods (e.g., getHealth(), getName()).

Methods: The class defines actions that a character can perform, such as attacking another character
(attack()) and taking damage (takeDamage()).
Game Character Ashokrao Mane Polytechnic

4. Source Code Of Project

#include <iostream.h>

#include <conio.h>

#include <string.h>

class GameCharacter {

private:

char name[50];

int health;

int attackPower;

public:

// Constructor to initialize values

GameCharacter(char* characterName, int hp, int attack) {

strcpy(name, characterName);

health = hp;

attackPower = attack;

char* getName() {

return name;

int getHealth() {

return health;

}
int getAttackPower() {

return attackPower;

}
Game Character Ashokrao Mane Polytechnic

void attack(GameCharacter& target) {

cout << name << " attacks " << target.getName() << " for "
<< attackPower << " damage!" << endl;

target.takeDamage(attackPower);

void takeDamage(int damage) {

health -= damage;

if (health < 0) health = 0;

cout << name << " takes " << damage << " damage and now
has " << health << " health left." << endl;

bool isAlive() {

return health > 0;

};

void printBorder() {

cout << "*******" << endl;

void printTitle(const char* title) {

cout << "\n";

printBorder();

cout << " " << title << " " << endl;

printBorder();

}
Game Character Ashokrao Mane Polytechnic

void main() {

clrscr(); // Clear screen function (specific to Turbo C++)

char name[50]; // Use a character array for name

int health, attackPower;

printTitle("Character Creation");

cout << "\nEnter name for the first character: ";

cin>>name ;

cout << "Enter health for " << name << ": ";

cin >> health;

cout << "Enter attack power for " << name << ": ";

cin >> attackPower;

GameCharacter character1(name, health, attackPower);

printTitle("Character 1 Created");

cout << "\nEnter name for the second character: ";

cin>>name ;

cout << "Enter health for " << name << ": ";

cin >> health;

cout << "Enter attack power for " << name << ": ";

cin >> attackPower;

GameCharacter character2(name, health, attackPower);

printTitle("Character 2 Created");

printTitle("--- Battle Begins ---");

while (character1.isAlive() && character2.isAlive()) {

cout << "\n** Round Start **\n";

character1.attack(character2);
Game Character Ashokrao Mane Polytechnic

if (character2.isAlive()) {

character2.attack(character1);

cout << "* Round End *\n\n";

}
printTitle("--- Winner ---");

if (character1.isAlive()) {

cout << character1.getName() << " wins!\n";

} else {

cout << character2.getName() << " wins!\n";

if (character1.isAlive()) {

cout << character1.getName() << " wins!\n";

} else {

cout << character2.getName() << " wins!\n";

}
printBorder();

cout << "\n============The Code is successfully


Excuted============";

getch();

}
Game Character Ashokrao Mane Polytechnic

5. Output of Project
Game Character Ashokrao Mane Polytechnic
Game Character Ashokrao Mane Polytechnic

6. Future Scope

1.Character Enhancements: Add attributes like defense, magic, and special abilities. Introduce a leveling
system with experience points, and allow characters to gain new skills or increase stats as they progress.

2.Story & Game Modes: Introduce a story mode, where characters progress through levels or face bosses. Add
game modes like Survival or Tournament to add variety to gameplay.

3.Multiplayer: Implement a two-player mode on the same computer or over a network, allowing players to
battle against each other.

4.AI & Difficulty: Develop AI-controlled opponents with different strategies and implement difficulty levels
for more challenging gameplay.

5.Sound & Music: Add sound effects and background music to make the game more immersive.

6.Save/Load System: Allow players to save and load game progress for longer sessions.
Game Character Ashokrao Mane Polytechnic

7. Conclusion
The code you've provided is a simple text-based battle simulation game written in C++ using Turbo C++
conventions, such as the inclusion of conio.h for screen clearing and user input handling. It defines a
GameCharacter class, which encapsulates the character's name, health, and attack power. The class
includes methods to handle attacking another character, taking damage, and checking if the character is still
alive.The game begins by prompting the user to create two characters by inputting their name, health, and
attack power. Once both characters are created, they engage in a turn-based battle where they take turns
attacking each other until one of them runs out of health. The program checks after each attack if a
character is still alive, and when the battle ends, it announces the winner. The battle continues until one
character’s health reaches zero, and the winner is determined based on which character remains
alive.Overall, this code provides a basic framework for a combat simulation game but can be expanded
with features like multiple characters, special abilities, different game modes, or even an improved user
interface. It demonstrates fundamental object-oriented programming principles such as class design,
constructor usage, and encapsulation in a fun and interactive way.
Game Character Ashokrao Mane Polytechnic

8. References

[1]. C++ Programming Books:


C++ Primer by Stanley B. Lippman, Josée Lajoie, Barbara E. Moo – A comprehensive guide to C++
programming, covering basic to advanced topics including classes, constructors, and object-oriented
programming.
The Complete Reference by Herbert Schildt – A detailed resource for C++ syntax, libraries, and features,
including Turbo C++ specifics.

[2].Code Project: C++ Game Programming Tutorial

[3]. Tutorials Point: C++ Game Development Tutorial

[4]. Udemy Course: C++ Game Development Fundamentals

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy