diff --git a/Code/GameLogic/Object.h b/Code/GameLogic/Object.h index aed439e2..a3c9fa2e 100644 --- a/Code/GameLogic/Object.h +++ b/Code/GameLogic/Object.h @@ -5,6 +5,8 @@ #include "Render/Rendering/Render.h" #include "Utilities.h" +#include "PhysicsAPI.h" + namespace GameLogic { @@ -23,6 +25,8 @@ namespace GameLogic protected: //either a model pointer or an ID to an arraypos filled with models that are to be rendered //rigidBody + unsigned int ref; + ::Utility::DynamicMemory::UniquePointer rigidBody; }; diff --git a/Code/GameLogic/Player.cpp b/Code/GameLogic/Player.cpp index d75f101d..a3b103be 100644 --- a/Code/GameLogic/Player.cpp +++ b/Code/GameLogic/Player.cpp @@ -1,11 +1,78 @@ #include "Player.h" +#include "OysterMath.h" + using namespace GameLogic; +using namespace Oyster::Physics; +using namespace Utility::DynamicMemory; + + +//void ColisionEvent(unsigned int obj1Ref, unsigned int obj2Ref) +//{ +// const ICustomBody *body1 = &API::Instance().Peek( obj1Ref ); +// const ICustomBody *body2 = &API::Instance().Peek( obj2Ref ); +// if( body1 != &Error::nobody ) +// { +// Object *obj1 = (Object*) const_cast(body1); +// +// Object *obj2 = (Object*) const_cast(body2); +// +// //switch( obj1->type ) +// //{ +// //case Player: +// // switch (obj2->type) +// // { +// // case låda: +// // //action +// // //soud +// // //particle effect +// +// // } +// +// //case låda : +// +// +// //} +// } +// +//} +void DestructionEvent(unsigned int obj1, ::Utility::DynamicMemory::UniquePointer obj2) +{ + +} Player::Player(void) :Object() { life = 10; + + UniquePointer rigidBody = API::Instance().CreateSimpleRigidBody(); + ref = API::Instance().AddObject(rigidBody); + //ref = API::Instance().AddObject(API::Instance().CreateSimpleRigidBody()); + const ICustomBody* rB; + + //rB = &API::Instance().Peek(ref); + //if( rB == &Error::nobody) + //{ + // //error + //} + + API::Instance().SetCenter(ref, Oyster::Math::Float3::null); + API::Instance().SetMass_KeepMomentum(ref, 20); + // get Tensor matrix (tröghetsmonent) + //API::Instance().SetMomentOfInertiaTensor_KeepMomentum(ref, tensorMatrix ) + + //Oyster::Math::Float3 ve = rB->GetCenter(); + API::Instance().SetDeltaTime(0.01f); + + //API::Instance().ApplyForceAt(ref, rB->GetCenter(), Oyster::Math::Float3::null); + + //API::Instance().SetAction(ColisionEvent); + + //API::Instance().Update(); + + + } @@ -15,7 +82,8 @@ Player::~Player(void) } void Player::Update() { - + //API::Instance().API::Update(); + //API::Instance().API::ApplyForceAt(ref, ) } void Player::Move() diff --git a/Code/GameLogic/Player.h b/Code/GameLogic/Player.h index ca334830..3747e9fe 100644 --- a/Code/GameLogic/Player.h +++ b/Code/GameLogic/Player.h @@ -4,9 +4,12 @@ #include "Object.h" #include "Weapon.h" + namespace GameLogic { - + //void ColisionEvent(unsigned int obj1, unsigned int obj2); + void DestructionEvent(unsigned int obj1, ::Utility::DynamicMemory::UniquePointer obj2); + class Player : public Object { @@ -23,6 +26,8 @@ namespace GameLogic private: int life; Weapon *weapon; + + }; } diff --git a/Code/GameLogic/TestGLMain.cpp b/Code/GameLogic/TestGLMain.cpp index cf78b8a0..6b578a06 100644 --- a/Code/GameLogic/TestGLMain.cpp +++ b/Code/GameLogic/TestGLMain.cpp @@ -10,6 +10,7 @@ #include "Core/Core.h" #include "Render\Preparations\Preparations.h" #include "IGame.h" +#include "InputController.h" @@ -198,6 +199,9 @@ HRESULT Render(float deltaTime) //Oyster::Graphics::Core::deviceContext->Draw(3,0); //Oyster::Graphics::Render::Rendering::Basic::EndFrame(); + + + Oyster::Graphics::Core::swapChain->Present(0,0); return S_OK;