Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
2 changed files
with
112 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include "player.h" | ||
|
||
|
||
int main() { | ||
|
||
int choice; | ||
|
||
//While loop to chose your player class | ||
while (!std::cin >> choice || choice > 3 || choice < 1) { | ||
std::cout << "Choose your character class. \n[1] Superman [2] Spider-Man [3] Batman; " << std::endl; | ||
std::cin >> choice; | ||
} | ||
//Initalise instance "character" of player Class | ||
player character(choice); | ||
|
||
std::cout << "\nWelcome " << character.printClass() << ". Let's begin your adventure. " << std::endl; | ||
|
||
//Print out player stats BS | ||
std::cout << "Your starting stats:" << std::endl; | ||
character.printStats();//END BS | ||
|
||
while() | ||
|
||
|
||
std::cin.ignore(); | ||
std::cin.get(); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
#include <iostream> | ||
#include <string> | ||
|
||
|
||
class player | ||
{ | ||
std::string playerClass; | ||
int level, attack, location; | ||
|
||
public: | ||
int hp, experience; | ||
|
||
player(int choice) | ||
{ | ||
location = ""; | ||
if (choice ==1) | ||
{ | ||
playerClass = "Superman"; | ||
level = 1; | ||
attack = 60; | ||
hp = 100; | ||
experience = 0; | ||
} | ||
if (choice == 2) | ||
{ | ||
playerClass = "Spider-Man"; | ||
level = 1; | ||
attack = 20; | ||
hp = 100; | ||
experience = 0; | ||
} | ||
if (choice == 3) | ||
{ | ||
playerClass = "BatMan"; | ||
level = 1; | ||
attack = 40; | ||
hp = 100; | ||
experience = 0; | ||
} | ||
|
||
} | ||
|
||
std::string printClass() | ||
{ | ||
return playerClass; | ||
} | ||
|
||
/*BS*/ | ||
//Method to output the player stats to the console | ||
void printStats() | ||
{ | ||
std::cout << "Player Class: " << playerClass << std::endl; | ||
std::cout << "Player Level: " << level << std::endl; | ||
std::cout << "Player Attack/Strength Level: " << attack << std::endl; | ||
std::cout << "Player HP: " << hp << std::endl; | ||
std::cout << "Player Exp: " << experience << std::endl; | ||
} | ||
//Method to return the player level | ||
int playerLevel() | ||
{ | ||
return level; | ||
} | ||
//Method to return the player attack/strength level | ||
int playerAttack() | ||
{ | ||
return attack; | ||
} | ||
//Method to return the players hp | ||
int playerHp() | ||
{ | ||
return hp; | ||
} | ||
//Method to return the players experience | ||
int playerExp() | ||
{ | ||
return experience; | ||
} | ||
//Method to return player location | ||
std::string playerLocation() | ||
{ | ||
return location; | ||
} | ||
/*END BS*/ | ||
}; |