From bdc5b5e736b2e1fc149b37de32c51b9665e351aa Mon Sep 17 00:00:00 2001 From: lindaandersson Date: Wed, 12 Feb 2014 09:32:13 +0100 Subject: [PATCH] GL - fixed graphics, collision with house, locked to 30 fps on client, jump added --- Code/Game/DanBiasGame/DanBiasGame_Impl.cpp | 8 +++--- .../DanBiasGame/GameClientState/GameState.cpp | 25 +++++++++---------- Code/Game/GameLogic/Level.cpp | 24 +++++++++--------- Code/Game/GameLogic/Player.cpp | 4 +-- 4 files changed, 30 insertions(+), 31 deletions(-) diff --git a/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp index 587a3df1..bf557473 100644 --- a/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp +++ b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp @@ -93,12 +93,12 @@ namespace DanBias m_data->recieverObj->Update(); capFrame += dt; - //if(capFrame > 0.03) + if(capFrame > 0.03) { - Oyster::Graphics::API::Update(dt); - if(Update(dt) != S_OK) + Oyster::Graphics::API::Update(capFrame); + if(Update(capFrame) != S_OK) return DanBiasClientReturn_Error; - if(Render(dt) != S_OK) + if(Render(capFrame) != S_OK) return DanBiasClientReturn_Error; capFrame = 0; } diff --git a/Code/Game/DanBiasGame/GameClientState/GameState.cpp b/Code/Game/DanBiasGame/GameClientState/GameState.cpp index cfc07fc9..e7d41cb3 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/GameState.cpp @@ -50,11 +50,11 @@ bool GameState::Init(Oyster::Network::NetworkClient* nwClient) GameState::gameStateState GameState::LoadGame() { Oyster::Graphics::Definitions::Pointlight plight; - plight.Pos = Float3(315, 0 ,5); + plight.Pos = Float3(615, 0 ,5); plight.Color = Float3(0.9f,0.7f,0.2f); - plight.Radius = 10; + plight.Radius = 100; plight.Bright = 0.5f; - //Oyster::Graphics::API::AddLight(plight); + Oyster::Graphics::API::AddLight(plight); plight.Pos = Float3(10,800,5); plight.Color = Float3(0.9f,0.7f,0.3f); plight.Radius = 300; @@ -122,9 +122,8 @@ bool GameState::LoadModels() this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData); } - /* // add crystal model - modelData.position = Oyster::Math::Float3(10, 301, 0); + modelData.position = Oyster::Math::Float3(10, 601, 0); modelData.modelPath = L"crystalformation_b.dan"; modelData.id = id++; // load models @@ -132,19 +131,19 @@ bool GameState::LoadModels() this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData); // add house model - modelData.position = Oyster::Math::Float3(-50, 290, 0); + modelData.position = Oyster::Math::Float3(-50, 590, 0); //Oyster::Math3D::Float4x4 rot = Oyster::Math3D::RotationMatrix(Oyster::Math::Float3(0 ,Utility::Value::Radian(90.0f), 0)); modelData.visible = true; modelData.modelPath = L"building_corporation.dan"; modelData.id = id++; // load models - this->dynamicObjects.Push(new C_DynamicObj()); - this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData); + this->staticObjects.Push(new C_StaticObj()); + this->staticObjects[this->staticObjects.Size() -1 ]->Init(modelData); // add player model - modelData.position = Oyster::Math::Float3(0, 320, 0); + modelData.position = Oyster::Math::Float3(0, 602, 0); modelData.modelPath = L"char_still_sizeref.dan"; modelData.id = id++; // load models @@ -152,7 +151,7 @@ bool GameState::LoadModels() this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData); // add player model 2 - modelData.position = Oyster::Math::Float3(50, 320, 0); + modelData.position = Oyster::Math::Float3(50, 602, 0); modelData.modelPath = L"char_still_sizeref.dan"; modelData.id = id++; // load models @@ -160,7 +159,7 @@ bool GameState::LoadModels() this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData); // add jumppad - modelData.position = Oyster::Math::Float3(4, 300.3, 0); + modelData.position = Oyster::Math::Float3(4, 600.3, 0); modelData.modelPath = L"jumppad_round.dan"; modelData.id = id++; // load models @@ -174,7 +173,7 @@ bool GameState::LoadModels() modelData.id = id++; // load models this->dynamicObjects.Push(new C_DynamicObj()); - this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData);*/ + this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData); return true; } bool GameState::LoadModels(std::string mapFile) @@ -374,7 +373,7 @@ bool GameState::Render(float dt) std::wstring fps; float f = 1/dt; fps = std::to_wstring(f); - Oyster::Graphics::API::RenderText(fps,Oyster::Math::Float2(0.5f,0.1f),Oyster::Math::Float2(0.05f,0.08f)); + Oyster::Graphics::API::RenderText(fps,Oyster::Math::Float2(0.5f,0.1f),Oyster::Math::Float2(0.2f,0.05f)); Oyster::Graphics::API::EndFrame(); return true; diff --git a/Code/Game/GameLogic/Level.cpp b/Code/Game/GameLogic/Level.cpp index e2e52854..619b491e 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(50); + API::Instance().SetGravity(100); 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); @@ -165,20 +165,20 @@ void Level::InitiateLevel(float radius) - //// add crystal + // add crystal + ICustomBody* rigidBody_Crystal = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(10, 605, 0), 5, 0.5f, 0.8f, 0.6f); - //ICustomBody* rigidBody_Crystal = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(10, 605, 0), 5); - - //this->dynamicObjects.Push(new DynamicObject(rigidBody_Crystal,Object::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX)); - //rigidBody_Crystal->SetCustomTag(this->dynamicObjects[nrOfBoxex]); - - // + this->dynamicObjects.Push(new DynamicObject(rigidBody_Crystal,Object::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX)); + rigidBody_Crystal->SetCustomTag(this->dynamicObjects[nrOfBoxex]); + this->dynamicObjects[nrOfBoxex]->objectID = idCount++; + - //// add house - //ICustomBody* rigidBody_House =API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(10, 905, 0), 0); - //this->staticObjects.Push(new StaticObject(rigidBody_House,Object::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_GENERIC)); - //rigidBody_House->SetCustomTag(this->staticObjects[0]); + // add house + ICustomBody* rigidBody_House =API::Instance().AddCollisionBox(Oyster::Math::Float3(20, 20, 20), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(-50, 590, 0), 0, 0.5f, 0.8f, 0.6f); + this->staticObjects.Push(new StaticObject(rigidBody_House,Object::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_GENERIC)); + rigidBody_House->SetCustomTag(this->staticObjects[0]); + this->staticObjects[0]->objectID = idCount++; } void Level::AddPlayerToTeam(Player *player, int teamID) diff --git a/Code/Game/GameLogic/Player.cpp b/Code/Game/GameLogic/Player.cpp index 039cae63..238d5e68 100644 --- a/Code/Game/GameLogic/Player.cpp +++ b/Code/Game/GameLogic/Player.cpp @@ -156,8 +156,8 @@ void Player::Rotate(const Oyster::Math3D::Float4 lookDir) void Player::Jump() { - Oyster::Math::Float3 up = this->rigidBody->GetState().GetOrientation().v[1]; - //this->rigidBody->GetState().SetLinearVelocity(up *10); + Oyster::Math::Float3 up = this->rigidBody->GetState().GetOrientation().v[1].GetNormalized(); + this->rigidBody->ApplyImpulse(up *2000); } bool Player::IsWalking()