Post by lemememaster on Oct 20, 2015 17:20:49 GMT
This is just the initial source for now. It's a pretty good skeleton of the game IMO. Nowhere near finished, but I did this in study hall, so it's a start.
#include <iostream>
#include <cmath>
#include <ctime>
#include <cstdlib>
using namespace std;
class Enemy{
public:
int str;
int health;
int def;
Enemy();
Enemy(int lvlmod);
void dispStat();
int doDamage();
void takeDamage(int ow);
bool isAlive();
};
int Enemy::doDamage(){
float dam=0;
float mod=((rand()%100)+50)/100;
dam=str;
dam=dam*mod;
return dam;
}
bool Enemy::isAlive(){
if(health>0){
return 1;
}
else{
return 0;
}
}
void Enemy::takeDamage(int ow){
if(def>ow){
cout<<"Damage dodged!\n";
}
else if(def<ow){
health=health-(ow-def);
cout<<"Enemy Health:"<<health<<endl;
}
}
Enemy::Enemy(){
str=0;
def=0;
health=0;
while((str+def+health)/3<5||(str+def+health)/3>10){
str=rand()%20+1;
def=rand()%20+1;
health=rand()%20+1;
}
}
Enemy::Enemy(int lvlmod){
str=0;
def=0;
health=0;
while((str+def+health)/3<5||(str+def+health)/3>10){
str=rand()%20+1;
def=rand()%20+1;
health=rand()%20+1;
}
str=str+lvlmod;
health=health+lvlmod;
def=def+lvlmod;
}
void Enemy::dispStat(){
cout<<"Def:"<<def<<endl<<"Str:"<<str<<endl<<"Health:"<<health<<endl<<"Average Stat:"<<(def+str+health)/3<<endl<<endl;
}
class Player{
public:
int str;
int health;
int def;
Player();
void dispStat();
int doDamage();
void takeDamage(int ow);
bool isAlive();
};
void Player::dispStat(){
cout<<"Def:"<<def<<endl<<"Str:"<<str<<endl<<"Health:"<<health<<endl<<"Average Stat:"<<(def+str+health)/3<<endl<<endl;
}
int Player::doDamage(){
float dam=0;
float mod=((rand()%100)+50)/100;
dam=str;
dam=dam*mod;
return dam;
}
void Player::takeDamage(int ow){
if(def>ow){
cout<<"Damage dodged!\n";
}
else if(def<ow){
health=health-(ow-def);
cout<<"Player Health:"<<health<<endl;
}
}
bool Player::isAlive(){
if(health>0){
return 1;
}
else{
return 0;
}
}
Player::Player(){
while(str+health+def!=45){
cout<<"you are permited 45 points for Str, Def, and Health.\n\nStr:";
cin>>str;
cout<<endl<<"You have "<<45-str<<" points remaining\nDef:";
cin>>def;
cout<<endl<<"You have "<<45-str-def<<" points remaining\nHealth:";
cin>>health;
cout<<endl;
}
}
int main() {
Enemy Poo[5];
Player me;
for(int i=0;i<5;i++){
Poo[i].dispStat();
}
cout<<"Next Part\n";
for(int i=0;i<5;i++){
while(me.isAlive()&&Poo[i].isAlive()){
cout<<"attack!\nPlayer:";
me.takeDamage(Poo[i].doDamage());
cout<<endl<<"Enemy:";
Poo[i].takeDamage(me.doDamage());
cout<<endl<<endl;
}
}
return 0;
}
e