First working multiplayer version
This commit is contained in:
@@ -3,38 +3,54 @@
|
||||
class Player
|
||||
{
|
||||
public:
|
||||
Player(int[3], int, int);
|
||||
Player(int, int, int);
|
||||
int Id() const;
|
||||
int Lives() const;
|
||||
void Lives(int);
|
||||
int Lives();
|
||||
bool Alive() const;
|
||||
void Kill();
|
||||
bool Alive();
|
||||
void moveto(int);
|
||||
void setColor(int, int, int);
|
||||
void moveby(int);
|
||||
int color[3];
|
||||
int position;
|
||||
bool attacking;
|
||||
int last_attack;
|
||||
void moveto(int);
|
||||
void Spawn(int);
|
||||
void updateState(bool tilted, bool wobbled, int time);
|
||||
void startAttack(int time);
|
||||
int _lastState; // 0-> idle; 1-> move; 2 -> attack
|
||||
// public variables
|
||||
int position;
|
||||
int speed;
|
||||
bool attacking;
|
||||
bool captured;
|
||||
int last_attack;
|
||||
int color[3];
|
||||
private:
|
||||
int _id;
|
||||
int _lives;
|
||||
int _state;
|
||||
|
||||
int _lastState; // 0-> idle; 1-> move; 2 -> attack
|
||||
int _attackDuration;
|
||||
};
|
||||
|
||||
Player::Player(int player_color[3], int lives, int attackDuration){
|
||||
Player::Player(int id, int lives, int attackDuration){
|
||||
_lives = lives;
|
||||
_id = id;
|
||||
|
||||
attacking = false;
|
||||
|
||||
color[0] = player_color[0];
|
||||
color[1] = player_color[1];
|
||||
color[2] = player_color[2];
|
||||
|
||||
_attackDuration = attackDuration;
|
||||
|
||||
_lastState = 0; // start as idle;
|
||||
|
||||
captured = false;
|
||||
}
|
||||
|
||||
void Player::setColor(int r, int g, int b){
|
||||
color[0] = r;
|
||||
color[1] = g;
|
||||
color[2] = b;
|
||||
}
|
||||
|
||||
int Player::Id() const
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
void Player::updateState(bool tilted, bool wobbled, int time) {
|
||||
@@ -65,16 +81,23 @@ void Player::Lives(int n){
|
||||
_lives = n;
|
||||
}
|
||||
|
||||
bool Player::Alive(){
|
||||
bool Player::Alive() const{
|
||||
return _lives > 0;
|
||||
}
|
||||
|
||||
void Player::Kill(){
|
||||
captured = true;
|
||||
|
||||
_lives--;
|
||||
if (_lives < 0) _lives = 0;
|
||||
}
|
||||
|
||||
int Player::Lives(){
|
||||
void Player::Spawn(int pos){
|
||||
captured = false;
|
||||
moveto(pos);
|
||||
}
|
||||
|
||||
int Player::Lives() const{
|
||||
return _lives;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user