GameLogic - player now using some of the new phys api

This commit is contained in:
Erik Persson 2014-01-09 13:06:18 +01:00
parent 48b9189a03
commit 52ba5602d5
2 changed files with 12 additions and 11 deletions

View File

@ -15,6 +15,7 @@ namespace Oyster
namespace Physics namespace Physics
{ {
class ICustomBody; class ICustomBody;
class State;
} }
} }
namespace GameLogic namespace GameLogic
@ -36,6 +37,8 @@ namespace GameLogic
int objectID; int objectID;
protected: protected:
Oyster::Physics::ICustomBody *rigidBody; Oyster::Physics::ICustomBody *rigidBody;
Oyster::Physics::ICustomBody::State *state;
}; };
} }

View File

@ -16,7 +16,7 @@ struct Player::PrivateData
teamID = -1; teamID = -1;
playerState = PLAYER_STATE::PLAYER_STATE_IDLE; playerState = PLAYER_STATE::PLAYER_STATE_IDLE;
lookDir = Oyster::Math::Float3(1,0,0); lookDir = Oyster::Math::Float4(1,0,0);
} }
~PrivateData() ~PrivateData()
@ -31,7 +31,7 @@ struct Player::PrivateData
int teamID; int teamID;
Weapon *weapon; Weapon *weapon;
PLAYER_STATE playerState; PLAYER_STATE playerState;
Oyster::Math::Float3 lookDir; Oyster::Math::Float4 lookDir;
}myData; }myData;
@ -49,8 +49,6 @@ Player::~Player(void)
void Player::Move(const PLAYER_MOVEMENT &movement) void Player::Move(const PLAYER_MOVEMENT &movement)
{ {
//Oyster::Math::Float3 currentVelocity = rigidBody->GetRigidLinearVelocity();
switch(movement) switch(movement)
{ {
case PLAYER_MOVEMENT::PLAYER_MOVEMENT_FORWARD: case PLAYER_MOVEMENT::PLAYER_MOVEMENT_FORWARD:
@ -77,23 +75,23 @@ void Player::Move(const PLAYER_MOVEMENT &movement)
void Player::MoveForward() void Player::MoveForward()
{ {
//API::Instance().ApplyForceAt(rigidBody,rigidBody->GetCenter(),myData->lookDir * 100); state->ApplyLinearImpulse(myData->lookDir * 100);
} }
void Player::MoveBackwards() void Player::MoveBackwards()
{ {
//API::Instance().ApplyForceAt(rigidBody,rigidBody->GetCenter(),-myData->lookDir * 100); state->ApplyLinearImpulse(-myData->lookDir * 100);
} }
void Player::MoveRight() void Player::MoveRight()
{ {
//Do cross product with forward vector and negative gravity vector //Do cross product with forward vector and negative gravity vector
//Oyster::Math::Float3 r = (-rigidBody->GetGravityNormal()).Cross(myData->lookDir); Oyster::Math::Float4 r = (-rigidBody->GetGravityNormal()).Cross((Oyster::Math::Float3)myData->lookDir);
//API::Instance().ApplyForceAt(rigidBody, rigidBody->GetCenter(), r * 100); state->ApplyLinearImpulse(r * 100);
} }
void Player::MoveLeft() void Player::MoveLeft()
{ {
//Do cross product with forward vector and negative gravity vector //Do cross product with forward vector and negative gravity vector
//Oyster::Math::Float3 r = -(-rigidBody->GetGravityNormal()).Cross(myData->lookDir); Oyster::Math::Float4 r = -(-rigidBody->GetGravityNormal()).Cross((Oyster::Math::Float3)myData->lookDir);
//API::Instance().ApplyForceAt(rigidBody, rigidBody->GetCenter(), r * 100); state->ApplyLinearImpulse(-r * 100);
} }
void Player::UseWeapon(const WEAPON_FIRE &fireInput) void Player::UseWeapon(const WEAPON_FIRE &fireInput)
@ -106,7 +104,7 @@ void Player::Respawn(Oyster::Math::Float3 spawnPoint)
//API::Instance().SetCenter(rigidBody,spawnPoint); //API::Instance().SetCenter(rigidBody,spawnPoint);
myData->life = 100; myData->life = 100;
myData->playerState = PLAYER_STATE::PLAYER_STATE_IDLE; myData->playerState = PLAYER_STATE::PLAYER_STATE_IDLE;
myData->lookDir = Oyster::Math::Float3(1,0,0); myData->lookDir = Oyster::Math::Float4(1,0,0);
} }
void Player::Jump() void Player::Jump()