Merge branch 'GameLogicBranch' of https://github.com/dean11/Danbias into GameLogicBranch

This commit is contained in:
Erik Persson 2013-11-29 09:26:16 +01:00
commit f9a1aaf43c
10 changed files with 87 additions and 99 deletions

View File

@ -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
}

View File

@ -176,8 +176,10 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<ClInclude Include="CollisionManager.h" />
<ClInclude Include="DynamicObject.h" />
<ClInclude Include="Game.h" />
<ClInclude Include="GameMode.h" />
<ClInclude Include="IGame.h" />
<ClInclude Include="Level.h" />
<ClInclude Include="Object.h" />
@ -187,8 +189,10 @@
<ClInclude Include="Weapon.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="CollisionManager.cpp" />
<ClCompile Include="DynamicObject.cpp" />
<ClCompile Include="Game.cpp" />
<ClCompile Include="GameMode.cpp" />
<ClCompile Include="IGame.cpp" />
<ClCompile Include="Level.cpp" />
<ClCompile Include="Object.cpp" />

View File

@ -42,6 +42,12 @@
<ClInclude Include="RefManager.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="GameMode.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="CollisionManager.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Game.cpp">
@ -74,5 +80,11 @@
<ClCompile Include="TestGLMain.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="GameMode.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="CollisionManager.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@ -8,16 +8,14 @@ BOOL WINAPI DllMain(
_In_ LPVOID lpvReserved
)
{
return TRUE;
}
using namespace GameLogic;
IGame::IGame()
{
gameModule = new Game();
}
IGame::~IGame()
{
delete gameModule;

View File

@ -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()

View File

@ -19,14 +19,14 @@ namespace GameLogic
class Object
{
public:
Object(void);
virtual ~Object(void);
enum OBJECT_TYPE
{
OBJECT_TYPE_PLAYER,
OBJECT_TYPE_BOX,
};
Object(void);
virtual ~Object(void);
void Render();

View File

@ -1,31 +1,29 @@
#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();
Move(keyPressed);
}
}
void Player::Move(keyInput keyPressed)
{
if(keyPressed == keyInput_A)
{
Oyster::Math::Float3 pos = this->rigidBody->GetCenter();
@ -38,17 +36,18 @@ void Player::Update(keyInput keyPressed)
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::Move()
{
//API::Instance().Update();
/*Oyster::Math::Float3 pos = this->rigidBody->GetCenter();
pos.x += 0.1;
rigidBody->SetCenter(pos);*/
//API::Instance().SetCenter(rigidBody, pos);
}
void Player::Shoot()
{

View File

@ -13,8 +13,6 @@
namespace GameLogic
{
class Player : public Object
{
@ -22,18 +20,18 @@ namespace GameLogic
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;
};
}
#endif

View File

@ -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 <Windows.h>
#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,8 +243,8 @@ 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 File

@ -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_
@ -24,7 +30,6 @@ private:
bool ReadKeyboard();
bool ReadMouse();
public:
InputClass();