diff --git a/Code/Dokumentation/GameClient.uxf b/Code/Dokumentation/GameClient.uxf index 294b3dba..154f0791 100644 --- a/Code/Dokumentation/GameClient.uxf +++ b/Code/Dokumentation/GameClient.uxf @@ -1,4 +1,334 @@ - + 10 + + com.umlet.element.Class + + 390 + 120 + 100 + 30 + + /C_Object/ + + + + + com.umlet.element.Class + + 320 + 0 + 100 + 30 + + C_Player + + + + com.umlet.element.Class + + 440 + 0 + 100 + 30 + + C_StaticObj + + + + com.umlet.element.Class + + 200 + 0 + 100 + 30 + + C_DynamicObj + + + + com.umlet.element.Relation + + 240 + 0 + 200 + 140 + + lt=<<- + 30;30;30;120;180;120 + + + com.umlet.element.Relation + + 370 + 0 + 50 + 140 + + lt=<<- + 30;30;30;120 + + + com.umlet.element.Relation + + 450 + 0 + 50 + 140 + + lt=<<- + 30;30;30;120 + + + com.umlet.element.Class + + 210 + 220 + 100 + 100 + + GameState +-- +C_Object* +GameState +Camera +Client* + + + + com.umlet.element.Class + + 360 + 330 + 160 + 50 + + /GameClientState/ +Is eighter game or lobby + + + + com.umlet.element.Class + + 570 + 220 + 100 + 100 + + LobbyState +-- +C_Object* +Camera +Client* + + + + com.umlet.element.Class + + 380 + 440 + 120 + 120 + + DanBiasGame +-- +Client +Input +GameClientState +Window + + + + com.umlet.element.Relation + + 400 + 350 + 50 + 110 + + lt=<<<<- + 30;90;30;30 + + + com.umlet.element.Relation + + 230 + 290 + 150 + 80 + + lt=<<- + 30;30;30;60;130;60 + + + com.umlet.element.Relation + + 490 + 290 + 150 + 80 + + lt=<<- + 130;30;130;60;30;60 + + + com.umlet.element.Class + + 560 + 0 + 100 + 30 + + C_UiObject + + + + com.umlet.element.Relation + + 410 + 0 + 210 + 140 + + lt=<<- + 190;30;190;120;30;120 + + + com.umlet.element.Relation + + 410 + 120 + 180 + 120 + + lt=<<<- + 160;100;30;100;30;30 + + + com.umlet.element.Relation + + 280 + 120 + 170 + 120 + + lt=<<<- + 30;100;150;100;150;30 + + + com.umlet.element.Class + + 620 + 120 + 100 + 30 + + Light + + + + com.umlet.element.Class + + 340 + 640 + 100 + 40 + + NetworkAPI +-- + + + + com.umlet.element.Class + + 230 + 640 + 100 + 40 + + GraphicsAPI +-- + + + + + com.umlet.element.Relation + + 230 + 530 + 170 + 130 + + lt=<<. + 30;110;30;30;150;30 + + + com.umlet.element.Relation + + 360 + 530 + 50 + 130 + + lt=<<. + 30;110;30;30 + + + com.umlet.element.Class + + 460 + 640 + 100 + 40 + + Input +-- + + + + com.umlet.element.Relation + + 460 + 530 + 50 + 130 + + lt=<<. + 30;110;30;30 + + + com.umlet.element.Class + + 120 + 520 + 110 + 40 + + DanBiasLancher +-- + + + + com.umlet.element.Class + + 580 + 640 + 110 + 40 + + WindowManager +-- + + + + com.umlet.element.Relation + + 470 + 530 + 190 + 130 + + lt=<<. + 170;110;170;30;30;30 + diff --git a/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp index 0554a480..4c0cc060 100644 --- a/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp +++ b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp @@ -70,6 +70,7 @@ namespace DanBias Client::GameClientState::NewObj* protocolData = new Client::GameClientState::NewObj; protocolData->object_ID = p[1].value.netInt; + char k = p[2].value.netChar; protocolData->path = p[2].value.netCharPtr; for(int i = 0; i< 16; i++) { @@ -152,6 +153,7 @@ namespace DanBias DanBiasGamePrivateData* DanBiasGame::m_data = new DanBiasGamePrivateData(); + float DanBiasGame::capFrame = 0; //-------------------------------------------------------------------------------------- // Interface API functions @@ -196,10 +198,16 @@ namespace DanBias float dt = (float)m_data->timer->getElapsedSeconds(); m_data->timer->reset(); - if(Update(dt) != S_OK) - return DanBiasClientReturn_Error; - if(Render(dt) != S_OK) - return DanBiasClientReturn_Error; + capFrame += dt; + if(capFrame > 0.03) + { + if(Update(dt) != S_OK) + return DanBiasClientReturn_Error; + if(Render(dt) != S_OK) + return DanBiasClientReturn_Error; + capFrame = 0; + } + } return DanBiasClientReturn_Sucess; } diff --git a/Code/Game/DanBiasGame/GameClientState/GameState.cpp b/Code/Game/DanBiasGame/GameClientState/GameState.cpp index cc4bbe53..a93a8e91 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/GameState.cpp @@ -18,10 +18,16 @@ struct GameState::myData Oyster::Network::NetworkClient* nwClient; gameStateState state; + + }privData; 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)) { - 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)) { - movePlayer.bBackward = true; - send = true; + if(!key_backward) + { + movePlayer.bBackward = true; + send = true; + key_backward = true; + } } + else + key_backward = false; + if(KeyInput->IsKeyPressed(DIK_A)) { - movePlayer.bStrafeLeft = true; - send = true; + if(!key_strafeLeft) + { + movePlayer.bStrafeLeft = true; + send = true; + key_strafeLeft = true; + } } + else + key_strafeLeft = false; + if(KeyInput->IsKeyPressed(DIK_D)) { - movePlayer.bStrafeRight = true; - send = true; + if(!key_strafeRight) + { + movePlayer.bStrafeRight = true; + send = true; + key_strafeRight = true; + } } + else + key_strafeRight = false; + if (privData->nwClient->IsConnected() && send) { diff --git a/Code/Game/DanBiasGame/GameClientState/GameState.h b/Code/Game/DanBiasGame/GameClientState/GameState.h index 4de73a39..3942afba 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState.h +++ b/Code/Game/DanBiasGame/GameClientState/GameState.h @@ -16,7 +16,12 @@ class GameState : public GameClientState gameStateState_end, }; private: - + + bool key_forward; + bool key_backward; + bool key_strafeRight; + bool key_strafeLeft; + struct myData; myData* privData; public: diff --git a/Code/Game/DanBiasGame/Include/DanBiasGame.h b/Code/Game/DanBiasGame/Include/DanBiasGame.h index 184960e3..15c3a40e 100644 --- a/Code/Game/DanBiasGame/Include/DanBiasGame.h +++ b/Code/Game/DanBiasGame/Include/DanBiasGame.h @@ -57,6 +57,8 @@ namespace DanBias static HRESULT Render(float deltaTime); static HRESULT CleanUp(); + static float capFrame; + private: static DanBiasGamePrivateData* m_data; diff --git a/Code/Game/GameLogic/Game.cpp b/Code/Game/GameLogic/Game.cpp index 3e985cb8..64e3beaa 100644 --- a/Code/Game/GameLogic/Game.cpp +++ b/Code/Game/GameLogic/Game.cpp @@ -58,12 +58,7 @@ void Game::GetAllPlayerPos() Game::PlayerData Game::CreatePlayer() { - PlayerData data; - //Yo mammma - data.playerID = GID(); - data.teamID = -1; - - return data; + return PlayerData(); } void Game::CreateTeam() diff --git a/Code/Game/GameProtocols/ObjectProtocols.h b/Code/Game/GameProtocols/ObjectProtocols.h index 6a1cde90..880b645d 100644 --- a/Code/Game/GameProtocols/ObjectProtocols.h +++ b/Code/Game/GameProtocols/ObjectProtocols.h @@ -28,27 +28,46 @@ namespace GameLogic 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 { 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]; + this->protocol[3].value = worldMatrix[0]; + this->protocol[4].value = worldMatrix[1]; + this->protocol[5].value = worldMatrix[2]; + this->protocol[6].value = worldMatrix[3]; + this->protocol[7].value = worldMatrix[4]; + this->protocol[8].value = worldMatrix[5]; + this->protocol[9].value = worldMatrix[6]; + this->protocol[10].value = worldMatrix[7]; + this->protocol[11].value = worldMatrix[8]; + this->protocol[12].value = worldMatrix[9]; + this->protocol[13].value = worldMatrix[10]; + this->protocol[14].value = worldMatrix[11]; + this->protocol[15].value = worldMatrix[12]; + this->protocol[16].value = worldMatrix[13]; + this->protocol[17].value = worldMatrix[14]; + this->protocol[18].value = worldMatrix[15]; + + + return &protocol; }