GameLogic - Merge with Erik
This commit is contained in:
commit
33d045de1a
Binary file not shown.
|
@ -71,7 +71,7 @@
|
|||
<OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
|
||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||
<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>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
|
@ -79,24 +79,24 @@
|
|||
<OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
|
||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||
<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>
|
||||
<IncludePath>$(SolutionDir)..\External\Include\;$(IncludePath);C:\Program Files %28x86%29\Visual Leak Detector\include</IncludePath>
|
||||
<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>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
|
||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
||||
<LibraryPath>$(SolutionDir)..\External\Lib\Input;$(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>
|
||||
<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>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
|
||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
||||
<LibraryPath>$(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win64;$(LibraryPath)</LibraryPath>
|
||||
<IncludePath>$(SolutionDir)..\External\Include\;$(IncludePath);C:\Program Files %28x86%29\Visual Leak Detector\include</IncludePath>
|
||||
<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>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
|
@ -111,7 +111,7 @@
|
|||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<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>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
|
@ -123,13 +123,13 @@
|
|||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>DANBIAS_GAME_DLL_EXPORT;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<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>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>GameProtocols_$(PlatformShortName)D.lib;OysterGraphics_$(PlatformShortName)D.lib;Input_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<DelayLoadDLLs>OysterGraphics_$(PlatformShortName)D.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||
<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>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
|
@ -142,15 +142,15 @@
|
|||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>DANBIAS_GAME_DLL_EXPORT;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<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>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>GameProtocols_$(PlatformShortName).lib;OysterGraphics_$(PlatformShortName).lib;Input_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<DelayLoadDLLs>OysterGraphics_x86.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||
<AdditionalDependencies>Misc\Misc_$(PlatformShortName).lib;WindowManager\WindowManager_$(PlatformShortName).lib;OysterGraphics_$(PlatformShortName).lib;Input\Input_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<DelayLoadDLLs>NetworkAPI_$(PlatformShortName).dll;OysterGraphics_$(PlatformShortName).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
|
@ -163,15 +163,15 @@
|
|||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>DANBIAS_GAME_DLL_EXPORT;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<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>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>GameProtocols_$(PlatformShortName).lib;OysterGraphics_$(PlatformShortName).lib;Input_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<DelayLoadDLLs>OysterGraphics_x86.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||
<AdditionalDependencies>Misc\Misc_$(PlatformShortName).lib;WindowManager\WindowManager_$(PlatformShortName).lib;OysterGraphics_$(PlatformShortName).lib;Input\Input_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<DelayLoadDLLs>NetworkAPI_$(PlatformShortName).dll;OysterGraphics_$(PlatformShortName).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
|
|
|
@ -8,16 +8,13 @@
|
|||
#include "PlayerProtocols.h"
|
||||
#include "NetworkClient.h"
|
||||
|
||||
#include "../WindowManager/WindowShell.h"
|
||||
#include "L_inputClass.h"
|
||||
//#include "vld.h"
|
||||
#include "WinTimer.h"
|
||||
#include "vld.h"
|
||||
|
||||
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
|
||||
|
||||
|
@ -29,22 +26,20 @@ namespace DanBias
|
|||
|
||||
void ProtocolRecievedCallback(Oyster::Network::CustomNetProtocol& p) override
|
||||
{
|
||||
|
||||
int pType = p[0].value.netInt;
|
||||
//Client::GameClientState::ProtocolStruct* protocolData;
|
||||
switch (pType)
|
||||
{
|
||||
case protocol_Gamplay_PlayerNavigation:
|
||||
{
|
||||
|
||||
|
||||
Client::GameClientState::KeyInput* protocolData = new Client::GameClientState::KeyInput;
|
||||
for(int i = 0; i< 6; i++)
|
||||
{
|
||||
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;
|
||||
protocolData = NULL;
|
||||
}
|
||||
|
@ -56,14 +51,31 @@ namespace DanBias
|
|||
{
|
||||
protocolData->playerPos[i] = p[i].value.netFloat;
|
||||
}
|
||||
//if(dynamic_cast<Client::GameState*>(gameClientState))
|
||||
gameClientState->Protocol(protocolData);
|
||||
if(dynamic_cast<Client::GameState*>(gameClientState))
|
||||
((Client::GameState*)gameClientState)->Protocol(protocolData);
|
||||
delete protocolData;
|
||||
protocolData = NULL;
|
||||
}
|
||||
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:
|
||||
{
|
||||
|
||||
|
@ -74,8 +86,8 @@ namespace DanBias
|
|||
protocolData->worldPos[i] = p[i+2].value.netFloat;
|
||||
}
|
||||
|
||||
|
||||
gameClientState->Protocol(protocolData);
|
||||
if(dynamic_cast<Client::GameState*>(gameClientState))
|
||||
((Client::GameState*)gameClientState)->Protocol(protocolData);
|
||||
|
||||
delete protocolData;
|
||||
protocolData = NULL;
|
||||
|
@ -102,7 +114,9 @@ namespace DanBias
|
|||
|
||||
public:
|
||||
//Client::GameClientState* gameClientState;
|
||||
WindowShell* window;
|
||||
InputClass* inputObj;
|
||||
Utility::WinTimer* timer;
|
||||
MyRecieverObject* recieverObj;
|
||||
|
||||
} data;
|
||||
|
@ -116,7 +130,8 @@ namespace DanBias
|
|||
//--------------------------------------------------------------------------------------
|
||||
DanBiasClientReturn DanBiasGame::Initiate(DanBiasGameDesc& desc)
|
||||
{
|
||||
if( FAILED( InitWindow( desc.hinst, desc.nCmdShow ) ))
|
||||
|
||||
if(! m_data->window->CreateWin(WindowShell::WINDOW_INIT_DESC()))
|
||||
return DanBiasClientReturn_Error;
|
||||
|
||||
if( FAILED( InitDirect3D() ) )
|
||||
|
@ -125,13 +140,6 @@ namespace DanBias
|
|||
if( FAILED( InitInput() ) )
|
||||
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->nwClient = new Oyster::Network::NetworkClient(m_data->recieverObj, Oyster::Network::NetworkProtocolCallbackType_Object);
|
||||
|
@ -144,37 +152,26 @@ namespace DanBias
|
|||
}
|
||||
// Start in lobby state
|
||||
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;
|
||||
}
|
||||
|
||||
DanBiasClientReturn DanBiasGame::Run()
|
||||
{
|
||||
// Main message loop
|
||||
MSG msg = {0};
|
||||
while(WM_QUIT != msg.message)
|
||||
while(m_data->window->Frame())
|
||||
{
|
||||
if( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE) )
|
||||
{
|
||||
TranslateMessage( &msg );
|
||||
DispatchMessage( &msg );
|
||||
}
|
||||
else
|
||||
{
|
||||
__int64 currTimeStamp = 0;
|
||||
QueryPerformanceCounter((LARGE_INTEGER*)&currTimeStamp);
|
||||
float dt = (currTimeStamp - prevTimeStamp) * secsPerCnt;
|
||||
float dt = m_data->timer->getElapsedSeconds();
|
||||
m_data->timer->reset();
|
||||
|
||||
//render
|
||||
if(Update(dt) != S_OK)
|
||||
return DanBiasClientReturn_Error;
|
||||
if(Render(dt) != S_OK)
|
||||
return DanBiasClientReturn_Error;
|
||||
|
||||
prevTimeStamp = currTimeStamp;
|
||||
}
|
||||
if(Update(dt) != S_OK)
|
||||
return DanBiasClientReturn_Error;
|
||||
if(Render(dt) != S_OK)
|
||||
return DanBiasClientReturn_Error;
|
||||
}
|
||||
return DanBiasClientReturn_Sucess;
|
||||
}
|
||||
|
@ -184,60 +181,12 @@ namespace DanBias
|
|||
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
|
||||
//--------------------------------------------------------------------------------------
|
||||
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 S_OK;
|
||||
}
|
||||
|
@ -248,7 +197,7 @@ namespace DanBias
|
|||
HRESULT DanBiasGame::InitInput()
|
||||
{
|
||||
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);
|
||||
return E_FAIL;
|
||||
|
@ -258,6 +207,7 @@ namespace DanBias
|
|||
|
||||
HRESULT DanBiasGame::Update(float deltaTime)
|
||||
{
|
||||
|
||||
m_data->inputObj->Update();
|
||||
|
||||
DanBias::Client::GameClientState::ClientState state = DanBias::Client::GameClientState::ClientState_Same;
|
||||
|
@ -297,7 +247,7 @@ namespace DanBias
|
|||
|
||||
wchar_t title[255];
|
||||
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();
|
||||
|
||||
|
@ -319,40 +269,4 @@ namespace DanBias
|
|||
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
|
|
@ -22,6 +22,12 @@ public:
|
|||
int object_ID;
|
||||
float worldPos[16];
|
||||
};
|
||||
struct NewObj :public ProtocolStruct
|
||||
{
|
||||
int object_ID;
|
||||
char* path;
|
||||
float worldPos[16];
|
||||
};
|
||||
struct KeyInput :public ProtocolStruct
|
||||
{
|
||||
bool key[6];
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "GameState.h"
|
||||
#include "GameState.h"
|
||||
#include "DllInterfaces/GFXAPI.h"
|
||||
#include "C_obj/C_Player.h"
|
||||
#include "C_obj/C_DynamicObj.h"
|
||||
|
@ -101,7 +101,6 @@ GameClientState::ClientState GameState::Update(float deltaTime, InputClass* KeyI
|
|||
movePlayer.bTurnLeft = false;
|
||||
movePlayer.bTurnRight = false;
|
||||
|
||||
|
||||
if(KeyInput->IsKeyPressed(DIK_W))
|
||||
{
|
||||
movePlayer.bForward = true;
|
||||
|
@ -128,6 +127,15 @@ GameClientState::ClientState GameState::Update(float deltaTime, InputClass* KeyI
|
|||
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
|
||||
//
|
||||
if(KeyInput->IsKeyPressed(DIK_L))
|
||||
|
@ -204,6 +212,25 @@ void GameState::Protocol( ObjPos* pos )
|
|||
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 )
|
||||
{
|
||||
bool key = false;
|
||||
|
|
|
@ -35,6 +35,7 @@ public:
|
|||
void Protocol(PlayerPos* pos);
|
||||
void Protocol(ObjPos* pos);
|
||||
void Protocol(KeyInput* pos);
|
||||
void Protocol( NewObj* pos );
|
||||
void PlayerPosProtocol(PlayerPos* pos);
|
||||
void ObjectPosProtocol(ObjPos* pos);
|
||||
//void Protocol(LightPos pos);
|
||||
|
|
|
@ -18,7 +18,6 @@ namespace DanBias
|
|||
{
|
||||
extern "C"
|
||||
{
|
||||
|
||||
enum DanBiasClientReturn
|
||||
{
|
||||
DanBiasClientReturn_Error,
|
||||
|
@ -34,7 +33,7 @@ namespace DanBias
|
|||
int nCmdShow;
|
||||
|
||||
};
|
||||
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
|
||||
|
||||
class DanBiasGamePrivateData;
|
||||
class DANBIAS_GAME_DLL DanBiasGame
|
||||
{
|
||||
|
@ -48,7 +47,6 @@ namespace DanBias
|
|||
|
||||
private:
|
||||
|
||||
static HRESULT InitWindow( HINSTANCE hInstance, int nCmdShow);
|
||||
static HRESULT InitDirect3D();
|
||||
static HRESULT InitInput();
|
||||
|
||||
|
@ -57,13 +55,8 @@ namespace DanBias
|
|||
static HRESULT CleanUp();
|
||||
|
||||
private:
|
||||
static __int64 cntsPerSec;
|
||||
static __int64 prevTimeStamp;
|
||||
static float secsPerCnt;
|
||||
|
||||
static HINSTANCE g_hInst;
|
||||
static HWND g_hWnd;
|
||||
static DanBiasGamePrivateData* m_data;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@
|
|||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
|
||||
<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 Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
|
@ -96,7 +96,7 @@
|
|||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
||||
<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>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
#include <Windows.h>
|
||||
#include <vld.h>
|
||||
|
||||
//#include "DanBiasServerAPI.h"
|
||||
#include "DanBiasGame.h"
|
||||
#include "DanBiasServerAPI.h"
|
||||
//#include "DanBiasGame.h"
|
||||
|
||||
|
||||
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
|
||||
DanBias::DanBiasGameDesc gameDesc;
|
||||
gameDesc.port = 15151;
|
||||
gameDesc.IP = "193.11.186.101";
|
||||
gameDesc.IP = "193.11.184.196";
|
||||
gameDesc.hinst = hinst;
|
||||
gameDesc.nCmdShow = cmdShow;
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "Object.h"
|
||||
#include "OysterMath.h"
|
||||
#include "CollisionManager.h"
|
||||
#include "GID.h"
|
||||
|
||||
|
||||
using namespace GameLogic;
|
||||
|
@ -18,6 +19,7 @@ Object::Object()
|
|||
|
||||
rigidBody->gameObjectRef = this;
|
||||
|
||||
this->objectID = GID();
|
||||
this->type = OBJECT_TYPE_UNKNOWN;
|
||||
|
||||
}
|
||||
|
@ -34,6 +36,8 @@ Object::Object(void* collisionFunc, OBJECT_TYPE type)
|
|||
|
||||
rigidBody->gameObjectRef = this;
|
||||
|
||||
this->objectID = GID();
|
||||
|
||||
this->type = type;
|
||||
}
|
||||
|
||||
|
@ -48,6 +52,10 @@ OBJECT_TYPE Object::GetType()
|
|||
{
|
||||
return this->type;
|
||||
}
|
||||
int Object::GetID()
|
||||
{
|
||||
return this->objectID;
|
||||
}
|
||||
|
||||
Oyster::Physics::ICustomBody* Object::GetRigidBody()
|
||||
{
|
||||
|
|
|
@ -21,11 +21,13 @@ namespace GameLogic
|
|||
~Object(void);
|
||||
|
||||
OBJECT_TYPE GetType();
|
||||
int GetID();
|
||||
|
||||
Oyster::Physics::ICustomBody* GetRigidBody();
|
||||
|
||||
private:
|
||||
OBJECT_TYPE type;
|
||||
int objectID;
|
||||
protected:
|
||||
Oyster::Physics::ICustomBody *rigidBody;
|
||||
};
|
||||
|
|
|
@ -8,6 +8,69 @@
|
|||
|
||||
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
|
||||
{
|
||||
int object_ID;
|
||||
|
|
|
@ -51,6 +51,34 @@ namespace GameLogic
|
|||
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
|
||||
{
|
||||
|
||||
|
|
|
@ -8,8 +8,11 @@
|
|||
/* THERE CAN ABSOLUTLEY NOT BE TWO DEFINITIONS WITH THE SAME ID!! */
|
||||
|
||||
#define protocol_Gamplay_PlayerNavigation 0
|
||||
#define protocol_Gamplay_PlayerPosition 1
|
||||
#define protocol_Gamplay_ObjectPosition 2
|
||||
#define protocol_Gamplay_PlayerMouseMovement 1
|
||||
#define protocol_Gamplay_PlayerPosition 2
|
||||
#define protocol_Gamplay_CreateObject 3
|
||||
#define protocol_Gamplay_ObjectPosition 4
|
||||
|
||||
|
||||
#define protocol_Lobby_Msg 100
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////
|
||||
// Created 2013 //
|
||||
// Dennis Andersen, Linda Andersson //
|
||||
//////////////////////////////////////////////////////////
|
||||
|
@ -32,7 +32,7 @@ public:
|
|||
{
|
||||
parent = 0;
|
||||
hInstance = NULL;
|
||||
windowName = L"MADAFACKA";
|
||||
windowName = L"おはよう";
|
||||
windowSize.x = 800;
|
||||
windowSize.y = 600;
|
||||
windowPosition.x = 0;
|
||||
|
|
Loading…
Reference in New Issue