GameLogic - Merge with Erik

This commit is contained in:
Dennis Andersen 2013-12-18 13:10:47 +01:00
commit 33d045de1a
15 changed files with 214 additions and 169 deletions

Binary file not shown.

View File

@ -71,7 +71,7 @@
<OutDir>$(SolutionDir)..\Bin\DLL\</OutDir> <OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir> <IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName> <TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
<LibraryPath>$(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath> <LibraryPath>$(SolutionDir)..\External\Lib\;$(SolutionDir)..\Bin\DLL;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
<IncludePath>$(SolutionDir)..\External\Include\;$(SolutionDir)Game\GameProtocols\;$(SolutionDir)Network/NetworkAPI;$(IncludePath);C:\Program Files %28x86%29\Visual Leak Detector\include</IncludePath> <IncludePath>$(SolutionDir)..\External\Include\;$(SolutionDir)Game\GameProtocols\;$(SolutionDir)Network/NetworkAPI;$(IncludePath);C:\Program Files %28x86%29\Visual Leak Detector\include</IncludePath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
@ -79,24 +79,24 @@
<OutDir>$(SolutionDir)..\Bin\DLL\</OutDir> <OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir> <IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName> <TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
<LibraryPath>$(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win64;$(LibraryPath)</LibraryPath> <LibraryPath>$(SolutionDir)..\External\Lib\;$(SolutionDir)..\Bin\DLL;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
<IncludePath>$(SolutionDir)..\External\Include\;$(IncludePath);C:\Program Files %28x86%29\Visual Leak Detector\include</IncludePath> <IncludePath>$(SolutionDir)..\External\Include\;$(SolutionDir)Game\GameProtocols\;$(SolutionDir)Network/NetworkAPI;$(IncludePath);C:\Program Files %28x86%29\Visual Leak Detector\include</IncludePath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental> <LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)..\Bin\DLL\</OutDir> <OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir> <IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName> <TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
<LibraryPath>$(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath> <LibraryPath>$(SolutionDir)..\External\Lib\;$(SolutionDir)..\Bin\DLL;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
<IncludePath>$(SolutionDir)..\External\Include\;$(IncludePath);C:\Program Files %28x86%29\Visual Leak Detector\include</IncludePath> <IncludePath>$(SolutionDir)..\External\Include\;$(SolutionDir)Game\GameProtocols\;$(SolutionDir)Network/NetworkAPI;$(IncludePath);C:\Program Files %28x86%29\Visual Leak Detector\include</IncludePath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental> <LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)..\Bin\DLL\</OutDir> <OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir> <IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName> <TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
<LibraryPath>$(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win64;$(LibraryPath)</LibraryPath> <LibraryPath>$(SolutionDir)..\External\Lib\;$(SolutionDir)..\Bin\DLL;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
<IncludePath>$(SolutionDir)..\External\Include\;$(IncludePath);C:\Program Files %28x86%29\Visual Leak Detector\include</IncludePath> <IncludePath>$(SolutionDir)..\External\Include\;$(SolutionDir)Game\GameProtocols\;$(SolutionDir)Network/NetworkAPI;$(IncludePath);C:\Program Files %28x86%29\Visual Leak Detector\include</IncludePath>
</PropertyGroup> </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile> <ClCompile>
@ -111,7 +111,7 @@
<Link> <Link>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>OysterGraphics_$(PlatformShortName)D.lib;Input_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>Misc\Misc_$(PlatformShortName)D.lib;WindowManager\WindowManager_$(PlatformShortName)D.lib;OysterGraphics_$(PlatformShortName)D.lib;Input\Input_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
<DelayLoadDLLs>NetworkAPI_$(PlatformShortName)D.dll;OysterGraphics_$(PlatformShortName)D.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <DelayLoadDLLs>NetworkAPI_$(PlatformShortName)D.dll;OysterGraphics_$(PlatformShortName)D.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
@ -123,13 +123,13 @@
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<PreprocessorDefinitions>DANBIAS_GAME_DLL_EXPORT;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>DANBIAS_GAME_DLL_EXPORT;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck> <SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(SolutionDir)GameProtocols;$(SolutionDir)OysterMath;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(SolutionDir)OysterMath;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>GameProtocols_$(PlatformShortName)D.lib;OysterGraphics_$(PlatformShortName)D.lib;Input_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>Misc\Misc_$(PlatformShortName)D.lib;WindowManager\WindowManager_$(PlatformShortName)D.lib;OysterGraphics_$(PlatformShortName)D.lib;Input\Input_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
<DelayLoadDLLs>OysterGraphics_$(PlatformShortName)D.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <DelayLoadDLLs>NetworkAPI_$(PlatformShortName)D.dll;OysterGraphics_$(PlatformShortName)D.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@ -142,15 +142,15 @@
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>DANBIAS_GAME_DLL_EXPORT;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>DANBIAS_GAME_DLL_EXPORT;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck> <SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(SolutionDir)GameProtocols;$(SolutionDir)OysterMath;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(SolutionDir)OysterMath;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>GameProtocols_$(PlatformShortName).lib;OysterGraphics_$(PlatformShortName).lib;Input_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>Misc\Misc_$(PlatformShortName).lib;WindowManager\WindowManager_$(PlatformShortName).lib;OysterGraphics_$(PlatformShortName).lib;Input\Input_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
<DelayLoadDLLs>OysterGraphics_x86.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <DelayLoadDLLs>NetworkAPI_$(PlatformShortName).dll;OysterGraphics_$(PlatformShortName).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@ -163,15 +163,15 @@
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>DANBIAS_GAME_DLL_EXPORT;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>DANBIAS_GAME_DLL_EXPORT;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck> <SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(SolutionDir)GameProtocols;$(SolutionDir)OysterMath;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(SolutionDir)OysterMath;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>GameProtocols_$(PlatformShortName).lib;OysterGraphics_$(PlatformShortName).lib;Input_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>Misc\Misc_$(PlatformShortName).lib;WindowManager\WindowManager_$(PlatformShortName).lib;OysterGraphics_$(PlatformShortName).lib;Input\Input_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
<DelayLoadDLLs>OysterGraphics_x86.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <DelayLoadDLLs>NetworkAPI_$(PlatformShortName).dll;OysterGraphics_$(PlatformShortName).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>

View File

@ -8,16 +8,13 @@
#include "PlayerProtocols.h" #include "PlayerProtocols.h"
#include "NetworkClient.h" #include "NetworkClient.h"
#include "../WindowManager/WindowShell.h"
#include "L_inputClass.h" #include "L_inputClass.h"
//#include "vld.h" #include "WinTimer.h"
#include "vld.h"
namespace DanBias namespace DanBias
{ {
__int64 DanBiasGame::cntsPerSec = 0;
__int64 DanBiasGame::prevTimeStamp = 0;
float DanBiasGame::secsPerCnt = 0;
HINSTANCE DanBiasGame::g_hInst = NULL;
HWND DanBiasGame::g_hWnd = NULL;
#pragma region Game Data #pragma region Game Data
@ -29,14 +26,11 @@ namespace DanBias
void ProtocolRecievedCallback(Oyster::Network::CustomNetProtocol& p) override void ProtocolRecievedCallback(Oyster::Network::CustomNetProtocol& p) override
{ {
int pType = p[0].value.netInt; int pType = p[0].value.netInt;
//Client::GameClientState::ProtocolStruct* protocolData;
switch (pType) switch (pType)
{ {
case protocol_Gamplay_PlayerNavigation: case protocol_Gamplay_PlayerNavigation:
{ {
Client::GameClientState::KeyInput* protocolData = new Client::GameClientState::KeyInput; Client::GameClientState::KeyInput* protocolData = new Client::GameClientState::KeyInput;
for(int i = 0; i< 6; i++) for(int i = 0; i< 6; i++)
@ -44,7 +38,8 @@ namespace DanBias
protocolData->key[i] = p[i+1].value.netBool; protocolData->key[i] = p[i+1].value.netBool;
} }
((Client::GameState*)gameClientState)->Protocol(protocolData); if(dynamic_cast<Client::GameState*>(gameClientState))
((Client::GameState*)gameClientState)->Protocol(protocolData);
delete protocolData; delete protocolData;
protocolData = NULL; protocolData = NULL;
} }
@ -56,14 +51,31 @@ namespace DanBias
{ {
protocolData->playerPos[i] = p[i].value.netFloat; protocolData->playerPos[i] = p[i].value.netFloat;
} }
//if(dynamic_cast<Client::GameState*>(gameClientState)) if(dynamic_cast<Client::GameState*>(gameClientState))
gameClientState->Protocol(protocolData); ((Client::GameState*)gameClientState)->Protocol(protocolData);
delete protocolData; delete protocolData;
protocolData = NULL; protocolData = NULL;
} }
break; break;
case protocol_Gamplay_CreateObject:
{
Client::GameClientState::NewObj* protocolData = new Client::GameClientState::NewObj;
protocolData->object_ID = p[1].value.netInt;
protocolData->path = p[2].value.netCharPtr;
for(int i = 0; i< 16; i++)
{
protocolData->worldPos[i] = p[i+3].value.netFloat;
}
if(dynamic_cast<Client::GameState*>(gameClientState))
((Client::GameState*)gameClientState)->Protocol(protocolData);
delete protocolData;
protocolData = NULL;
}
break;
case protocol_Gamplay_ObjectPosition: case protocol_Gamplay_ObjectPosition:
{ {
@ -74,8 +86,8 @@ namespace DanBias
protocolData->worldPos[i] = p[i+2].value.netFloat; protocolData->worldPos[i] = p[i+2].value.netFloat;
} }
if(dynamic_cast<Client::GameState*>(gameClientState))
gameClientState->Protocol(protocolData); ((Client::GameState*)gameClientState)->Protocol(protocolData);
delete protocolData; delete protocolData;
protocolData = NULL; protocolData = NULL;
@ -102,7 +114,9 @@ namespace DanBias
public: public:
//Client::GameClientState* gameClientState; //Client::GameClientState* gameClientState;
WindowShell* window;
InputClass* inputObj; InputClass* inputObj;
Utility::WinTimer* timer;
MyRecieverObject* recieverObj; MyRecieverObject* recieverObj;
} data; } data;
@ -116,7 +130,8 @@ namespace DanBias
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
DanBiasClientReturn DanBiasGame::Initiate(DanBiasGameDesc& desc) DanBiasClientReturn DanBiasGame::Initiate(DanBiasGameDesc& desc)
{ {
if( FAILED( InitWindow( desc.hinst, desc.nCmdShow ) ))
if(! m_data->window->CreateWin(WindowShell::WINDOW_INIT_DESC()))
return DanBiasClientReturn_Error; return DanBiasClientReturn_Error;
if( FAILED( InitDirect3D() ) ) if( FAILED( InitDirect3D() ) )
@ -125,13 +140,6 @@ namespace DanBias
if( FAILED( InitInput() ) ) if( FAILED( InitInput() ) )
return DanBiasClientReturn_Error; return DanBiasClientReturn_Error;
cntsPerSec = 0;
QueryPerformanceFrequency((LARGE_INTEGER*)&cntsPerSec);
secsPerCnt = 1.0f / (float)cntsPerSec;
prevTimeStamp = 0;
QueryPerformanceCounter((LARGE_INTEGER*)&prevTimeStamp);
m_data->recieverObj = new MyRecieverObject; m_data->recieverObj = new MyRecieverObject;
m_data->recieverObj->nwClient = new Oyster::Network::NetworkClient(m_data->recieverObj, Oyster::Network::NetworkProtocolCallbackType_Object); m_data->recieverObj->nwClient = new Oyster::Network::NetworkClient(m_data->recieverObj, Oyster::Network::NetworkProtocolCallbackType_Object);
@ -144,37 +152,26 @@ namespace DanBias
} }
// Start in lobby state // Start in lobby state
m_data->recieverObj->gameClientState = new Client::LobbyState(); m_data->recieverObj->gameClientState = new Client::LobbyState();
m_data->recieverObj->gameClientState->Init(m_data->recieverObj->nwClient); if(!m_data->recieverObj->gameClientState->Init(m_data->recieverObj->nwClient))
return DanBiasClientReturn_Error;
m_data->timer = new Utility::WinTimer();
m_data->timer->reset();
return DanBiasClientReturn_Sucess; return DanBiasClientReturn_Sucess;
} }
DanBiasClientReturn DanBiasGame::Run() DanBiasClientReturn DanBiasGame::Run()
{ {
// Main message loop // Main message loop
MSG msg = {0}; while(m_data->window->Frame())
while(WM_QUIT != msg.message)
{ {
if( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE) ) float dt = m_data->timer->getElapsedSeconds();
{ m_data->timer->reset();
TranslateMessage( &msg );
DispatchMessage( &msg );
}
else
{
__int64 currTimeStamp = 0;
QueryPerformanceCounter((LARGE_INTEGER*)&currTimeStamp);
float dt = (currTimeStamp - prevTimeStamp) * secsPerCnt;
//render if(Update(dt) != S_OK)
if(Update(dt) != S_OK) return DanBiasClientReturn_Error;
return DanBiasClientReturn_Error; if(Render(dt) != S_OK)
if(Render(dt) != S_OK) return DanBiasClientReturn_Error;
return DanBiasClientReturn_Error;
prevTimeStamp = currTimeStamp;
}
} }
return DanBiasClientReturn_Sucess; return DanBiasClientReturn_Sucess;
} }
@ -184,60 +181,12 @@ namespace DanBias
CleanUp(); CleanUp();
} }
//--------------------------------------------------------------------------------------
// Register class and create window
//--------------------------------------------------------------------------------------
HRESULT DanBiasGame::InitWindow( HINSTANCE hInstance, int nCmdShow )
{
// Register class
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = 0;
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = NULL;
wcex.lpszClassName = L"BTH_D3D_Template";
wcex.hIconSm = 0;
if( !RegisterClassEx(&wcex) )
return E_FAIL;
// Adjust and create window
g_hInst = hInstance;
RECT rc = { 0, 0, 1024, 768 };
AdjustWindowRect( &rc, WS_OVERLAPPEDWINDOW, FALSE );
if(!(g_hWnd = CreateWindow(
L"BTH_D3D_Template",
L"BTH - Direct3D 11.0 Template",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
rc.right - rc.left,
rc.bottom - rc.top,
NULL,
NULL,
hInstance,
NULL)))
{
return E_FAIL;
}
ShowWindow( g_hWnd, nCmdShow );
return S_OK;
}
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Create Direct3D with Oyster Graphics // Create Direct3D with Oyster Graphics
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
HRESULT DanBiasGame::InitDirect3D() HRESULT DanBiasGame::InitDirect3D()
{ {
if(Oyster::Graphics::API::Init(g_hWnd, false, false, Oyster::Math::Float2( 1024, 768)) != Oyster::Graphics::API::Sucsess) if(Oyster::Graphics::API::Init(m_data->window->GetHWND(), false, false, Oyster::Math::Float2( 1024, 768)) != Oyster::Graphics::API::Sucsess)
return E_FAIL; return E_FAIL;
return S_OK; return S_OK;
} }
@ -245,10 +194,10 @@ namespace DanBias
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Init the input // Init the input
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
HRESULT DanBiasGame::InitInput() HRESULT DanBiasGame::InitInput()
{ {
m_data->inputObj = new InputClass; m_data->inputObj = new InputClass;
if(!m_data->inputObj->Initialize(g_hInst, g_hWnd, 1024, 768)) if(!m_data->inputObj->Initialize(m_data->window->GetHINSTANCE(), m_data->window->GetHWND(), m_data->window->GetHeight(), m_data->window->GetWidth()))
{ {
MessageBox(0, L"Could not initialize the input object.", L"Error", MB_OK); MessageBox(0, L"Could not initialize the input object.", L"Error", MB_OK);
return E_FAIL; return E_FAIL;
@ -258,6 +207,7 @@ namespace DanBias
HRESULT DanBiasGame::Update(float deltaTime) HRESULT DanBiasGame::Update(float deltaTime)
{ {
m_data->inputObj->Update(); m_data->inputObj->Update();
DanBias::Client::GameClientState::ClientState state = DanBias::Client::GameClientState::ClientState_Same; DanBias::Client::GameClientState::ClientState state = DanBias::Client::GameClientState::ClientState_Same;
@ -297,7 +247,7 @@ namespace DanBias
wchar_t title[255]; wchar_t title[255];
swprintf(title, sizeof(title), L"| Pressing A: %d | \n", (int)(isPressed)); swprintf(title, sizeof(title), L"| Pressing A: %d | \n", (int)(isPressed));
SetWindowText(g_hWnd, title); SetWindowText(m_data->window->GetHWND(), title);
m_data->recieverObj->gameClientState->Render(); m_data->recieverObj->gameClientState->Render();
@ -319,40 +269,4 @@ namespace DanBias
return S_OK; return S_OK;
} }
//--------------------------------------------------------------------------------------
// Called every time the application receives a message
//--------------------------------------------------------------------------------------
LRESULT CALLBACK WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
PAINTSTRUCT ps;
HDC hdc;
switch (message)
{
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
case WM_KEYDOWN:
switch(wParam)
{
case VK_ESCAPE:
PostQuitMessage(0);
break;
}
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
} //End namespace DanBias } //End namespace DanBias

View File

@ -22,6 +22,12 @@ public:
int object_ID; int object_ID;
float worldPos[16]; float worldPos[16];
}; };
struct NewObj :public ProtocolStruct
{
int object_ID;
char* path;
float worldPos[16];
};
struct KeyInput :public ProtocolStruct struct KeyInput :public ProtocolStruct
{ {
bool key[6]; bool key[6];

View File

@ -1,4 +1,4 @@
#include "GameState.h" #include "GameState.h"
#include "DllInterfaces/GFXAPI.h" #include "DllInterfaces/GFXAPI.h"
#include "C_obj/C_Player.h" #include "C_obj/C_Player.h"
#include "C_obj/C_DynamicObj.h" #include "C_obj/C_DynamicObj.h"
@ -101,7 +101,6 @@ GameClientState::ClientState GameState::Update(float deltaTime, InputClass* KeyI
movePlayer.bTurnLeft = false; movePlayer.bTurnLeft = false;
movePlayer.bTurnRight = false; movePlayer.bTurnRight = false;
if(KeyInput->IsKeyPressed(DIK_W)) if(KeyInput->IsKeyPressed(DIK_W))
{ {
movePlayer.bForward = true; movePlayer.bForward = true;
@ -127,6 +126,15 @@ GameClientState::ClientState GameState::Update(float deltaTime, InputClass* KeyI
{ {
privData->nwClient->Send(movePlayer); privData->nwClient->Send(movePlayer);
} }
//send delta mouse movement
if (KeyInput->IsMousePressed())
{
GameLogic::Protocol_PlayerMouse deltaMouseMove;
deltaMouseMove.dxMouse = KeyInput->GetYaw();
deltaMouseMove.dyMouse = KeyInput->GetPitch();
//privData->nwClient->Send(deltaMouseMove);
}
// send event data // send event data
// //
@ -204,6 +212,25 @@ void GameState::Protocol( ObjPos* pos )
privData->object[pos->object_ID]->setPos(world); privData->object[pos->object_ID]->setPos(world);
} }
void GameState::Protocol( NewObj* pos )
{
Oyster::Math::Float4x4 world;
for(int i = 0; i<16; i++)
{
world[i] = pos->worldPos[i];
}
ModelInitData modelData;
modelData.world = world;
modelData.visible = true;
const char* path = pos->path;
modelData.modelPath = std::wstring(path, path + strlen(path));
// load models
privData->object[pos->object_ID] = new C_Player();
privData->object[pos->object_ID]->Init(modelData);
}
void GameState::Protocol( KeyInput* pos ) void GameState::Protocol( KeyInput* pos )
{ {
bool key = false; bool key = false;

View File

@ -35,6 +35,7 @@ public:
void Protocol(PlayerPos* pos); void Protocol(PlayerPos* pos);
void Protocol(ObjPos* pos); void Protocol(ObjPos* pos);
void Protocol(KeyInput* pos); void Protocol(KeyInput* pos);
void Protocol( NewObj* pos );
void PlayerPosProtocol(PlayerPos* pos); void PlayerPosProtocol(PlayerPos* pos);
void ObjectPosProtocol(ObjPos* pos); void ObjectPosProtocol(ObjPos* pos);
//void Protocol(LightPos pos); //void Protocol(LightPos pos);

View File

@ -18,7 +18,6 @@ namespace DanBias
{ {
extern "C" extern "C"
{ {
enum DanBiasClientReturn enum DanBiasClientReturn
{ {
DanBiasClientReturn_Error, DanBiasClientReturn_Error,
@ -34,7 +33,7 @@ namespace DanBias
int nCmdShow; int nCmdShow;
}; };
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
class DanBiasGamePrivateData; class DanBiasGamePrivateData;
class DANBIAS_GAME_DLL DanBiasGame class DANBIAS_GAME_DLL DanBiasGame
{ {
@ -48,7 +47,6 @@ namespace DanBias
private: private:
static HRESULT InitWindow( HINSTANCE hInstance, int nCmdShow);
static HRESULT InitDirect3D(); static HRESULT InitDirect3D();
static HRESULT InitInput(); static HRESULT InitInput();
@ -57,13 +55,8 @@ namespace DanBias
static HRESULT CleanUp(); static HRESULT CleanUp();
private: private:
static __int64 cntsPerSec;
static __int64 prevTimeStamp;
static float secsPerCnt;
static HINSTANCE g_hInst;
static HWND g_hWnd;
static DanBiasGamePrivateData* m_data; static DanBiasGamePrivateData* m_data;
}; };

View File

@ -80,7 +80,7 @@
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir> <IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName> <TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
<IncludePath>$(SolutionDir)..\External\Include\;C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath)</IncludePath> <IncludePath>$(SolutionDir)..\External\Include\;C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath)</IncludePath>
<LibraryPath>$(OutDir)..\DLL\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win64;$(LibraryPath)</LibraryPath> <LibraryPath>$(OutDir)..\DLL\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental> <LinkIncremental>false</LinkIncremental>
@ -96,7 +96,7 @@
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir> <IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName> <TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
<IncludePath>$(SolutionDir)..\External\Include\;C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath)</IncludePath> <IncludePath>$(SolutionDir)..\External\Include\;C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath)</IncludePath>
<LibraryPath>$(OutDir)..\DLL\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win64;$(LibraryPath)</LibraryPath> <LibraryPath>$(OutDir)..\DLL\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
</PropertyGroup> </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile> <ClCompile>

View File

@ -5,8 +5,8 @@
#include <Windows.h> #include <Windows.h>
#include <vld.h> #include <vld.h>
//#include "DanBiasServerAPI.h" #include "DanBiasServerAPI.h"
#include "DanBiasGame.h" //#include "DanBiasGame.h"
int WINAPI WinMain( HINSTANCE hinst, HINSTANCE prevInst, PSTR cmdLine, int cmdShow) int WINAPI WinMain( HINSTANCE hinst, HINSTANCE prevInst, PSTR cmdLine, int cmdShow)
@ -29,7 +29,7 @@ int WINAPI WinMain( HINSTANCE hinst, HINSTANCE prevInst, PSTR cmdLine, int cmdSh
// Game client starter code goes here // Game client starter code goes here
DanBias::DanBiasGameDesc gameDesc; DanBias::DanBiasGameDesc gameDesc;
gameDesc.port = 15151; gameDesc.port = 15151;
gameDesc.IP = "193.11.186.101"; gameDesc.IP = "193.11.184.196";
gameDesc.hinst = hinst; gameDesc.hinst = hinst;
gameDesc.nCmdShow = cmdShow; gameDesc.nCmdShow = cmdShow;

View File

@ -1,6 +1,7 @@
#include "Object.h" #include "Object.h"
#include "OysterMath.h" #include "OysterMath.h"
#include "CollisionManager.h" #include "CollisionManager.h"
#include "GID.h"
using namespace GameLogic; using namespace GameLogic;
@ -18,6 +19,7 @@ Object::Object()
rigidBody->gameObjectRef = this; rigidBody->gameObjectRef = this;
this->objectID = GID();
this->type = OBJECT_TYPE_UNKNOWN; this->type = OBJECT_TYPE_UNKNOWN;
} }
@ -34,6 +36,8 @@ Object::Object(void* collisionFunc, OBJECT_TYPE type)
rigidBody->gameObjectRef = this; rigidBody->gameObjectRef = this;
this->objectID = GID();
this->type = type; this->type = type;
} }
@ -48,6 +52,10 @@ OBJECT_TYPE Object::GetType()
{ {
return this->type; return this->type;
} }
int Object::GetID()
{
return this->objectID;
}
Oyster::Physics::ICustomBody* Object::GetRigidBody() Oyster::Physics::ICustomBody* Object::GetRigidBody()
{ {

View File

@ -21,11 +21,13 @@ namespace GameLogic
~Object(void); ~Object(void);
OBJECT_TYPE GetType(); OBJECT_TYPE GetType();
int GetID();
Oyster::Physics::ICustomBody* GetRigidBody(); Oyster::Physics::ICustomBody* GetRigidBody();
private: private:
OBJECT_TYPE type; OBJECT_TYPE type;
int objectID;
protected: protected:
Oyster::Physics::ICustomBody *rigidBody; Oyster::Physics::ICustomBody *rigidBody;
}; };

View File

@ -8,6 +8,69 @@
namespace GameLogic namespace GameLogic
{ {
struct Protocol_CreateObject :public Oyster::Network::CustomProtocolObject
{
int object_ID;
char path[255];
float worldMatrix[16];
Protocol_CreateObject()
{
this->protocol[0].value = protocol_Gamplay_CreateObject;
this->protocol[0].type = Oyster::Network::NetAttributeType_Int;
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
this->protocol[2].type = Oyster::Network::NetAttributeType_CharArray;
this->protocol[3].type = Oyster::Network::NetAttributeType_Float;
this->protocol[4].type = Oyster::Network::NetAttributeType_Float;
this->protocol[5].type = Oyster::Network::NetAttributeType_Float;
this->protocol[6].type = Oyster::Network::NetAttributeType_Float;
this->protocol[7].type = Oyster::Network::NetAttributeType_Float;
this->protocol[8].type = Oyster::Network::NetAttributeType_Float;
this->protocol[9].type = Oyster::Network::NetAttributeType_Float;
this->protocol[10].type = Oyster::Network::NetAttributeType_Float;
this->protocol[11].type = Oyster::Network::NetAttributeType_Float;
this->protocol[12].type = Oyster::Network::NetAttributeType_Float;
this->protocol[13].type = Oyster::Network::NetAttributeType_Float;
this->protocol[14].type = Oyster::Network::NetAttributeType_Float;
this->protocol[15].type = Oyster::Network::NetAttributeType_Float;
this->protocol[16].type = Oyster::Network::NetAttributeType_Float;
this->protocol[17].type = Oyster::Network::NetAttributeType_Float;
this->protocol[18].type = Oyster::Network::NetAttributeType_Float;
}
Oyster::Network::CustomNetProtocol* GetProtocol() override
{
this->protocol[1].value = object_ID;
this->protocol[2].value = path;
this->protocol[3].value = worldMatrix[1];
this->protocol[4].value = worldMatrix[2];
this->protocol[5].value = worldMatrix[3];
this->protocol[6].value = worldMatrix[4];
this->protocol[7].value = worldMatrix[5];
this->protocol[8].value = worldMatrix[6];
this->protocol[9].value = worldMatrix[7];
this->protocol[10].value = worldMatrix[8];
this->protocol[11].value = worldMatrix[9];
this->protocol[12].value = worldMatrix[10];
this->protocol[13].value = worldMatrix[11];
this->protocol[14].value = worldMatrix[12];
this->protocol[15].value = worldMatrix[13];
this->protocol[16].value = worldMatrix[14];
this->protocol[17].value = worldMatrix[15];
this->protocol[18].value = worldMatrix[16];
return &protocol;
}
private:
Oyster::Network::CustomNetProtocol protocol;
};
struct Protocol_ObjectPosition :public Oyster::Network::CustomProtocolObject struct Protocol_ObjectPosition :public Oyster::Network::CustomProtocolObject
{ {
int object_ID; int object_ID;

View File

@ -51,6 +51,34 @@ namespace GameLogic
Oyster::Network::CustomNetProtocol protocol; Oyster::Network::CustomNetProtocol protocol;
}; };
struct Protocol_PlayerMouse :public Oyster::Network::CustomProtocolObject
{
float dxMouse;
float dyMouse;
Protocol_PlayerMouse()
{
this->protocol[0].value = protocol_Gamplay_PlayerMouseMovement;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[1].type = Oyster::Network::NetAttributeType_Float;
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
}
Oyster::Network::CustomNetProtocol* GetProtocol() override
{
this->protocol[1].value = dxMouse;
this->protocol[2].value = dyMouse;
return &protocol;
}
private:
Oyster::Network::CustomNetProtocol protocol;
};
struct Protocol_PlayerPosition :public Oyster::Network::CustomProtocolObject struct Protocol_PlayerPosition :public Oyster::Network::CustomProtocolObject
{ {

View File

@ -8,8 +8,11 @@
/* THERE CAN ABSOLUTLEY NOT BE TWO DEFINITIONS WITH THE SAME ID!! */ /* THERE CAN ABSOLUTLEY NOT BE TWO DEFINITIONS WITH THE SAME ID!! */
#define protocol_Gamplay_PlayerNavigation 0 #define protocol_Gamplay_PlayerNavigation 0
#define protocol_Gamplay_PlayerPosition 1 #define protocol_Gamplay_PlayerMouseMovement 1
#define protocol_Gamplay_ObjectPosition 2 #define protocol_Gamplay_PlayerPosition 2
#define protocol_Gamplay_CreateObject 3
#define protocol_Gamplay_ObjectPosition 4
#define protocol_Lobby_Msg 100 #define protocol_Lobby_Msg 100

View File

@ -1,4 +1,4 @@
////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////
// Created 2013 // // Created 2013 //
// Dennis Andersen, Linda Andersson // // Dennis Andersen, Linda Andersson //
////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////
@ -32,7 +32,7 @@ public:
{ {
parent = 0; parent = 0;
hInstance = NULL; hInstance = NULL;
windowName = L"MADAFACKA"; windowName = L"おはよう";
windowSize.x = 800; windowSize.x = 800;
windowSize.y = 600; windowSize.y = 600;
windowPosition.x = 0; windowPosition.x = 0;