Jul 28, 2009 at 10:13am UTC
I can't wait until this becomes a complete game... I will play it. And it will be fun.
It will be fun.
If it's boring I'll kill you all, but no pressure.
Last edited on Jul 28, 2009 at 10:14am UTC
Jul 28, 2009 at 11:43am UTC
Modified
quickAttack to work with a weapon
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
#include <cstdlib>
#include <iostream>
#include <ctime>
#include <cmath>
#include "SDL.h" // Access to 2d graphics API
#include <vector>
#include <algorithm>
class Player {
public :
explicit Player ( unsigned initial_health = 100 ) : health_ ( initial_health ), isDead ( false ), max_health ( initial_health ) { }
void heal( unsigned cure ) { health_ = std::min( health_ + cure, max_health); }
void quickAttack( const weapon &weap, Player &who) { if ( who.health_ > weap.damage ) who.health_ -= weap.damage; else who.isDead = true ; }
private :
std::vector<weapon> weaponry;
unsigned health_;
unsigned max_health;
bool isDead;
};
int main(int argc, char *argv[])
{
Player Havoc(75);
srand( time(0) );
int i;
int rNum = rand() % 10 + 1;
// Do-while loop to
do {
return EXIT_SUCCESS;
}
Last edited on Jul 28, 2009 at 11:43am UTC
Jul 28, 2009 at 6:23pm UTC
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
#include <cstdlib>
#include <iostream>
#include <ctime>
#include <cmath>
#include "SDL.h" // Access to 2d graphics API
#include <vector>
#include <algorithm>
#include "weapon.hpp"
class Player {
public :
explicit Player ( unsigned initial_health = 100 ) : health_ ( initial_health ), isDead ( false ), max_health ( initial_health ) { }
void heal( unsigned cure ) { health_ = std::min( health_ + cure, max_health); }
void quickAttack( const weapon &weap, Player &who) { if ( who.health_ > weap.damage ) who.health_ -= weap.damage; else who.isDead = true ; }
private :
std::vector<weapon> weaponry;
unsigned health_;
unsigned max_health;
bool isDead;
};
int main(int argc, char *argv[])
{
Player Havoc(75);
srand( time(0) );
int i;
int rNum = rand() % 10 + 1;
// Do-while loop to
do {
return EXIT_SUCCESS;
}
edit: changed include '<>' to "
Last edited on Jul 28, 2009 at 7:00pm UTC
Jul 28, 2009 at 7:23pm UTC
Made a little correction for the constructor
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
#include <iostream>
#include <ctime>
#include <cmath>
#include "SDL.h" // Access to 2d graphics API
#include <vector>
#include <algorithm>
#include "weapon.hpp"
class Player {
public :
explicit Player ( unsigned initial_health = 100, const std::vector<weapon>& weapons = std::vector<weapon>() )
: health_ ( initial_health ), isDead ( false ), max_health ( initial_health ), weaponry (weapons) { }
void heal( unsigned cure ) { health_ = std::min( health_ + cure, max_health); }
void quickAttack( const weapon &weap, Player &who) { if ( who.health_ > weap.damage ) who.health_ -= weap.damage; else who.isDead = true ; }
private :
std::vector<weapon> weaponry;
unsigned health_;
unsigned max_health;
bool isDead;
};
int main(int argc, char *argv[])
{
Player Havoc(75);
srand( time(0) );
int i;
int rNum = rand() % 10 + 1;
// Do-while loop to
do {
return EXIT_SUCCESS;
}
1 2 3 4 5 6
class weapon
{
private :
std::string name;
};
Last edited on Jul 28, 2009 at 7:24pm UTC
Jul 28, 2009 at 9:03pm UTC
Added a function to give a new weapon to the player
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
#include <iostream>
#include <ctime>
#include <cmath>
#include "SDL.h" // Access to 2d graphics API
#include <vector>
#include <algorithm>
#include "weapon.hpp"
class Player {
public :
explicit Player ( unsigned initial_health = 100, const std::vector<weapon>& weapons = std::vector<weapon>() )
: health_ ( initial_health ), isDead ( false ), max_health ( initial_health ), weaponry (weapons) { }
void heal( unsigned cure ) { health_ = std::min( health_ + cure, max_health); }
void quickAttack( const weapon &weap, Player &who) { if ( who.health_ > weap.damage ) who.health_ -= weap.damage; else who.isDead = true ; }
void addWeapon ( const weapon &new_weapon ) { weaponry.push_back( new_weapon ); }
private :
std::vector<weapon> weaponry;
unsigned health_;
unsigned max_health;
bool isDead;
};
int main(int argc, char *argv[])
{
Player Havoc(75);
srand( time(0) );
int i;
int rNum = rand() % 10 + 1;
// Do-while loop to
do {
return EXIT_SUCCESS;
}
1 2 3 4 5
class weapon
{
private :
std::string name;
};
Last edited on Jul 28, 2009 at 9:04pm UTC