GL - Player dies and respawns

This commit is contained in:
Erik Persson 2014-02-04 11:13:02 +01:00
parent 1f28c05983
commit 3bf9f59f5a
2 changed files with 11 additions and 1 deletions

View File

@ -35,7 +35,7 @@ using namespace GameLogic;
//return Physics::ICustomBody::SubscriptMessage_none; //return Physics::ICustomBody::SubscriptMessage_none;
break; break;
case OBJECT_TYPE::OBJECT_TYPE_WORLD: case OBJECT_TYPE::OBJECT_TYPE_WORLD:
int test = 5; PlayerVObject(*player,*realObj, kineticEnergyLoss);
break; break;
} }

View File

@ -61,6 +61,7 @@ Player::~Player(void)
void Player::BeginFrame() void Player::BeginFrame()
{ {
weapon->Update(0.002f); weapon->Update(0.002f);
if(playerState == PLAYER_STATE_DEAD) Respawn(Oyster::Math::Float3(0,308,0));
Object::BeginFrame(); Object::BeginFrame();
} }
@ -132,6 +133,7 @@ void Player::Respawn(Oyster::Math::Float3 spawnPoint)
this->life = 100; this->life = 100;
this->playerState = PLAYER_STATE::PLAYER_STATE_IDLE; this->playerState = PLAYER_STATE::PLAYER_STATE_IDLE;
this->lookDir = Oyster::Math::Float4(1,0,0); this->lookDir = Oyster::Math::Float4(1,0,0);
this->setState.SetCenterPosition(spawnPoint);
} }
void Player::Rotate(const Oyster::Math3D::Float4 lookDir) void Player::Rotate(const Oyster::Math3D::Float4 lookDir)
@ -187,5 +189,13 @@ PLAYER_STATE Player::GetState() const
void Player::DamageLife(int damage) void Player::DamageLife(int damage)
{ {
this->life -= damage; this->life -= damage;
this->life = 0;
if(this->life <= 0)
{
this->life = 0;
playerState = PLAYER_STATE_DEAD;
//do stuff that makes you dead
}
} }