GameServer - Merged with other half of GameLogic

This commit is contained in:
Dennis Andersen 2014-01-13 12:50:27 +01:00
commit eb9360377d
7 changed files with 430 additions and 36 deletions

View File

@ -1,4 +1,334 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<diagram program="umlet" version="12.2"> <diagram program="umlet" version="12.1">
<zoom_level>10</zoom_level> <zoom_level>10</zoom_level>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>390</x>
<y>120</y>
<w>100</w>
<h>30</h>
</coordinates>
<panel_attributes>/C_Object/
</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>320</x>
<y>0</y>
<w>100</w>
<h>30</h>
</coordinates>
<panel_attributes>C_Player</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>440</x>
<y>0</y>
<w>100</w>
<h>30</h>
</coordinates>
<panel_attributes>C_StaticObj</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>200</x>
<y>0</y>
<w>100</w>
<h>30</h>
</coordinates>
<panel_attributes>C_DynamicObj</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>240</x>
<y>0</y>
<w>200</w>
<h>140</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;-</panel_attributes>
<additional_attributes>30;30;30;120;180;120</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>370</x>
<y>0</y>
<w>50</w>
<h>140</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;-</panel_attributes>
<additional_attributes>30;30;30;120</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>450</x>
<y>0</y>
<w>50</w>
<h>140</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;-</panel_attributes>
<additional_attributes>30;30;30;120</additional_attributes>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>210</x>
<y>220</y>
<w>100</w>
<h>100</h>
</coordinates>
<panel_attributes>GameState
--
C_Object*
GameState
Camera
Client*</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>360</x>
<y>330</y>
<w>160</w>
<h>50</h>
</coordinates>
<panel_attributes>/GameClientState/
Is eighter game or lobby </panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>570</x>
<y>220</y>
<w>100</w>
<h>100</h>
</coordinates>
<panel_attributes>LobbyState
--
C_Object*
Camera
Client*</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>380</x>
<y>440</y>
<w>120</w>
<h>120</h>
</coordinates>
<panel_attributes>DanBiasGame
--
Client
Input
GameClientState
Window</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>400</x>
<y>350</y>
<w>50</w>
<h>110</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes>
<additional_attributes>30;90;30;30</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>230</x>
<y>290</y>
<w>150</w>
<h>80</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;-</panel_attributes>
<additional_attributes>30;30;30;60;130;60</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>490</x>
<y>290</y>
<w>150</w>
<h>80</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;-</panel_attributes>
<additional_attributes>130;30;130;60;30;60</additional_attributes>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>560</x>
<y>0</y>
<w>100</w>
<h>30</h>
</coordinates>
<panel_attributes>C_UiObject</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>410</x>
<y>0</y>
<w>210</w>
<h>140</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;-</panel_attributes>
<additional_attributes>190;30;190;120;30;120</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>410</x>
<y>120</y>
<w>180</w>
<h>120</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;&lt;-</panel_attributes>
<additional_attributes>160;100;30;100;30;30</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>280</x>
<y>120</y>
<w>170</w>
<h>120</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;&lt;-</panel_attributes>
<additional_attributes>30;100;150;100;150;30</additional_attributes>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>620</x>
<y>120</y>
<w>100</w>
<h>30</h>
</coordinates>
<panel_attributes>Light</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>340</x>
<y>640</y>
<w>100</w>
<h>40</h>
</coordinates>
<panel_attributes>NetworkAPI
--</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>230</x>
<y>640</y>
<w>100</w>
<h>40</h>
</coordinates>
<panel_attributes>GraphicsAPI
--
</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>230</x>
<y>530</y>
<w>170</w>
<h>130</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;.</panel_attributes>
<additional_attributes>30;110;30;30;150;30</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>360</x>
<y>530</y>
<w>50</w>
<h>130</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;.</panel_attributes>
<additional_attributes>30;110;30;30</additional_attributes>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>460</x>
<y>640</y>
<w>100</w>
<h>40</h>
</coordinates>
<panel_attributes>Input
--</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>460</x>
<y>530</y>
<w>50</w>
<h>130</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;.</panel_attributes>
<additional_attributes>30;110;30;30</additional_attributes>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>120</x>
<y>520</y>
<w>110</w>
<h>40</h>
</coordinates>
<panel_attributes>DanBiasLancher
--</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>580</x>
<y>640</y>
<w>110</w>
<h>40</h>
</coordinates>
<panel_attributes>WindowManager
--</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>470</x>
<y>530</y>
<w>190</w>
<h>130</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;.</panel_attributes>
<additional_attributes>170;110;170;30;30;30</additional_attributes>
</element>
</diagram> </diagram>

View File

@ -70,6 +70,7 @@ namespace DanBias
Client::GameClientState::NewObj* protocolData = new Client::GameClientState::NewObj; Client::GameClientState::NewObj* protocolData = new Client::GameClientState::NewObj;
protocolData->object_ID = p[1].value.netInt; protocolData->object_ID = p[1].value.netInt;
char k = p[2].value.netChar;
protocolData->path = p[2].value.netCharPtr; protocolData->path = p[2].value.netCharPtr;
for(int i = 0; i< 16; i++) for(int i = 0; i< 16; i++)
{ {
@ -152,6 +153,7 @@ namespace DanBias
DanBiasGamePrivateData* DanBiasGame::m_data = new DanBiasGamePrivateData(); DanBiasGamePrivateData* DanBiasGame::m_data = new DanBiasGamePrivateData();
float DanBiasGame::capFrame = 0;
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Interface API functions // Interface API functions
@ -196,10 +198,16 @@ namespace DanBias
float dt = (float)m_data->timer->getElapsedSeconds(); float dt = (float)m_data->timer->getElapsedSeconds();
m_data->timer->reset(); m_data->timer->reset();
if(Update(dt) != S_OK) capFrame += dt;
return DanBiasClientReturn_Error; if(capFrame > 0.03)
if(Render(dt) != S_OK) {
return DanBiasClientReturn_Error; if(Update(dt) != S_OK)
return DanBiasClientReturn_Error;
if(Render(dt) != S_OK)
return DanBiasClientReturn_Error;
capFrame = 0;
}
} }
return DanBiasClientReturn_Sucess; return DanBiasClientReturn_Sucess;
} }

View File

@ -18,10 +18,16 @@ struct GameState::myData
Oyster::Network::NetworkClient* nwClient; Oyster::Network::NetworkClient* nwClient;
gameStateState state; gameStateState state;
}privData; }privData;
GameState::GameState(void) GameState::GameState(void)
{ {
key_forward = false;
key_backward = false;
key_strafeRight = false;
key_strafeLeft = false;
} }
@ -121,24 +127,53 @@ GameClientState::ClientState GameState::Update(float deltaTime, InputClass* KeyI
if(KeyInput->IsKeyPressed(DIK_W)) if(KeyInput->IsKeyPressed(DIK_W))
{ {
movePlayer.bForward = true;
send = true; if(!key_forward)
{
movePlayer.bForward = true;
send = true;
key_forward = true;
}
} }
else
key_forward = false;
if(KeyInput->IsKeyPressed(DIK_S)) if(KeyInput->IsKeyPressed(DIK_S))
{ {
movePlayer.bBackward = true; if(!key_backward)
send = true; {
movePlayer.bBackward = true;
send = true;
key_backward = true;
}
} }
else
key_backward = false;
if(KeyInput->IsKeyPressed(DIK_A)) if(KeyInput->IsKeyPressed(DIK_A))
{ {
movePlayer.bStrafeLeft = true; if(!key_strafeLeft)
send = true; {
movePlayer.bStrafeLeft = true;
send = true;
key_strafeLeft = true;
}
} }
else
key_strafeLeft = false;
if(KeyInput->IsKeyPressed(DIK_D)) if(KeyInput->IsKeyPressed(DIK_D))
{ {
movePlayer.bStrafeRight = true; if(!key_strafeRight)
send = true; {
movePlayer.bStrafeRight = true;
send = true;
key_strafeRight = true;
}
} }
else
key_strafeRight = false;
if (privData->nwClient->IsConnected() && send) if (privData->nwClient->IsConnected() && send)
{ {

View File

@ -16,7 +16,12 @@ class GameState : public GameClientState
gameStateState_end, gameStateState_end,
}; };
private: private:
bool key_forward;
bool key_backward;
bool key_strafeRight;
bool key_strafeLeft;
struct myData; struct myData;
myData* privData; myData* privData;
public: public:

View File

@ -57,6 +57,8 @@ namespace DanBias
static HRESULT Render(float deltaTime); static HRESULT Render(float deltaTime);
static HRESULT CleanUp(); static HRESULT CleanUp();
static float capFrame;
private: private:
static DanBiasGamePrivateData* m_data; static DanBiasGamePrivateData* m_data;

View File

@ -58,12 +58,7 @@ void Game::GetAllPlayerPos()
Game::PlayerData Game::CreatePlayer() Game::PlayerData Game::CreatePlayer()
{ {
PlayerData data; return PlayerData();
//Yo mammma
data.playerID = GID();
data.teamID = -1;
return data;
} }
void Game::CreateTeam() void Game::CreateTeam()

View File

@ -28,27 +28,46 @@ namespace GameLogic
this->protocol[i].type = Oyster::Network::NetAttributeType_Float; this->protocol[i].type = Oyster::Network::NetAttributeType_Float;
} }
} }
Protocol_CreateObject(float m[16], int id, char *path)
{
this->protocol[protocol_INDEX_ID].value = protocol_Gameplay_CreateObject;
this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Int;
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
for (int i = 2; i <= 17; i++)
{
this->protocol[i].type = Oyster::Network::NetAttributeType_Float;
}
object_ID = id;
this->path = path;
memcpy(&worldMatrix[0], &m[0], sizeof(float)*16);
}
Oyster::Network::CustomNetProtocol* GetProtocol() override Oyster::Network::CustomNetProtocol* GetProtocol() override
{ {
this->protocol[1].value = object_ID; this->protocol[1].value = object_ID;
this->protocol[2].value = path; this->protocol[2].value = path;
this->protocol[3].value = worldMatrix[1]; this->protocol[3].value = worldMatrix[0];
this->protocol[4].value = worldMatrix[2]; this->protocol[4].value = worldMatrix[1];
this->protocol[5].value = worldMatrix[3]; this->protocol[5].value = worldMatrix[2];
this->protocol[6].value = worldMatrix[4]; this->protocol[6].value = worldMatrix[3];
this->protocol[7].value = worldMatrix[5]; this->protocol[7].value = worldMatrix[4];
this->protocol[8].value = worldMatrix[6]; this->protocol[8].value = worldMatrix[5];
this->protocol[9].value = worldMatrix[7]; this->protocol[9].value = worldMatrix[6];
this->protocol[10].value = worldMatrix[8]; this->protocol[10].value = worldMatrix[7];
this->protocol[11].value = worldMatrix[9]; this->protocol[11].value = worldMatrix[8];
this->protocol[12].value = worldMatrix[10]; this->protocol[12].value = worldMatrix[9];
this->protocol[13].value = worldMatrix[11]; this->protocol[13].value = worldMatrix[10];
this->protocol[14].value = worldMatrix[12]; this->protocol[14].value = worldMatrix[11];
this->protocol[15].value = worldMatrix[13]; this->protocol[15].value = worldMatrix[12];
this->protocol[16].value = worldMatrix[14]; this->protocol[16].value = worldMatrix[13];
this->protocol[17].value = worldMatrix[15]; this->protocol[17].value = worldMatrix[14];
this->protocol[18].value = worldMatrix[16]; this->protocol[18].value = worldMatrix[15];
return &protocol; return &protocol;
} }