diff --git a/Code/Game/DanBiasGame/DanBiasGame.vcxproj b/Code/Game/DanBiasGame/DanBiasGame.vcxproj index 0b9d07d3..5f9dee44 100644 --- a/Code/Game/DanBiasGame/DanBiasGame.vcxproj +++ b/Code/Game/DanBiasGame/DanBiasGame.vcxproj @@ -71,7 +71,7 @@ $(SolutionDir)..\Bin\DLL\ $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ $(ProjectName)_$(PlatformShortName)D - C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)$(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL; + $(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL;$(LibraryPath) $(SolutionDir)..\External\Include\;$(IncludePath) @@ -79,7 +79,7 @@ $(SolutionDir)..\Bin\DLL\ $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ $(ProjectName)_$(PlatformShortName)D - C:\Program Files %28x86%29\Visual Leak Detector\lib\Win64;$(LibraryPath)$(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL; + $(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL;$(LibraryPath) $(SolutionDir)..\External\Include\;$(IncludePath) @@ -87,7 +87,7 @@ $(SolutionDir)..\Bin\DLL\ $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ $(ProjectName)_$(PlatformShortName) - C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)$(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL; + $(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL;$(LibraryPath) $(SolutionDir)..\External\Include\;$(IncludePath) @@ -95,7 +95,7 @@ $(SolutionDir)..\Bin\DLL\ $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ $(ProjectName)_$(PlatformShortName) - C:\Program Files %28x86%29\Visual Leak Detector\lib\Win64;$(LibraryPath)$(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL; + $(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL;$(LibraryPath) $(SolutionDir)..\External\Include\;$(IncludePath) @@ -106,7 +106,7 @@ Disabled DANBIAS_CLIENT;DANBIAS_GAME_DLL_EXPORT;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) true - $(SolutionDir)GameLogic;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories) + $(SolutionDir)OysterMath;$(SolutionDir)GameLogic;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories) Windows @@ -123,7 +123,7 @@ Disabled DANBIAS_CLIENT;DANBIAS_GAME_DLL_EXPORT;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) true - $(SolutionDir)GameLogic;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories) + $(SolutionDir)OysterMath;$(SolutionDir)GameLogic;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories) Windows @@ -142,7 +142,7 @@ true DANBIAS_CLIENT;DANBIAS_GAME_DLL_EXPORT;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) true - $(SolutionDir)GameLogic;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories) + $(SolutionDir)OysterMath;$(SolutionDir)GameLogic;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories) Windows @@ -163,7 +163,7 @@ true DANBIAS_CLIENT;DANBIAS_GAME_DLL_EXPORT;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) true - $(SolutionDir)GameLogic;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories) + $(SolutionDir)OysterMath;$(SolutionDir)GameLogic;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories) Windows @@ -178,9 +178,15 @@ {7e3990d2-3d94-465c-b58d-64a74b3ecf9b} + + {2ec4dded-8f75-4c86-a10b-e1e8eb29f3ee} + {0ec83e64-230e-48ef-b08c-6ac9651b4f82} + + {f10cbc03-9809-4cba-95d8-327c287b18ee} + {b1195bb9-b3a5-47f0-906c-8dea384d1520} @@ -188,9 +194,15 @@ + + + + + + diff --git a/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp index 09fa36b8..11144244 100644 --- a/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp +++ b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp @@ -1,6 +1,11 @@ #define NOMINMAX #include #include "Include\DanBiasGame.h" +#include "DllInterfaces/GFXAPI.h" +#include "GameClientState/GameClientState.h" +#include "GameClientState\GameState.h" +#include "GameClientState\LobbyState.h" + namespace DanBias { @@ -26,9 +31,11 @@ namespace DanBias } public: + Client::GameClientState* gameClientState; } data; #pragma endregion + DanBiasGamePrivateData* DanBiasGame::m_data = new DanBiasGamePrivateData(); //-------------------------------------------------------------------------------------- // Interface API functions @@ -41,7 +48,7 @@ namespace DanBias if( FAILED( InitDirect3D() ) ) return DanBiasClientReturn_Error; - if( FAILED( InitGame() ) ) + if( FAILED( InitInput() ) ) return DanBiasClientReturn_Error; cntsPerSec = 0; @@ -51,6 +58,10 @@ namespace DanBias prevTimeStamp = 0; QueryPerformanceCounter((LARGE_INTEGER*)&prevTimeStamp); + + // Start in lobby state + m_data->gameClientState = new Client::LobbyState(); + m_data->gameClientState->Init(); return DanBiasClientReturn_Sucess; } @@ -72,8 +83,10 @@ namespace DanBias float dt = (currTimeStamp - prevTimeStamp) * secsPerCnt; //render - Update(dt); - Render(dt); + if(Update(dt) != S_OK) + return DanBiasClientReturn_Error; + if(Render(dt) != S_OK) + return DanBiasClientReturn_Error; prevTimeStamp = currTimeStamp; } @@ -145,9 +158,9 @@ namespace DanBias } //-------------------------------------------------------------------------------------- - // Init the input and the game + // Init the input //------------------------------------------------------------------------------------- - HRESULT DanBiasGame::InitGame() + HRESULT DanBiasGame::InitInput() { inputObj = new InputClass; if(!inputObj->Initialize(g_hInst, g_hWnd, 1024, 768)) @@ -155,14 +168,32 @@ namespace DanBias MessageBox(0, L"Could not initialize the input object.", L"Error", MB_OK); return E_FAIL; } - return S_OK; } HRESULT DanBiasGame::Update(float deltaTime) { inputObj->Update(); + DanBias::Client::GameClientState::ClientState state = DanBias::Client::GameClientState::ClientState_Same; + state = m_data->gameClientState->Update(); + if(state != Client::GameClientState::ClientState_Same) + { + m_data->gameClientState->Release(); + switch (state) + { + case Client::GameClientState::ClientState_Lobby: + m_data->gameClientState = new Client::LobbyState(); + break; + case Client::GameClientState::ClientState_Game: + m_data->gameClientState = new Client::GameState(); + break; + default: + return E_FAIL; + break; + } + m_data->gameClientState->Init(); + } return S_OK; } @@ -174,13 +205,16 @@ namespace DanBias isPressed = 1; } - Oyster::Graphics::API::NewFrame(Oyster::Math3D::Float4x4::null, Oyster::Math3D::Float4x4::null); - + + //Oyster::Graphics::API::NewFrame(Oyster::Math3D::Float4x4::null, Oyster::Math3D::Float4x4::null); + wchar_t title[255]; swprintf(title, sizeof(title), L"| Pressing A: %d | \n", (int)(isPressed)); SetWindowText(g_hWnd, title); - - Oyster::Graphics::API::EndFrame(); + + m_data->gameClientState->Render(); + + //Oyster::Graphics::API::EndFrame(); return S_OK; } diff --git a/Code/Game/DanBiasGame/GameClientState/GameClientState.cpp b/Code/Game/DanBiasGame/GameClientState/GameClientState.cpp new file mode 100644 index 00000000..1fffc85e --- /dev/null +++ b/Code/Game/DanBiasGame/GameClientState/GameClientState.cpp @@ -0,0 +1,12 @@ +#include "GameClientState.h" + +using namespace DanBias::Client; + +GameClientState::GameClientState(void) +{ +} + + +GameClientState::~GameClientState(void) +{ +} diff --git a/Code/Game/DanBiasGame/GameClientState/GameClientState.h b/Code/Game/DanBiasGame/GameClientState/GameClientState.h new file mode 100644 index 00000000..879dbafc --- /dev/null +++ b/Code/Game/DanBiasGame/GameClientState/GameClientState.h @@ -0,0 +1,26 @@ +#pragma once +namespace DanBias +{ +namespace Client +{ + +class GameClientState +{ +public: + enum ClientState + { + ClientState_Lobby, + ClientState_Game, + ClientState_Same, + }; + +public: + GameClientState(void); + virtual ~GameClientState(void); + virtual bool Init() = 0; + virtual ClientState Update() = 0; + virtual bool Render() = 0; + virtual bool Release() = 0; +}; +}; +}; diff --git a/Code/Game/DanBiasGame/GameClientState/GameState.cpp b/Code/Game/DanBiasGame/GameClientState/GameState.cpp new file mode 100644 index 00000000..b6951cd0 --- /dev/null +++ b/Code/Game/DanBiasGame/GameClientState/GameState.cpp @@ -0,0 +1,30 @@ +#include "GameState.h" +#include "DllInterfaces/GFXAPI.h" +using namespace DanBias::Client; +GameState::GameState(void) +{ +} + + +GameState::~GameState(void) +{ +} +bool GameState::Init() +{ + return true; +} +GameClientState::ClientState GameState::Update() +{ + return ClientState_Same; +} +bool GameState::Render() +{ + Oyster::Graphics::API::NewFrame(Oyster::Math3D::Float4x4::null, Oyster::Math3D::Float4x4::null); + + Oyster::Graphics::API::EndFrame(); + return true; +} +bool GameState::Release() +{ + return true; +} \ No newline at end of file diff --git a/Code/Game/DanBiasGame/GameClientState/GameState.h b/Code/Game/DanBiasGame/GameClientState/GameState.h new file mode 100644 index 00000000..45011ba6 --- /dev/null +++ b/Code/Game/DanBiasGame/GameClientState/GameState.h @@ -0,0 +1,18 @@ +#pragma once +#include "GameClientState.h" +namespace DanBias +{ +namespace Client +{ +class GameState : public GameClientState +{ +public: + GameState(void); + ~GameState(void); + bool Init(); + GameClientState::ClientState Update(); + bool Render(); + bool Release(); +}; +}; +}; diff --git a/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp b/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp new file mode 100644 index 00000000..2ccba307 --- /dev/null +++ b/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp @@ -0,0 +1,51 @@ +#include "LobbyState.h" +#include "DllInterfaces/GFXAPI.h" +#include "OysterMath.h" +using namespace DanBias::Client; + +struct myData +{ + Oyster::Math3D::Float4x4 view; + Oyster::Math3D::Float4x4 proj; + Oyster::Graphics::Model::Model *model; +}data; + + +LobbyState::LobbyState(void) +{ + +} + + +LobbyState::~LobbyState(void) +{ +} +bool LobbyState::Init() +{ + data.model = Oyster::Graphics::API::CreateModel(L"crate"); + + 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); + data.view = Oyster::Math3D::ViewMatrix_LookAtDirection(dir, up, pos); + data.proj = Oyster::Math3D::ProjectionMatrix_Orthographic(1024, 768, 1, 10); + return true; +} +GameClientState::ClientState LobbyState::Update() +{ + + //if( startGame) + // return ClientState_Game; + return ClientState_Same; +} +bool LobbyState::Render() +{ + Oyster::Graphics::API::NewFrame(data.view, data.proj); + Oyster::Graphics::API::RenderScene(data.model,1); + Oyster::Graphics::API::EndFrame(); + return true; +} +bool LobbyState::Release() +{ + return true; +} \ No newline at end of file diff --git a/Code/Game/DanBiasGame/GameClientState/LobbyState.h b/Code/Game/DanBiasGame/GameClientState/LobbyState.h new file mode 100644 index 00000000..04e1ca8b --- /dev/null +++ b/Code/Game/DanBiasGame/GameClientState/LobbyState.h @@ -0,0 +1,19 @@ +#pragma once +#include "GameClientState.h" +namespace DanBias +{ + namespace Client + { + struct myData; +class LobbyState : public GameClientState +{ +private: + myData* privData; +public: + LobbyState(void); + ~LobbyState(void); + bool Init(); + ClientState Update(); + bool Render(); + bool Release(); +};};}; diff --git a/Code/Game/DanBiasGame/Include/DanBiasGame.h b/Code/Game/DanBiasGame/Include/DanBiasGame.h index d1adba92..0f9b83eb 100644 --- a/Code/Game/DanBiasGame/Include/DanBiasGame.h +++ b/Code/Game/DanBiasGame/Include/DanBiasGame.h @@ -10,9 +10,10 @@ #define NOMINMAX #include -#include "DllInterfaces/GFXAPI.h" + #include "L_inputClass.h" + namespace DanBias { extern "C" @@ -24,6 +25,8 @@ namespace DanBias DanBiasClientReturn_Sucess, }; + + struct DanBiasGameDesc { //Stuff goes here... @@ -33,7 +36,7 @@ namespace DanBias }; LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); - + class DanBiasGamePrivateData; class DANBIAS_GAME_DLL DanBiasGame { public: @@ -48,7 +51,7 @@ namespace DanBias static HRESULT InitWindow( HINSTANCE hInstance, int nCmdShow); static HRESULT InitDirect3D(); - static HRESULT InitGame(); + static HRESULT InitInput(); static HRESULT Update(float deltaTime); static HRESULT Render(float deltaTime); @@ -60,6 +63,7 @@ namespace DanBias static InputClass* inputObj; static HINSTANCE g_hInst; static HWND g_hWnd; + static DanBiasGamePrivateData* m_data; }; diff --git a/Code/Game/DanBiasLauncher/DanBiasLauncher.vcxproj b/Code/Game/DanBiasLauncher/DanBiasLauncher.vcxproj index 5a4ebeb6..9d4363bb 100644 --- a/Code/Game/DanBiasLauncher/DanBiasLauncher.vcxproj +++ b/Code/Game/DanBiasLauncher/DanBiasLauncher.vcxproj @@ -110,7 +110,7 @@ Windows true - GameLogic_$(PlatformShortName)D.dll;OysterGraphics_$(PlatformShortName)D.dll;DanBiasServer_$(PlatformShortName)D.dll;DanBiasGame_$(PlatformShortName)D.dll;%(DelayLoadDLLs) + DanBiasServer_$(PlatformShortName)D.dll;DanBiasGame_$(PlatformShortName)D.dll;%(DelayLoadDLLs) Input_$(PlatformShortName)D.lib;GameLogic_$(PlatformShortName)D.lib;DanBiasServer_$(PlatformShortName)D.lib;DanBiasGame_$(PlatformShortName)D.lib;%(AdditionalDependencies) @@ -126,7 +126,7 @@ Windows true - GameLogic_$(PlatformShortName)D.dll;OysterGraphics_$(PlatformShortName)D.dll;DanBiasServer_$(PlatformShortName)D.dll;DanBiasGame_$(PlatformShortName)D.dll;%(DelayLoadDLLs) + DanBiasServer_$(PlatformShortName)D.dll;DanBiasGame_$(PlatformShortName)D.dll;%(DelayLoadDLLs) Input_$(PlatformShortName)D.lib;GameLogic_$(PlatformShortName)D.lib;DanBiasServer_$(PlatformShortName)D.lib;DanBiasGame_$(PlatformShortName)D.lib;%(AdditionalDependencies) @@ -146,7 +146,7 @@ true true true - GameLogic_$(PlatformShortName).dll;OysterGraphics_$(PlatformShortName).dll;DanBiasServer_$(PlatformShortName).dll;DanBiasGame_$(PlatformShortName).dll;%(DelayLoadDLLs) + DanBiasServer_$(PlatformShortName).dll;DanBiasGame_$(PlatformShortName).dll;%(DelayLoadDLLs) Input_$(PlatformShortName).lib;GameLogic_$(PlatformShortName).lib;DanBiasServer_$(PlatformShortName).lib;DanBiasGame_$(PlatformShortName).lib;%(AdditionalDependencies) @@ -166,7 +166,7 @@ true true true - GameLogic_$(PlatformShortName).dll;OysterGraphics_$(PlatformShortName).dll;DanBiasServer_$(PlatformShortName).dll;DanBiasGame_$(PlatformShortName).dll;%(DelayLoadDLLs) + DanBiasServer_$(PlatformShortName).dll;DanBiasGame_$(PlatformShortName).dll;%(DelayLoadDLLs) Input_$(PlatformShortName).lib;GameLogic_$(PlatformShortName).lib;DanBiasServer_$(PlatformShortName).lib;DanBiasGame_$(PlatformShortName).lib;%(AdditionalDependencies) diff --git a/Code/Game/DanBiasLauncher/Launcher.cpp b/Code/Game/DanBiasLauncher/Launcher.cpp index 28b89485..0440d973 100644 --- a/Code/Game/DanBiasLauncher/Launcher.cpp +++ b/Code/Game/DanBiasLauncher/Launcher.cpp @@ -4,8 +4,8 @@ #define NOMINMAX #include -#define DANBIAS_SERVER -//#define DANBIAS_CLIENT +//#define DANBIAS_SERVER +#define DANBIAS_CLIENT #if defined(DANBIAS_SERVER)