Ok so I am making this super mega crapy game, far from Gears or halo, but you have to start somewhere. I am trying to get input from the player and then see what key was pushed either x v or s and this will determine the attack type and minus this from the health of the really stupid bot that I made.
I am haveing problems with geting the input from the user and also geting the attack to subtrack from the enemy health points.
I worked with number input like 1 2 and 3 and that worked but did not damage the enemy health at all so there is also something wrong there too.
Thanks for any help
here is the code for one of the best games of E3 this year :)
#include "stdafx.h"
#include <iostream>
#include <string>
#include <windows.h>
usingnamespace System;
usingnamespace std;
//good guy ie player
class Player
{
public:
int hp;
int sp;
int mp;
};
class Bot
{
public:
int hp; //hit points for emeny
int atk; //damage to player health
};
void atkTimer(){
cout << "Player attacked please wait" << endl;
//time guage for attack bar player cannot attck for 5 seconds
Sleep(5000); //this is in milliseconds
}
int main()
{
//attack related items and skills
//attack bar
bool atb = true; //if false then player cannot attack
//amount of damage is abitray
int slash = 10; //players pushs x does 10 in damage
int flameSlash = 20; //player pushs s does 20 in damage
int shiningStrike = 30; //player pushs v does 30 in damage
//skill wheel does x in damage
int powerDive = 15;
int powerCharge = 25;
int wildStrike = 35;
int renegade = 40;
int ShiningStars = 50;
//build player
Player Maverick;
Maverick.hp = 1220;
Maverick.mp = 220;
Maverick.sp = 100;
//build bot
Bot ninja;
ninja.hp = 500;
ninja.atk = 20;
//print off player data
cout << "Maverick" << endl;
cout << "Health " << Maverick.hp <<endl;
cout << "Magic " << Maverick.mp <<endl;
cout << "Skill " << Maverick.sp <<endl;
cout <<endl;
//print off ninja
cout << "Enemy Ninja Health " << ninja.hp <<endl;
//player battle starts
while(ninja.hp > 0) //fight until ninja dies
{
cout << "Attack!" << endl;
char button; //input for button pressed
cin >> button;
//input is either x v or s on key board.
if(button == x)
{
ninja.hp - slash;
}elseif(button == v)
{
ninja.hp - flameSlash;
}elseif(button == s)
{
ninja.hp - shiningStrike;
}
cout << "Enemy Ninja Health " << ninja.hp <<endl;
atb = false;
//ninja stricks like the flu
Maverick.hp - ninja.atk;
atkTimer();
atb = true; //player can attack now
}//end of while
return 0;
}
Thank you oghma that fixed it just right. I see now that the code was treating it like a variable with out the little '' thingys around it.
For the design Computer i went with the sleep becuase I am thinking of having a realtime stratigy type attack method with player stamina in the later codeing so I can adjust the rate of attack based on the power of the attack and the players stamina. Something different than the standard Final Fantisy game tactics.
Soon I will have much more to this little dos game type very soon. Maybe even images when I get there :(