From 3bf9f59f5a752311104a1c53c768b63457910661 Mon Sep 17 00:00:00 2001 From: Erik Persson Date: Tue, 4 Feb 2014 11:13:02 +0100 Subject: [PATCH] GL - Player dies and respawns --- Code/Game/GameLogic/CollisionManager.cpp | 2 +- Code/Game/GameLogic/Player.cpp | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Code/Game/GameLogic/CollisionManager.cpp b/Code/Game/GameLogic/CollisionManager.cpp index 5c226362..37916799 100644 --- a/Code/Game/GameLogic/CollisionManager.cpp +++ b/Code/Game/GameLogic/CollisionManager.cpp @@ -35,7 +35,7 @@ using namespace GameLogic; //return Physics::ICustomBody::SubscriptMessage_none; break; case OBJECT_TYPE::OBJECT_TYPE_WORLD: - int test = 5; + PlayerVObject(*player,*realObj, kineticEnergyLoss); break; } diff --git a/Code/Game/GameLogic/Player.cpp b/Code/Game/GameLogic/Player.cpp index 235fab13..81c1b6d8 100644 --- a/Code/Game/GameLogic/Player.cpp +++ b/Code/Game/GameLogic/Player.cpp @@ -61,6 +61,7 @@ Player::~Player(void) void Player::BeginFrame() { weapon->Update(0.002f); + if(playerState == PLAYER_STATE_DEAD) Respawn(Oyster::Math::Float3(0,308,0)); Object::BeginFrame(); } @@ -132,6 +133,7 @@ void Player::Respawn(Oyster::Math::Float3 spawnPoint) this->life = 100; this->playerState = PLAYER_STATE::PLAYER_STATE_IDLE; this->lookDir = Oyster::Math::Float4(1,0,0); + this->setState.SetCenterPosition(spawnPoint); } void Player::Rotate(const Oyster::Math3D::Float4 lookDir) @@ -187,5 +189,13 @@ PLAYER_STATE Player::GetState() const void Player::DamageLife(int damage) { this->life -= damage; + this->life = 0; + + if(this->life <= 0) + { + this->life = 0; + playerState = PLAYER_STATE_DEAD; + //do stuff that makes you dead + } }