Merge branch 'GameLogicBranch' of https://github.com/dean11/Danbias into GameLogicBranch
This commit is contained in:
commit
f9a1aaf43c
|
@ -5,9 +5,8 @@ using namespace Oyster::Physics;
|
||||||
using namespace Utility::DynamicMemory;
|
using namespace Utility::DynamicMemory;
|
||||||
|
|
||||||
DynamicObject::DynamicObject(void)
|
DynamicObject::DynamicObject(void)
|
||||||
|
:Object()
|
||||||
{
|
{
|
||||||
rigidBody = API::Instance().CreateSimpleRigidBody();
|
|
||||||
API::Instance().AddObject(rigidBody);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,5 +16,5 @@ DynamicObject::~DynamicObject(void)
|
||||||
|
|
||||||
void DynamicObject::Update()
|
void DynamicObject::Update()
|
||||||
{
|
{
|
||||||
//updatera objectet
|
//update object
|
||||||
}
|
}
|
|
@ -176,8 +176,10 @@
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClInclude Include="CollisionManager.h" />
|
||||||
<ClInclude Include="DynamicObject.h" />
|
<ClInclude Include="DynamicObject.h" />
|
||||||
<ClInclude Include="Game.h" />
|
<ClInclude Include="Game.h" />
|
||||||
|
<ClInclude Include="GameMode.h" />
|
||||||
<ClInclude Include="IGame.h" />
|
<ClInclude Include="IGame.h" />
|
||||||
<ClInclude Include="Level.h" />
|
<ClInclude Include="Level.h" />
|
||||||
<ClInclude Include="Object.h" />
|
<ClInclude Include="Object.h" />
|
||||||
|
@ -187,8 +189,10 @@
|
||||||
<ClInclude Include="Weapon.h" />
|
<ClInclude Include="Weapon.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClCompile Include="CollisionManager.cpp" />
|
||||||
<ClCompile Include="DynamicObject.cpp" />
|
<ClCompile Include="DynamicObject.cpp" />
|
||||||
<ClCompile Include="Game.cpp" />
|
<ClCompile Include="Game.cpp" />
|
||||||
|
<ClCompile Include="GameMode.cpp" />
|
||||||
<ClCompile Include="IGame.cpp" />
|
<ClCompile Include="IGame.cpp" />
|
||||||
<ClCompile Include="Level.cpp" />
|
<ClCompile Include="Level.cpp" />
|
||||||
<ClCompile Include="Object.cpp" />
|
<ClCompile Include="Object.cpp" />
|
||||||
|
|
|
@ -42,6 +42,12 @@
|
||||||
<ClInclude Include="RefManager.h">
|
<ClInclude Include="RefManager.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="GameMode.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="CollisionManager.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="Game.cpp">
|
<ClCompile Include="Game.cpp">
|
||||||
|
@ -74,5 +80,11 @@
|
||||||
<ClCompile Include="TestGLMain.cpp">
|
<ClCompile Include="TestGLMain.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="GameMode.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="CollisionManager.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -8,16 +8,14 @@ BOOL WINAPI DllMain(
|
||||||
_In_ LPVOID lpvReserved
|
_In_ LPVOID lpvReserved
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
using namespace GameLogic;
|
using namespace GameLogic;
|
||||||
|
|
||||||
IGame::IGame()
|
IGame::IGame()
|
||||||
{
|
{
|
||||||
gameModule = new Game();
|
gameModule = new Game();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
IGame::~IGame()
|
IGame::~IGame()
|
||||||
{
|
{
|
||||||
delete gameModule;
|
delete gameModule;
|
||||||
|
|
|
@ -18,7 +18,10 @@ Object::Object(void)
|
||||||
model = new Model();
|
model = new Model();
|
||||||
model = Oyster::Graphics::API::CreateModel(L"bth.obj");
|
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);
|
GameLogic::RefManager::getInstance()->AddMapping(*rigidBody, *this);
|
||||||
|
|
||||||
|
@ -36,7 +39,6 @@ void Object::Render()
|
||||||
{
|
{
|
||||||
this->rigidBody->GetOrientation(model->WorldMatrix);
|
this->rigidBody->GetOrientation(model->WorldMatrix);
|
||||||
Oyster::Graphics::API::RenderScene(model, 1);
|
Oyster::Graphics::API::RenderScene(model, 1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Object::OBJECT_TYPE Object::GetType()
|
Object::OBJECT_TYPE Object::GetType()
|
||||||
|
|
|
@ -18,16 +18,16 @@ namespace GameLogic
|
||||||
{
|
{
|
||||||
class Object
|
class Object
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Object(void);
|
|
||||||
virtual ~Object(void);
|
|
||||||
|
|
||||||
enum OBJECT_TYPE
|
enum OBJECT_TYPE
|
||||||
{
|
{
|
||||||
OBJECT_TYPE_PLAYER,
|
OBJECT_TYPE_PLAYER,
|
||||||
OBJECT_TYPE_BOX,
|
OBJECT_TYPE_BOX,
|
||||||
};
|
};
|
||||||
|
Object(void);
|
||||||
|
virtual ~Object(void);
|
||||||
|
|
||||||
void Render();
|
void Render();
|
||||||
|
|
||||||
OBJECT_TYPE GetType();
|
OBJECT_TYPE GetType();
|
||||||
|
|
|
@ -1,54 +1,53 @@
|
||||||
#include "Player.h"
|
#include "Player.h"
|
||||||
#include "OysterMath.h"
|
#include "OysterMath.h"
|
||||||
|
|
||||||
|
|
||||||
using namespace GameLogic;
|
using namespace GameLogic;
|
||||||
using namespace Oyster::Physics;
|
using namespace Oyster::Physics;
|
||||||
using namespace Utility::DynamicMemory;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Player::Player(void)
|
Player::Player(void)
|
||||||
:Object()
|
:Object()
|
||||||
{
|
{
|
||||||
life = 100;
|
life = 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Player::~Player(void)
|
Player::~Player(void)
|
||||||
{
|
{
|
||||||
delete this->rigidBody;
|
delete this->rigidBody;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::Update(keyInput keyPressed)
|
void Player::Update(keyInput keyPressed)
|
||||||
{
|
{
|
||||||
if(keyPressed != keyInput_none)
|
if(keyPressed != keyInput_none)
|
||||||
{
|
{
|
||||||
Move();
|
Move(keyPressed);
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::Move()
|
void Player::Move(keyInput keyPressed)
|
||||||
{
|
{
|
||||||
//API::Instance().Update();
|
if(keyPressed == keyInput_A)
|
||||||
/*Oyster::Math::Float3 pos = this->rigidBody->GetCenter();
|
{
|
||||||
pos.x += 0.1;
|
Oyster::Math::Float3 pos = this->rigidBody->GetCenter();
|
||||||
rigidBody->SetCenter(pos);*/
|
pos.x -= 0.1;
|
||||||
//API::Instance().SetCenter(rigidBody, pos);
|
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()
|
void Player::Shoot()
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,27 +13,25 @@
|
||||||
|
|
||||||
namespace GameLogic
|
namespace GameLogic
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
class Player : public Object
|
class Player : public Object
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Player(void);
|
Player(void);
|
||||||
~Player(void);
|
~Player(void);
|
||||||
|
|
||||||
|
/********************************************************
|
||||||
|
* Update the position of the rigid body
|
||||||
|
* This will be done with physics later
|
||||||
|
********************************************************/
|
||||||
void Update(keyInput keyPressed);
|
void Update(keyInput keyPressed);
|
||||||
|
|
||||||
void Move();
|
void Move(keyInput keyPressed);
|
||||||
void Shoot();
|
void Shoot();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int life;
|
int life;
|
||||||
Weapon *weapon;
|
Weapon *weapon;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
|
@ -5,6 +5,12 @@
|
||||||
//
|
//
|
||||||
// Copyright (c) Stefan Petersson 2011. All rights reserved.
|
// 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
|
#define NOMINMAX
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#include "Core/Core.h"
|
#include "Core/Core.h"
|
||||||
|
@ -28,8 +34,8 @@
|
||||||
HINSTANCE g_hInst = NULL;
|
HINSTANCE g_hInst = NULL;
|
||||||
HWND g_hWnd = NULL;
|
HWND g_hWnd = NULL;
|
||||||
|
|
||||||
GameLogic::IGame* game;
|
GameLogic::IGame *game;
|
||||||
InputClass* inputObj;
|
InputClass *inputObj;
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
@ -95,8 +101,9 @@ int WINAPI wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdL
|
||||||
__int64 prevTimeStamp = 0;
|
__int64 prevTimeStamp = 0;
|
||||||
QueryPerformanceCounter((LARGE_INTEGER*)&prevTimeStamp);
|
QueryPerformanceCounter((LARGE_INTEGER*)&prevTimeStamp);
|
||||||
|
|
||||||
//debugwindow
|
//Init debug window
|
||||||
//SetStdOutToNewConsole();
|
//SetStdOutToNewConsole();
|
||||||
|
|
||||||
// Main message loop
|
// Main message loop
|
||||||
MSG msg = {0};
|
MSG msg = {0};
|
||||||
while(WM_QUIT != msg.message)
|
while(WM_QUIT != msg.message)
|
||||||
|
@ -171,56 +178,21 @@ HRESULT InitWindow( HINSTANCE hInstance, int nCmdShow )
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
// Create Direct3D device and swap chain
|
// Create Direct3D with Oyster Graphics
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
HRESULT InitDirect3D()
|
HRESULT InitDirect3D()
|
||||||
{
|
{
|
||||||
/*HRESULT hr = S_OK;;
|
if(Oyster::Graphics::API::Init(g_hWnd, false, false, Oyster::Math::Float2( 1024, 768)) != Oyster::Graphics::API::Sucsess)
|
||||||
|
|
||||||
Oyster::Graphics::Core::resolution = Oyster::Math::Float2( 1024, 768 );
|
|
||||||
|
|
||||||
if(Oyster::Graphics::Core::Init::FullInit(g_hWnd,false,false)==Oyster::Graphics::Core::Init::Fail)
|
|
||||||
return E_FAIL;
|
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;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
// Init the input and the game
|
||||||
|
//-------------------------------------------------------------------------------------
|
||||||
HRESULT InitGame()
|
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;
|
inputObj = new InputClass;
|
||||||
if(!inputObj->Initialize(g_hInst, g_hWnd, 1024, 768))
|
if(!inputObj->Initialize(g_hInst, g_hWnd, 1024, 768))
|
||||||
{
|
{
|
||||||
|
@ -231,10 +203,9 @@ HRESULT InitGame()
|
||||||
game->Init();
|
game->Init();
|
||||||
game->StartGame();
|
game->StartGame();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT Update(float deltaTime)
|
HRESULT Update(float deltaTime)
|
||||||
{
|
{
|
||||||
inputObj->Update();
|
inputObj->Update();
|
||||||
|
@ -272,10 +243,10 @@ HRESULT Render(float deltaTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
// test view and projection matrix
|
// test view and projection matrix
|
||||||
Oyster::Math::Float3 dir = Oyster::Math::Float3(0,0,-1);
|
Oyster::Math::Float3 dir = Oyster::Math::Float3(0, 0, -1);
|
||||||
Oyster::Math::Float3 up =Oyster::Math::Float3(0,1,0);
|
Oyster::Math::Float3 up = Oyster::Math::Float3(0, 1, 0);
|
||||||
Oyster::Math::Float3 pos = Oyster::Math::Float3(0, 0, 100);
|
Oyster::Math::Float3 pos = Oyster::Math::Float3(0, 0, 100);
|
||||||
|
|
||||||
Oyster::Math::Float4x4 view =Oyster::Math3D::OrientationMatrix_LookAtDirection(dir, up, pos);
|
Oyster::Math::Float4x4 view =Oyster::Math3D::OrientationMatrix_LookAtDirection(dir, up, pos);
|
||||||
view = view.GetInverse();
|
view = view.GetInverse();
|
||||||
|
|
||||||
|
|
|
@ -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_
|
#ifndef _INPUTCLASS_H_
|
||||||
#define _INPUTCLASS_H_
|
#define _INPUTCLASS_H_
|
||||||
|
|
||||||
|
@ -23,7 +29,6 @@ private:
|
||||||
|
|
||||||
bool ReadKeyboard();
|
bool ReadKeyboard();
|
||||||
bool ReadMouse();
|
bool ReadMouse();
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue