Changeset 64a1f4e in network-game for common/Game.cpp


Ignore:
Timestamp:
Jan 29, 2014, 2:06:36 AM (11 years ago)
Author:
dportnoy <dmp1488@…>
Branches:
master
Children:
8826eed
Parents:
d6b5f74
Message:

Game.addPlayer reset all the player's stats as well

File:
1 edited

Legend:

Unmodified
Added
Removed
  • common/Game.cpp

    rd6b5f74 r64a1f4e  
    33#include <iostream>
    44#include <cstring>
     5#include <cstdlib>
    56
    67#include "Common.h"
     
    4546   if (players.find(p->getId()) == players.end()) {
    4647      players[p->getId()] = p;
     48
     49      // reset player stats, location, etc.
     50      p->pos.x = p->target.x = 200;
     51      p->pos.y = p->target.y = 200;
     52      p->setTargetPlayer(0);
     53      p->isChasing = false;
     54      p->isAttacking = false;
     55      p->isDead = false;
     56      p->health = p->maxHealth;
     57      p->hasBlueFlag = false;
     58      p->hasRedFlag = false;
     59
     60      // choose a random team (either 0 or 1)
     61      p->team = rand() % 2;
     62
     63      p->currentGame = this;
     64
    4765      return true;
    4866   }
Note: See TracChangeset for help on using the changeset viewer.