diff --git a/Code/GameLogic/DynamicObject.cpp b/Code/GameLogic/DynamicObject.cpp
index ec175f59..14e0518d 100644
--- a/Code/GameLogic/DynamicObject.cpp
+++ b/Code/GameLogic/DynamicObject.cpp
@@ -5,9 +5,8 @@ using namespace Oyster::Physics;
using namespace Utility::DynamicMemory;
DynamicObject::DynamicObject(void)
+ :Object()
{
- rigidBody = API::Instance().CreateSimpleRigidBody();
- API::Instance().AddObject(rigidBody);
}
@@ -17,5 +16,5 @@ DynamicObject::~DynamicObject(void)
void DynamicObject::Update()
{
- //updatera objectet
+ //update object
}
\ No newline at end of file
diff --git a/Code/GameLogic/GameLogic.vcxproj b/Code/GameLogic/GameLogic.vcxproj
index e4e48526..b0733004 100644
--- a/Code/GameLogic/GameLogic.vcxproj
+++ b/Code/GameLogic/GameLogic.vcxproj
@@ -176,8 +176,10 @@
+
+
@@ -187,8 +189,10 @@
+
+
diff --git a/Code/GameLogic/GameLogic.vcxproj.filters b/Code/GameLogic/GameLogic.vcxproj.filters
index 38b2d5fa..e0ed6161 100644
--- a/Code/GameLogic/GameLogic.vcxproj.filters
+++ b/Code/GameLogic/GameLogic.vcxproj.filters
@@ -42,6 +42,12 @@
Header Files
+
+ Header Files
+
+
+ Header Files
+
@@ -74,5 +80,11 @@
Source Files
+
+ Source Files
+
+
+ Source Files
+
\ No newline at end of file
diff --git a/Code/GameLogic/IGame.cpp b/Code/GameLogic/IGame.cpp
index 883a9285..0fe09345 100644
--- a/Code/GameLogic/IGame.cpp
+++ b/Code/GameLogic/IGame.cpp
@@ -8,16 +8,14 @@ BOOL WINAPI DllMain(
_In_ LPVOID lpvReserved
)
{
-
return TRUE;
}
using namespace GameLogic;
+
IGame::IGame()
{
gameModule = new Game();
}
-
-
IGame::~IGame()
{
delete gameModule;
diff --git a/Code/GameLogic/Object.cpp b/Code/GameLogic/Object.cpp
index ddcb4656..965af90e 100644
--- a/Code/GameLogic/Object.cpp
+++ b/Code/GameLogic/Object.cpp
@@ -18,7 +18,10 @@ Object::Object(void)
model = new Model();
model = Oyster::Graphics::API::CreateModel(L"bth.obj");
- ICustomBody* temp = rigidBody = API::Instance().CreateRigidBody().Release();
+ API::SimpleBodyDescription sbDesc;
+ //sbDesc.centerPosition =
+
+ ICustomBody* temp = rigidBody = API::Instance().CreateRigidBody(sbDesc).Release();
GameLogic::RefManager::getInstance()->AddMapping(*rigidBody, *this);
@@ -36,7 +39,6 @@ void Object::Render()
{
this->rigidBody->GetOrientation(model->WorldMatrix);
Oyster::Graphics::API::RenderScene(model, 1);
-
}
Object::OBJECT_TYPE Object::GetType()
diff --git a/Code/GameLogic/Object.h b/Code/GameLogic/Object.h
index be2f77a6..767edb1f 100644
--- a/Code/GameLogic/Object.h
+++ b/Code/GameLogic/Object.h
@@ -18,16 +18,16 @@ namespace GameLogic
{
class Object
{
- public:
- Object(void);
- virtual ~Object(void);
+ public:
enum OBJECT_TYPE
{
OBJECT_TYPE_PLAYER,
OBJECT_TYPE_BOX,
};
-
+ Object(void);
+ virtual ~Object(void);
+
void Render();
OBJECT_TYPE GetType();
diff --git a/Code/GameLogic/Player.cpp b/Code/GameLogic/Player.cpp
index 3a9ae029..93a83506 100644
--- a/Code/GameLogic/Player.cpp
+++ b/Code/GameLogic/Player.cpp
@@ -1,54 +1,53 @@
#include "Player.h"
#include "OysterMath.h"
-
using namespace GameLogic;
using namespace Oyster::Physics;
-using namespace Utility::DynamicMemory;
-
-
-
Player::Player(void)
:Object()
{
life = 100;
}
-
-
Player::~Player(void)
{
delete this->rigidBody;
}
+
void Player::Update(keyInput keyPressed)
{
if(keyPressed != keyInput_none)
{
- Move();
-
- if(keyPressed == keyInput_A)
- {
- Oyster::Math::Float3 pos = this->rigidBody->GetCenter();
- pos.x -= 0.1;
- rigidBody->SetCenter(pos);
- }
- if(keyPressed == keyInput_D)
- {
- Oyster::Math::Float3 pos = this->rigidBody->GetCenter();
- pos.x += 0.1;
- rigidBody->SetCenter(pos);
- }
+ Move(keyPressed);
}
-
}
-void Player::Move()
+void Player::Move(keyInput keyPressed)
{
- //API::Instance().Update();
- /*Oyster::Math::Float3 pos = this->rigidBody->GetCenter();
- pos.x += 0.1;
- rigidBody->SetCenter(pos);*/
- //API::Instance().SetCenter(rigidBody, pos);
+ if(keyPressed == keyInput_A)
+ {
+ Oyster::Math::Float3 pos = this->rigidBody->GetCenter();
+ pos.x -= 0.1;
+ rigidBody->SetCenter(pos);
+ }
+ if(keyPressed == keyInput_D)
+ {
+ Oyster::Math::Float3 pos = this->rigidBody->GetCenter();
+ pos.x += 0.1;
+ rigidBody->SetCenter(pos);
+ }
+ if(keyPressed == keyInput_S)
+ {
+ Oyster::Math::Float3 pos = this->rigidBody->GetCenter();
+ pos.y -= 0.1;
+ rigidBody->SetCenter(pos);
+ }
+ if(keyPressed == keyInput_W)
+ {
+ Oyster::Math::Float3 pos = this->rigidBody->GetCenter();
+ pos.y += 0.1;
+ rigidBody->SetCenter(pos);
+ }
}
void Player::Shoot()
{
diff --git a/Code/GameLogic/Player.h b/Code/GameLogic/Player.h
index 7726fed4..7c4045e3 100644
--- a/Code/GameLogic/Player.h
+++ b/Code/GameLogic/Player.h
@@ -13,27 +13,25 @@
namespace GameLogic
{
-
-
class Player : public Object
{
public:
Player(void);
~Player(void);
-
+
+ /********************************************************
+ * Update the position of the rigid body
+ * This will be done with physics later
+ ********************************************************/
void Update(keyInput keyPressed);
- void Move();
+ void Move(keyInput keyPressed);
void Shoot();
-
private:
- int life;
- Weapon *weapon;
-
-
+ int life;
+ Weapon *weapon;
};
-
}
#endif
\ No newline at end of file
diff --git a/Code/GameLogic/TestGLMain.cpp b/Code/GameLogic/TestGLMain.cpp
index 8cf34e5f..a03ba314 100644
--- a/Code/GameLogic/TestGLMain.cpp
+++ b/Code/GameLogic/TestGLMain.cpp
@@ -5,6 +5,12 @@
//
// Copyright (c) Stefan Petersson 2011. All rights reserved.
//--------------------------------------------------------------------------------------
+
+//////////////////////////////////////////////////////////////////////////
+// Test main function for game logic when .exe
+// Doesn't run when Game logic is compiled as a .dll
+//////////////////////////////////////////////////////////////////////////
+
#define NOMINMAX
#include
#include "Core/Core.h"
@@ -28,8 +34,8 @@
HINSTANCE g_hInst = NULL;
HWND g_hWnd = NULL;
-GameLogic::IGame* game;
-InputClass* inputObj;
+GameLogic::IGame *game;
+InputClass *inputObj;
//--------------------------------------------------------------------------------------
@@ -95,8 +101,9 @@ int WINAPI wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdL
__int64 prevTimeStamp = 0;
QueryPerformanceCounter((LARGE_INTEGER*)&prevTimeStamp);
- //debugwindow
+ //Init debug window
//SetStdOutToNewConsole();
+
// Main message loop
MSG msg = {0};
while(WM_QUIT != msg.message)
@@ -171,56 +178,21 @@ HRESULT InitWindow( HINSTANCE hInstance, int nCmdShow )
return S_OK;
}
-
-
//--------------------------------------------------------------------------------------
-// Create Direct3D device and swap chain
+// Create Direct3D with Oyster Graphics
//--------------------------------------------------------------------------------------
HRESULT InitDirect3D()
{
- /*HRESULT hr = S_OK;;
-
- Oyster::Graphics::Core::resolution = Oyster::Math::Float2( 1024, 768 );
-
- if(Oyster::Graphics::Core::Init::FullInit(g_hWnd,false,false)==Oyster::Graphics::Core::Init::Fail)
+ if(Oyster::Graphics::API::Init(g_hWnd, false, false, Oyster::Math::Float2( 1024, 768)) != Oyster::Graphics::API::Sucsess)
return E_FAIL;
-
-
-
- std::wstring ShaderPath = L"..\\OysterGraphics\\Shader\\HLSL\\";
- std::wstring EffectPath = L"SimpleDebug\\";
-
- Oyster::Graphics::Core::ShaderManager::Init(ShaderPath + EffectPath + L"DebugPixel.hlsl",Oyster::Graphics::Core::ShaderManager::ShaderType::Pixel,L"Debug",false);
- Oyster::Graphics::Core::ShaderManager::Init(ShaderPath + EffectPath + L"DebugVertex.hlsl",Oyster::Graphics::Core::ShaderManager::ShaderType::Vertex,L"PassThroughFloat4",false);
-
- Oyster::Graphics::Core::ShaderManager::Set::Vertex(Oyster::Graphics::Core::ShaderManager::Get::Vertex(L"PassThroughFloat4"));
- Oyster::Graphics::Core::ShaderManager::Set::Pixel(Oyster::Graphics::Core::ShaderManager::Get::Pixel(L"Debug"));
-
- D3D11_INPUT_ELEMENT_DESC inputDesc[] =
- {
- { "POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }
- };
-
- ID3D11InputLayout* layout;
-
- Oyster::Graphics::Core::ShaderManager::CreateInputLayout( inputDesc, 1, Oyster::Graphics::Core::ShaderManager::Get::Vertex(L"PassThroughFloat4"), layout);
-
- Oyster::Graphics::Core::deviceContext->IASetInputLayout(layout);
- Oyster::Graphics::Core::deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
-
- Oyster::Graphics::Render::Preparations::Basic::BindBackBufferRTV();
-
- Oyster::Graphics::Render::Preparations::Basic::SetViewPort();*/
-
return S_OK;
}
+//--------------------------------------------------------------------------------------
+// Init the input and the game
+//-------------------------------------------------------------------------------------
HRESULT InitGame()
{
-
- if(Oyster::Graphics::API::Init(g_hWnd, false, false, Oyster::Math::Float2( 1024, 768)) != Oyster::Graphics::API::Sucsess)
- return E_FAIL;
-
inputObj = new InputClass;
if(!inputObj->Initialize(g_hInst, g_hWnd, 1024, 768))
{
@@ -231,10 +203,9 @@ HRESULT InitGame()
game->Init();
game->StartGame();
-
-
return S_OK;
}
+
HRESULT Update(float deltaTime)
{
inputObj->Update();
@@ -272,10 +243,10 @@ HRESULT Render(float deltaTime)
}
// test view and projection matrix
- Oyster::Math::Float3 dir = Oyster::Math::Float3(0,0,-1);
- Oyster::Math::Float3 up =Oyster::Math::Float3(0,1,0);
+ Oyster::Math::Float3 dir = Oyster::Math::Float3(0, 0, -1);
+ Oyster::Math::Float3 up = Oyster::Math::Float3(0, 1, 0);
Oyster::Math::Float3 pos = Oyster::Math::Float3(0, 0, 100);
-
+
Oyster::Math::Float4x4 view =Oyster::Math3D::OrientationMatrix_LookAtDirection(dir, up, pos);
view = view.GetInverse();
diff --git a/Code/Input/L_inputClass.h b/Code/Input/L_inputClass.h
index b5a08c31..4b11c369 100644
--- a/Code/Input/L_inputClass.h
+++ b/Code/Input/L_inputClass.h
@@ -1,3 +1,9 @@
+//////////////////////////////////////////////////////////////////////////
+// Temp input handler, not stable!
+// When starting the program, don't click anywhere until the program starts
+// because that breaks the input..
+//////////////////////////////////////////////////////////////////////////
+
#ifndef _INPUTCLASS_H_
#define _INPUTCLASS_H_
@@ -23,7 +29,6 @@ private:
bool ReadKeyboard();
bool ReadMouse();
-
public: