GL - added C_obj files, client obj in game state to send input

This commit is contained in:
Linda Andersson 2013-12-16 09:45:12 +01:00
parent 34d79d1207
commit fa1473455f
20 changed files with 355 additions and 60 deletions

Binary file not shown.

Binary file not shown.

View File

@ -196,6 +196,7 @@ Global
{2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 {2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|Mixed Platforms.Build.0 = Debug|Win32 {2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|Win32.ActiveCfg = Debug|Win32 {2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|Win32.ActiveCfg = Debug|Win32
{2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|Win32.Build.0 = Debug|Win32
{2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|x64.ActiveCfg = Debug|x64 {2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|x64.ActiveCfg = Debug|x64
{2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|x64.Build.0 = Debug|x64 {2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|x64.Build.0 = Debug|x64
{2A1BC987-AF42-4500-802D-89CD32FC1309}.Release|Mixed Platforms.ActiveCfg = Release|Win32 {2A1BC987-AF42-4500-802D-89CD32FC1309}.Release|Mixed Platforms.ActiveCfg = Release|Win32

View File

@ -192,26 +192,26 @@
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="GameClientState\Obj\C_UIobject.cpp" /> <ClCompile Include="GameClientState\C_obj\C_DynamicObj.cpp" />
<ClCompile Include="GameClientState\C_obj\C_Player.cpp" />
<ClCompile Include="GameClientState\C_obj\C_StaticObj.cpp" />
<ClCompile Include="GameClientState\C_obj\C_UIobject.cpp" />
<ClCompile Include="DanBiasGame_Impl.cpp" /> <ClCompile Include="DanBiasGame_Impl.cpp" />
<ClCompile Include="DLLMain.cpp" /> <ClCompile Include="DLLMain.cpp" />
<ClCompile Include="GameClientState\Obj\C_DynamicObj.cpp" />
<ClCompile Include="GameClientState\GameClientState.cpp" /> <ClCompile Include="GameClientState\GameClientState.cpp" />
<ClCompile Include="GameClientState\GameState.cpp" /> <ClCompile Include="GameClientState\GameState.cpp" />
<ClCompile Include="GameClientState\LobbyState.cpp" /> <ClCompile Include="GameClientState\LobbyState.cpp" />
<ClCompile Include="GameClientState\Obj\C_Player.cpp" />
<ClCompile Include="GameClientState\Obj\C_StaticObj.cpp" />
<ClCompile Include="GameClientState\C_Object.cpp" /> <ClCompile Include="GameClientState\C_Object.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="GameClientState\Obj\C_UIobject.h" /> <ClInclude Include="GameClientState\C_obj\C_DynamicObj.h" />
<ClInclude Include="GameClientState\Obj\C_DynamicObj.h" /> <ClInclude Include="GameClientState\C_obj\C_Player.h" />
<ClInclude Include="GameClientState\C_obj\C_StaticObj.h" />
<ClInclude Include="GameClientState\C_obj\C_UIobject.h" />
<ClInclude Include="GameClientState\GameClientState.h" /> <ClInclude Include="GameClientState\GameClientState.h" />
<ClInclude Include="GameClientState\GameState.h" /> <ClInclude Include="GameClientState\GameState.h" />
<ClInclude Include="Include\DanBiasGame.h" /> <ClInclude Include="Include\DanBiasGame.h" />
<ClInclude Include="GameClientState\LobbyState.h" /> <ClInclude Include="GameClientState\LobbyState.h" />
<ClInclude Include="GameClientState\Obj\C_Player.h" />
<ClInclude Include="GameClientState\Obj\C_StaticObj.h" />
<ClInclude Include="GameClientState\C_Object.h" /> <ClInclude Include="GameClientState\C_Object.h" />
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

View File

@ -112,12 +112,12 @@ namespace DanBias
prevTimeStamp = 0; prevTimeStamp = 0;
QueryPerformanceCounter((LARGE_INTEGER*)&prevTimeStamp); QueryPerformanceCounter((LARGE_INTEGER*)&prevTimeStamp);
// Start in lobby state
m_data->gameClientState = new Client::LobbyState();
m_data->gameClientState->Init();
m_data->r = new MyRecieverObject; m_data->r = new MyRecieverObject;
m_data->r->nwClient = new Oyster::Network::NetworkClient(); m_data->r->nwClient = new Oyster::Network::NetworkClient();
// Start in lobby state
m_data->gameClientState = new Client::LobbyState();
m_data->gameClientState->Init(m_data->r->nwClient);
return DanBiasClientReturn_Sucess; return DanBiasClientReturn_Sucess;
} }
@ -253,7 +253,7 @@ namespace DanBias
return E_FAIL; return E_FAIL;
break; break;
} }
m_data->gameClientState->Init(); // send game client m_data->gameClientState->Init(m_data->r->nwClient); // send game client
} }
return S_OK; return S_OK;

View File

@ -0,0 +1,42 @@
#include "C_DynamicObj.h"
#include "DllInterfaces/GFXAPI.h"
using namespace DanBias::Client;
struct C_DynamicObj::myData
{
myData(){}
Oyster::Graphics::Model::Model *model;
// light
// sound
// effect
}privData;
C_DynamicObj::C_DynamicObj(void)
{
}
C_DynamicObj::~C_DynamicObj(void)
{
}
void C_DynamicObj::Init(ModelInitData modelInit)
{
// load models
privData = new myData();
privData->model = Oyster::Graphics::API::CreateModel(modelInit.modelPath);
privData->model->WorldMatrix = modelInit.world;
privData->model->Visible = modelInit.visible;
}
void C_DynamicObj::setPos()
{
}
void C_DynamicObj::Render()
{
Oyster::Graphics::API::RenderModel(*(privData->model));
}
void C_DynamicObj::Release()
{
Oyster::Graphics::API::DeleteModel(privData->model);
delete privData;
}

View File

@ -0,0 +1,22 @@
#ifndef DANBIAS_CLIENT_CDYNAMICOBJECT_H
#define DANBIAS_CLIENT_CDYNAMICOBJECT_H
#include "../C_Object.h"
namespace DanBias
{
namespace Client
{
class C_DynamicObj : public C_Object
{
private:
struct myData;
myData* privData;
public:
C_DynamicObj(void);
virtual ~C_DynamicObj(void);
void Init(ModelInitData modelInit);
void setPos();
void Render();
void Release();
};};};
#endif

View File

@ -0,0 +1,46 @@
#include "C_Player.h"
#include "DllInterfaces/GFXAPI.h"
using namespace DanBias::Client;
struct C_Player::myData
{
myData(){}
Oyster::Math3D::Float4x4 view;
Oyster::Math3D::Float4x4 proj;
Oyster::Graphics::Model::Model *model;
}privData;
C_Player::C_Player(void)
{
}
C_Player::~C_Player(void)
{
}
void C_Player::Init(ModelInitData modelInit)
{
// load models
privData = new myData();
privData->model = Oyster::Graphics::API::CreateModel(modelInit.modelPath);
privData->model->WorldMatrix = modelInit.world;
privData->model->Visible = modelInit.visible;
}
void C_Player::setPos()
{
}
void C_Player::Render()
{
Oyster::Graphics::API::RenderModel(*(privData->model));
}
void C_Player::Release()
{
Oyster::Graphics::API::DeleteModel(privData->model);
delete privData;
}

View File

@ -0,0 +1,25 @@
#ifndef DANBIAS_CLIENT_CPLAYER_H
#define DANBIAS_CLIENT_CPLAYER_H
#include "../C_Object.h"
namespace DanBias
{
namespace Client
{
class C_Player : public C_Object
{
private:
struct myData;
myData* privData;
//Oyster::Graphics:: LIght
public:
C_Player(void);
~C_Player(void);
void Init(ModelInitData modelInit);
void setPos();
void Render();
void Release();
};};};
#endif

View File

@ -0,0 +1,45 @@
#include "C_StaticObj.h"
#include "DllInterfaces/GFXAPI.h"
using namespace DanBias::Client;
struct C_StaticObj::myData
{
myData(){}
Oyster::Graphics::Model::Model *model;
// light
// sound
// effect
}privData;
C_StaticObj::C_StaticObj(void)
{
}
C_StaticObj::~C_StaticObj(void)
{
}
void C_StaticObj::Init(ModelInitData modelInit)
{
// load models
privData = new myData();
privData->model = Oyster::Graphics::API::CreateModel(modelInit.modelPath);
privData->model->WorldMatrix = modelInit.world;
privData->model->Visible = modelInit.visible;
}
void C_StaticObj::setPos()
{
}
void C_StaticObj::Render()
{
Oyster::Graphics::API::RenderModel(*(privData->model));
}
void C_StaticObj::Release()
{
Oyster::Graphics::API::DeleteModel(privData->model);
delete privData;
}

View File

@ -0,0 +1,22 @@
#ifndef DANBIAS_CLIENT_CSTATICOBJECT_H
#define DANBIAS_CLIENT_CSTATICOBJECT_H
#include "../C_Object.h"
namespace DanBias
{
namespace Client
{
class C_StaticObj : public C_Object
{
private:
struct myData;
myData* privData;
public:
C_StaticObj(void);
virtual ~C_StaticObj(void);
void Init(ModelInitData modelInit);
void setPos();
void Render();
void Release();
};};};
#endif

View File

@ -0,0 +1,43 @@
#include "C_UIobject.h"
#include "DllInterfaces/GFXAPI.h"
using namespace DanBias::Client;
struct C_UIobject::myData
{
myData(){}
Oyster::Math3D::Float4x4 view;
Oyster::Math3D::Float4x4 proj;
Oyster::Graphics::Model::Model *model;
}privData;
C_UIobject::C_UIobject(void)
{
}
C_UIobject::~C_UIobject(void)
{
}
void C_UIobject::Init(ModelInitData modelInit)
{
// load models
privData = new myData();
privData->model = Oyster::Graphics::API::CreateModel(modelInit.modelPath);
privData->model->WorldMatrix = modelInit.world;
privData->model->Visible = modelInit.visible;
}
void C_UIobject::setPos()
{
}
void C_UIobject::Render()
{
Oyster::Graphics::API::RenderModel(*(privData->model));
}
void C_UIobject::Release()
{
Oyster::Graphics::API::DeleteModel(privData->model);
delete privData;
}

View File

@ -0,0 +1,22 @@
#ifndef DANBIAS_CLIENT_CUIOBJECT_H
#define DANBIAS_CLIENT_CUIOBJECT_H
#include "../C_Object.h"
namespace DanBias
{
namespace Client
{
class C_UIobject : public C_Object
{
private:
struct myData;
myData* privData;
public:
C_UIobject(void);
virtual ~C_UIobject(void);
void Init(ModelInitData modelInit);
void setPos();
void Render();
void Release();
};};};
#endif

View File

@ -3,6 +3,7 @@
#define NOMINMAX #define NOMINMAX
#include "L_inputClass.h" #include "L_inputClass.h"
#include "NetworkClient.h"
namespace DanBias namespace DanBias
{ {
@ -42,7 +43,7 @@ public:
public: public:
GameClientState(void); GameClientState(void);
virtual ~GameClientState(void); virtual ~GameClientState(void);
virtual bool Init() = 0; virtual bool Init(Oyster::Network::NetworkClient* nwClient) = 0;
virtual ClientState Update(float deltaTime, InputClass* KeyInput) = 0; virtual ClientState Update(float deltaTime, InputClass* KeyInput) = 0;
virtual bool Render() = 0; virtual bool Render() = 0;
virtual bool Release() = 0; virtual bool Release() = 0;

View File

@ -1,7 +1,7 @@
#include "GameState.h" #include "GameState.h"
#include "DllInterfaces/GFXAPI.h" #include "DllInterfaces/GFXAPI.h"
#include "Obj/C_Player.h" #include "C_obj/C_Player.h"
#include "Obj/C_DynamicObj.h" #include "C_obj/C_DynamicObj.h"
#include "NetworkClient.h" #include "NetworkClient.h"
#include "PlayerProtocols.h" #include "PlayerProtocols.h"
@ -28,11 +28,12 @@ GameState::~GameState(void)
{ {
} }
bool GameState::Init() bool GameState::Init(Oyster::Network::NetworkClient* nwClient)
{ {
// load models // load models
privData = new myData(); privData = new myData();
privData->state = gameStateState_loading; privData->state = gameStateState_loading;
privData->nwClient = nwClient;
privData->state = LoadGame(); privData->state = LoadGame();
return true; return true;
} }
@ -93,8 +94,33 @@ GameClientState::ClientState GameState::Update(float deltaTime, InputClass* KeyI
// Client.send(obj); // Client.send(obj);
{ {
GameLogic::Protocol_PlayerMovement movePlayer; GameLogic::Protocol_PlayerMovement movePlayer;
movePlayer.bForward = false;
movePlayer.bBackward = false;
movePlayer.bStrafeLeft = false;
movePlayer.bStrafeRight = false;
movePlayer.bTurnLeft = false;
movePlayer.bTurnRight = false;
//privData->nwClient->Send(movePlayer);
if(KeyInput->IsKeyPressed(DIK_W))
{
movePlayer.bForward = true;
}
if(KeyInput->IsKeyPressed(DIK_S))
{
movePlayer.bBackward = true;
}
if(KeyInput->IsKeyPressed(DIK_A))
{
movePlayer.bStrafeLeft = true;
}
if(KeyInput->IsKeyPressed(DIK_D))
{
movePlayer.bStrafeRight = true;
}
privData->nwClient->Send(movePlayer);
if(KeyInput->IsKeyPressed(DIK_L)) if(KeyInput->IsKeyPressed(DIK_L))
privData->state = GameState::gameStateState_end; privData->state = GameState::gameStateState_end;

View File

@ -22,7 +22,7 @@ private:
public: public:
GameState(void); GameState(void);
~GameState(void); ~GameState(void);
bool Init(); bool Init(Oyster::Network::NetworkClient* nwClient);
GameClientState::ClientState Update(float deltaTime, InputClass* KeyInput) override; GameClientState::ClientState Update(float deltaTime, InputClass* KeyInput) override;
bool LoadModels(std::wstring mapFile) ; bool LoadModels(std::wstring mapFile) ;
bool InitCamera(Oyster::Math::Float3 startPos) ; bool InitCamera(Oyster::Math::Float3 startPos) ;

View File

@ -1,9 +1,9 @@
#include "LobbyState.h" #include "LobbyState.h"
#include "DllInterfaces/GFXAPI.h" #include "DllInterfaces/GFXAPI.h"
#include "OysterMath.h" #include "OysterMath.h"
#include "Obj/C_Player.h" #include "C_obj/C_Player.h"
#include "Obj/C_StaticObj.h" #include "C_obj/C_StaticObj.h"
#include "Obj/C_DynamicObj.h" #include "C_obj/C_DynamicObj.h"
using namespace DanBias::Client; using namespace DanBias::Client;
@ -28,7 +28,7 @@ LobbyState::~LobbyState(void)
} }
bool LobbyState::Init() bool LobbyState::Init(Oyster::Network::NetworkClient* nwClient)
{ {
privData = new myData(); privData = new myData();

View File

@ -17,7 +17,7 @@ private:
public: public:
LobbyState(void); LobbyState(void);
~LobbyState(void); ~LobbyState(void);
bool Init(); bool Init(Oyster::Network::NetworkClient* nwClient);
bool LoadModels(std::wstring file); bool LoadModels(std::wstring file);
bool InitCamera(Oyster::Math::Float3 startPos); bool InitCamera(Oyster::Math::Float3 startPos);
ClientState Update(float deltaTime, InputClass* KeyInput); ClientState Update(float deltaTime, InputClass* KeyInput);

View File

@ -1,7 +1,7 @@
#ifndef DANBIASGAME_DANBIASGAME_H #ifndef DANBIASGAME_DANBIASGAME_H
#define DANBIASGAME_DANBIASGAME_H #define DANBIASGAME_DANBIASGAME_H
#define DANBIAS_CLIENT_L #define DANBIAS_CLIENT
#if defined (DANBIAS_GAME_DLL_EXPORT) #if defined (DANBIAS_GAME_DLL_EXPORT)
#define DANBIAS_GAME_DLL __declspec(dllexport) #define DANBIAS_GAME_DLL __declspec(dllexport)

View File

@ -6,8 +6,8 @@
#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)
@ -22,7 +22,7 @@ int WINAPI WinMain( HINSTANCE hinst, HINSTANCE prevInst, PSTR cmdLine, int cmdSh
DanBias::DanBiasServerAPI::Run(); DanBias::DanBiasServerAPI::Run();
DanBias::DanBiasServerAPI::Release(); DanBias::DanBiasServerAPI::Release();
} }
#elif defined(DANBIAS_CLIENT_L) #elif defined(DANBIAS_CLIENT)
if(SetDllDirectory(L"..\\DLL") == FALSE) if(SetDllDirectory(L"..\\DLL") == FALSE)
{ {
return cmdShow; return cmdShow;