From fa16f71a26f5a5b7c3fc97ebf889bc1ceb7db691 Mon Sep 17 00:00:00 2001 From: lindaandersson Date: Wed, 12 Feb 2014 11:36:08 +0100 Subject: [PATCH] GL - forgot to commit files --- .../DanBiasGame/GameClientState/GameState.h | 1 + Code/Game/GameLogic/CollisionManager.cpp | 1 + Code/Game/GameLogic/Game_PlayerData.cpp | 2 +- Code/Game/GameLogic/Level.cpp | 2 +- Code/Game/GameLogic/Player.cpp | 49 ++++++++++--------- Code/Game/GameLogic/Player.h | 4 +- Code/Game/GameProtocols/ObjectProtocols.h | 10 ++-- 7 files changed, 38 insertions(+), 31 deletions(-) diff --git a/Code/Game/DanBiasGame/GameClientState/GameState.h b/Code/Game/DanBiasGame/GameClientState/GameState.h index 5935398d..74226008 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState.h +++ b/Code/Game/DanBiasGame/GameClientState/GameState.h @@ -33,6 +33,7 @@ private: int myId; float pitch; + float timer; struct myData; myData* privData; Utility::DynamicMemory::DynamicArray> staticObjects; diff --git a/Code/Game/GameLogic/CollisionManager.cpp b/Code/Game/GameLogic/CollisionManager.cpp index 9c6f6aca..3c556d5f 100644 --- a/Code/Game/GameLogic/CollisionManager.cpp +++ b/Code/Game/GameLogic/CollisionManager.cpp @@ -38,6 +38,7 @@ using namespace GameLogic; break; case OBJECT_TYPE::OBJECT_TYPE_WORLD: PlayerVObject(*player,*realObj, kineticEnergyLoss); + player->playerState = PLAYER_STATE::PLAYER_STATE_WALKING; break; } diff --git a/Code/Game/GameLogic/Game_PlayerData.cpp b/Code/Game/GameLogic/Game_PlayerData.cpp index 39ce44cb..908dd42f 100644 --- a/Code/Game/GameLogic/Game_PlayerData.cpp +++ b/Code/Game/GameLogic/Game_PlayerData.cpp @@ -6,7 +6,7 @@ using namespace GameLogic; Game::PlayerData::PlayerData() { //set some stats that are appropriate to a player - Oyster::Math::Float3 centerPosition = Oyster::Math::Float3(0,628,-25); + Oyster::Math::Float3 centerPosition = Oyster::Math::Float3(0,603,0); Oyster::Math::Float3 size = Oyster::Math::Float3(0.25f,1.0f,0.5f); Oyster::Math::Float mass = 60; Oyster::Math::Float restitutionCoeff = 0.5; diff --git a/Code/Game/GameLogic/Level.cpp b/Code/Game/GameLogic/Level.cpp index 619b491e..e7b10eac 100644 --- a/Code/Game/GameLogic/Level.cpp +++ b/Code/Game/GameLogic/Level.cpp @@ -113,7 +113,7 @@ void Level::InitiateLevel(std::string levelPath) void Level::InitiateLevel(float radius) { API::Instance().SetGravityPoint(Oyster::Math3D::Float3(0,0,0)); - API::Instance().SetGravity(100); + API::Instance().SetGravity(200); int idCount = 100; // add level sphere ICustomBody* rigidBody = API::Instance().AddCollisionSphere(599.2f, Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 0, 0), 0, 0.5f, 0.8f, 0.6f); diff --git a/Code/Game/GameLogic/Player.cpp b/Code/Game/GameLogic/Player.cpp index 238d5e68..61ee108f 100644 --- a/Code/Game/GameLogic/Player.cpp +++ b/Code/Game/GameLogic/Player.cpp @@ -45,7 +45,8 @@ void Player::InitPlayer() this->life = 100; this->teamID = -1; this->playerState = PLAYER_STATE_IDLE; - lookDir = Oyster::Math::Float4(0,0,-1,0); + this->lookDir = Oyster::Math::Float3(0,0,-1); + this->moveDir = Oyster::Math::Float3(0,0,0); } Player::~Player(void) @@ -61,8 +62,6 @@ void Player::BeginFrame() { //weapon->Update(0.002f); Object::BeginFrame(); - - } void Player::EndFrame() @@ -99,27 +98,37 @@ void Player::Move(const PLAYER_MOVEMENT &movement) void Player::MoveForward() { - Oyster::Math::Float3 forward = this->rigidBody->GetState().GetOrientation().v[2]; - rigidBody->SetLinearVelocity( MOVE_FORCE * forward.GetNormalized() ); + Oyster::Math::Float3 forward = this->rigidBody->GetState().GetOrientation().v[2].GetNormalized(); + moveDir = forward; + moveDir.Normalize(); + rigidBody->SetLinearVelocity( MOVE_FORCE * moveDir ); } void Player::MoveBackwards() { - Oyster::Math::Float3 forward = this->rigidBody->GetState().GetOrientation().v[2]; - rigidBody->SetLinearVelocity( MOVE_FORCE * -forward.GetNormalized() ); + Oyster::Math::Float3 forward = this->rigidBody->GetState().GetOrientation().v[2].GetNormalized(); + moveDir = -forward; + moveDir.Normalize(); + rigidBody->SetLinearVelocity( MOVE_FORCE * moveDir ); } void Player::MoveRight() { //Do cross product with forward vector and negative gravity vector - Oyster::Math::Float3 forward = this->rigidBody->GetState().GetOrientation().v[2]; - Oyster::Math::Float3 r = (-this->rigidBody->GetState().centerPos.Normalize()).Cross(forward); - rigidBody->SetLinearVelocity(r * MOVE_FORCE); + Oyster::Math::Float3 forward = this->rigidBody->GetState().GetOrientation().v[2].GetNormalized(); + Oyster::Math::Float3 up = this->rigidBody->GetState().centerPos.Normalize(); + Oyster::Math::Float3 r = (up).Cross(forward).Normalize(); + moveDir = -r; + moveDir.Normalize(); + rigidBody->SetLinearVelocity( MOVE_FORCE * moveDir ); } void Player::MoveLeft() { //Do cross product with forward vector and negative gravity vector - Oyster::Math::Float3 forward = this->rigidBody->GetState().GetOrientation().v[2]; - Oyster::Math::Float3 r = (-this->rigidBody->GetState().centerPos.Normalize()).Cross(forward); - rigidBody->SetLinearVelocity(-r * MOVE_FORCE); + Oyster::Math::Float3 forward = this->rigidBody->GetState().GetOrientation().v[2].GetNormalized(); + Oyster::Math::Float3 up = this->rigidBody->GetState().centerPos.Normalize(); + Oyster::Math::Float3 r = (up).Cross(forward).Normalize(); + moveDir = r; + moveDir.Normalize(); + rigidBody->SetLinearVelocity( MOVE_FORCE * moveDir ); } void Player::UseWeapon(const WEAPON_FIRE &usage) @@ -137,27 +146,19 @@ void Player::Respawn(Oyster::Math::Float3 spawnPoint) void Player::Rotate(const Oyster::Math3D::Float4 lookDir) { - // right - Oyster::Math::Float dx = lookDir.w; - if(dx > 0.0f) - { - int i =0 ; - } - + // this is the camera right vector this->lookDir = lookDir.xyz; - this->dx = lookDir.w; - Oyster::Math::Float3 up = this->rigidBody->GetState().GetOrientation().v[1]; this->rigidBody->SetUpAndRight(up, lookDir.xyz); this->rigidBody->SetUpAndRight(this->rigidBody->GetState().centerPos.GetNormalized(), this->rigidBody->GetState().GetOrientation().v[0].xyz.GetNormalized()); - } void Player::Jump() { Oyster::Math::Float3 up = this->rigidBody->GetState().GetOrientation().v[1].GetNormalized(); - this->rigidBody->ApplyImpulse(up *2000); + this->rigidBody->ApplyImpulse(up *1500); + this->playerState == PLAYER_STATE::PLAYER_STATE_JUMPING; } bool Player::IsWalking() diff --git a/Code/Game/GameLogic/Player.h b/Code/Game/GameLogic/Player.h index b7791a42..623b0988 100644 --- a/Code/Game/GameLogic/Player.h +++ b/Code/Game/GameLogic/Player.h @@ -85,8 +85,8 @@ namespace GameLogic int teamID; Weapon *weapon; PLAYER_STATE playerState; - Oyster::Math::Float3 lookDir; //Duplicate in Object.h? - Oyster::Math::Float dx; //dx of what? + Oyster::Math::Float3 moveDir; + Oyster::Math::Float3 lookDir; bool hasTakenDamage; float invincibleCooldown; diff --git a/Code/Game/GameProtocols/ObjectProtocols.h b/Code/Game/GameProtocols/ObjectProtocols.h index 753d61e3..6dd32d62 100644 --- a/Code/Game/GameProtocols/ObjectProtocols.h +++ b/Code/Game/GameProtocols/ObjectProtocols.h @@ -292,7 +292,7 @@ namespace GameLogic { short object_ID; float position[3]; - float rotation[3]; + float rotation[4]; Protocol_ObjectPositionRotation() { @@ -307,10 +307,11 @@ namespace GameLogic this->protocol[5].type = Oyster::Network::NetAttributeType_Float; this->protocol[6].type = Oyster::Network::NetAttributeType_Float; this->protocol[7].type = Oyster::Network::NetAttributeType_Float; + this->protocol[8].type = Oyster::Network::NetAttributeType_Float; this->object_ID = 0; memset(&this->position[0], 0, sizeof(float) * 3); - memset(&this->rotation[0], 0, sizeof(float) * 3); + memset(&this->rotation[0], 0, sizeof(float) * 4); } Protocol_ObjectPositionRotation(Oyster::Network::CustomNetProtocol& p) { @@ -323,6 +324,7 @@ namespace GameLogic this->rotation[0] = p[5].value.netFloat; this->rotation[1] = p[6].value.netFloat; this->rotation[2] = p[7].value.netFloat; + this->rotation[3] = p[8].value.netFloat; } Protocol_ObjectPositionRotation(float p[3], float r[3], int id) { @@ -337,10 +339,11 @@ namespace GameLogic this->protocol[5].type = Oyster::Network::NetAttributeType_Float; this->protocol[6].type = Oyster::Network::NetAttributeType_Float; this->protocol[7].type = Oyster::Network::NetAttributeType_Float; + this->protocol[8].type = Oyster::Network::NetAttributeType_Float; object_ID = id; memcpy(&this->position[0], &p[0], sizeof(float) * 3); - memcpy(&this->rotation[0], &r[0], sizeof(float) * 3); + memcpy(&this->rotation[0], &r[0], sizeof(float) * 4); } Oyster::Network::CustomNetProtocol GetProtocol() override { @@ -351,6 +354,7 @@ namespace GameLogic this->protocol[5].value = this->rotation[0]; this->protocol[6].value = this->rotation[1]; this->protocol[7].value = this->rotation[2]; + this->protocol[8].value = this->rotation[3]; return protocol; }