From 4a07586076459bc107ce54b53c8812d9fdd1abf3 Mon Sep 17 00:00:00 2001 From: Erik Persson Date: Thu, 9 Jan 2014 12:43:32 +0100 Subject: [PATCH 1/6] state --- Code/DanBiasGame/DanBiasGame.vcxproj.user | 22 ++++++++++++++++++++++ Code/Game/GameLogic/Object.h | 1 + Code/Game/GameLogic/Player.cpp | Bin 3037 -> 3103 bytes Code/GameLogic/GameLogic.vcxproj.user | 22 ++++++++++++++++++++++ 4 files changed, 45 insertions(+) create mode 100644 Code/DanBiasGame/DanBiasGame.vcxproj.user create mode 100644 Code/GameLogic/GameLogic.vcxproj.user diff --git a/Code/DanBiasGame/DanBiasGame.vcxproj.user b/Code/DanBiasGame/DanBiasGame.vcxproj.user new file mode 100644 index 00000000..1371945a --- /dev/null +++ b/Code/DanBiasGame/DanBiasGame.vcxproj.user @@ -0,0 +1,22 @@ + + + + true + + + $(SolutionDir)..\Bin\Executable\Tester + WindowsLocalDebugger + + + $(OutDir) + WindowsLocalDebugger + + + $(OutDir) + WindowsLocalDebugger + + + $(OutDir) + WindowsLocalDebugger + + \ No newline at end of file diff --git a/Code/Game/GameLogic/Object.h b/Code/Game/GameLogic/Object.h index a73dc154..5442424f 100644 --- a/Code/Game/GameLogic/Object.h +++ b/Code/Game/GameLogic/Object.h @@ -36,6 +36,7 @@ namespace GameLogic int objectID; protected: Oyster::Physics::ICustomBody *rigidBody; + Oyster::Physics::ICustomBody::State *state; }; } diff --git a/Code/Game/GameLogic/Player.cpp b/Code/Game/GameLogic/Player.cpp index ecf60dd310744c606c1634c2f19cc31d79702227..c9c356a152677295faf23f618cf3520f0f99d897 100644 GIT binary patch literal 3103 kcmeIu0Sy2E0K%a6Pwi$7h(KY$fB^#r3>YwAz<_}d3=AIt0RR91 literal 3037 zcmd5;QE%EX5Pl}V!rG+COwdy8jcS!r2rOMF5oJSrLT+NfYltJqfY8+b_MPLzP10=Y zx@ww~huCM|eg5wA`QEZPh;|`GZ~TZHsW{oZvEG`w=`od5Oo-f6=LbBBSju=jAu(Ck zcP%JMc&v60^!S+Pb zA(6!TVYNy_+_qXU(>i2<(MJ^11JWpP`y34LMQlaEa@Omq2}#M;9m2SKriMv&_8STA zVb1sLZ_aFaGq>jsge{Gh?$C1p8Mx#8ZpZ|zE^sTB`u$PFiTr@iI=xO$g}#Ty4-HV+ z3SkWwuxH>~A&n@+*Ru-Mz1j}gSuBx)4|D2QV~2r0A$o6il%b;1nP6=bN|YZ0%+~$( zsECEL8M-r06t(^7?ROeTT+cdildUoH9W=eXat8C|{F@KVl?F=Hp0hC9m-ABqg{79V8GTInp5lPVDM&`=Y%=}oOq}aEdbb7Jmc}x3bb8vz zMz9kCmVBiV512dxK*825yyW4rdoiYRrbZr%DG|jQr7o+L9+(U^_%VjcXFyU~$6>@& z09%fxvxPky_95FXg@44wfrwD6wsk8gxl<9I=j_rRe6D!AB*C3>m%hxO=ZxkCnMYUh zWo~Bf_|u~wU~%(8M^|4aeun32w@s>8;G%#Yp2)$_sdRUGYWr@#?}9)`98laov6Cb^ z!kU2E5}Raq%wLxF0ce5>-0o=MbuWsm|6Uan5WxM@xFzCWBXai-Lg)PIutSal!P68a zf`_V>f>JkVrA3DJaH+XKBo5&!u8CxOiq?YcmH4$yk=A%uRN=$jDp6y-^_q(g2P*vcUl1E zjgy@&g++4o6Vknat@v?8R*x%}YNp=tLyQ|mk(qoBZ&Y4p>-X)3$~=WeIi1obP)32L z@>&;@$)CN_kItU=R@V!Nt}?H3f1BvSy$*Bw?&Xq8$HO3Up{9w9Tjdjmx@*~<||n3=sfE`8+R4$U0set cvV~ULgFX-|XJIzX4r}767PtE`H^Jro31M2q{{R30 diff --git a/Code/GameLogic/GameLogic.vcxproj.user b/Code/GameLogic/GameLogic.vcxproj.user new file mode 100644 index 00000000..75ed2a95 --- /dev/null +++ b/Code/GameLogic/GameLogic.vcxproj.user @@ -0,0 +1,22 @@ + + + + true + + + $(SolutionDir)..\Bin\Executable\Tester + WindowsLocalDebugger + + + $(SolutionDir)..\Bin\Executable\Tester + WindowsLocalDebugger + + + $(SolutionDir)..\Bin\Executable\Tester + WindowsLocalDebugger + + + $(SolutionDir)..\Bin\Executable\Tester + WindowsLocalDebugger + + \ No newline at end of file From 48b9189a03a649b00b1cf6f4f37395e4334db752 Mon Sep 17 00:00:00 2001 From: Erik Persson Date: Thu, 9 Jan 2014 12:51:17 +0100 Subject: [PATCH 2/6] Revert "state" This reverts commit 4a07586076459bc107ce54b53c8812d9fdd1abf3. --- Code/DanBiasGame/DanBiasGame.vcxproj.user | 22 ---------------------- Code/Game/GameLogic/Object.h | 1 - Code/Game/GameLogic/Player.cpp | Bin 3103 -> 3037 bytes Code/GameLogic/GameLogic.vcxproj.user | 22 ---------------------- 4 files changed, 45 deletions(-) delete mode 100644 Code/DanBiasGame/DanBiasGame.vcxproj.user delete mode 100644 Code/GameLogic/GameLogic.vcxproj.user diff --git a/Code/DanBiasGame/DanBiasGame.vcxproj.user b/Code/DanBiasGame/DanBiasGame.vcxproj.user deleted file mode 100644 index 1371945a..00000000 --- a/Code/DanBiasGame/DanBiasGame.vcxproj.user +++ /dev/null @@ -1,22 +0,0 @@ - - - - true - - - $(SolutionDir)..\Bin\Executable\Tester - WindowsLocalDebugger - - - $(OutDir) - WindowsLocalDebugger - - - $(OutDir) - WindowsLocalDebugger - - - $(OutDir) - WindowsLocalDebugger - - \ No newline at end of file diff --git a/Code/Game/GameLogic/Object.h b/Code/Game/GameLogic/Object.h index 5442424f..a73dc154 100644 --- a/Code/Game/GameLogic/Object.h +++ b/Code/Game/GameLogic/Object.h @@ -36,7 +36,6 @@ namespace GameLogic int objectID; protected: Oyster::Physics::ICustomBody *rigidBody; - Oyster::Physics::ICustomBody::State *state; }; } diff --git a/Code/Game/GameLogic/Player.cpp b/Code/Game/GameLogic/Player.cpp index c9c356a152677295faf23f618cf3520f0f99d897..ecf60dd310744c606c1634c2f19cc31d79702227 100644 GIT binary patch literal 3037 zcmd5;QE%EX5Pl}V!rG+COwdy8jcS!r2rOMF5oJSrLT+NfYltJqfY8+b_MPLzP10=Y zx@ww~huCM|eg5wA`QEZPh;|`GZ~TZHsW{oZvEG`w=`od5Oo-f6=LbBBSju=jAu(Ck zcP%JMc&v60^!S+Pb zA(6!TVYNy_+_qXU(>i2<(MJ^11JWpP`y34LMQlaEa@Omq2}#M;9m2SKriMv&_8STA zVb1sLZ_aFaGq>jsge{Gh?$C1p8Mx#8ZpZ|zE^sTB`u$PFiTr@iI=xO$g}#Ty4-HV+ z3SkWwuxH>~A&n@+*Ru-Mz1j}gSuBx)4|D2QV~2r0A$o6il%b;1nP6=bN|YZ0%+~$( zsECEL8M-r06t(^7?ROeTT+cdildUoH9W=eXat8C|{F@KVl?F=Hp0hC9m-ABqg{79V8GTInp5lPVDM&`=Y%=}oOq}aEdbb7Jmc}x3bb8vz zMz9kCmVBiV512dxK*825yyW4rdoiYRrbZr%DG|jQr7o+L9+(U^_%VjcXFyU~$6>@& z09%fxvxPky_95FXg@44wfrwD6wsk8gxl<9I=j_rRe6D!AB*C3>m%hxO=ZxkCnMYUh zWo~Bf_|u~wU~%(8M^|4aeun32w@s>8;G%#Yp2)$_sdRUGYWr@#?}9)`98laov6Cb^ z!kU2E5}Raq%wLxF0ce5>-0o=MbuWsm|6Uan5WxM@xFzCWBXai-Lg)PIutSal!P68a zf`_V>f>JkVrA3DJaH+XKBo5&!u8CxOiq?YcmH4$yk=A%uRN=$jDp6y-^_q(g2P*vcUl1E zjgy@&g++4o6Vknat@v?8R*x%}YNp=tLyQ|mk(qoBZ&Y4p>-X)3$~=WeIi1obP)32L z@>&;@$)CN_kItU=R@V!Nt}?H3f1BvSy$*Bw?&Xq8$HO3Up{9w9Tjdjmx@*~<||n3=sfE`8+R4$U0set cvV~ULgFX-|XJIzX4r}767PtE`H^Jro31M2q{{R30 literal 3103 kcmeIu0Sy2E0K%a6Pwi$7h(KY$fB^#r3>YwAz<_}d3=AIt0RR91 diff --git a/Code/GameLogic/GameLogic.vcxproj.user b/Code/GameLogic/GameLogic.vcxproj.user deleted file mode 100644 index 75ed2a95..00000000 --- a/Code/GameLogic/GameLogic.vcxproj.user +++ /dev/null @@ -1,22 +0,0 @@ - - - - true - - - $(SolutionDir)..\Bin\Executable\Tester - WindowsLocalDebugger - - - $(SolutionDir)..\Bin\Executable\Tester - WindowsLocalDebugger - - - $(SolutionDir)..\Bin\Executable\Tester - WindowsLocalDebugger - - - $(SolutionDir)..\Bin\Executable\Tester - WindowsLocalDebugger - - \ No newline at end of file From 52ba5602d5c0f281a8f8b66f674f9b0e01ca5e26 Mon Sep 17 00:00:00 2001 From: Erik Persson Date: Thu, 9 Jan 2014 13:06:18 +0100 Subject: [PATCH 3/6] GameLogic - player now using some of the new phys api --- Code/Game/GameLogic/Object.h | 3 +++ Code/Game/GameLogic/Player.cpp | 20 +++++++++----------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Code/Game/GameLogic/Object.h b/Code/Game/GameLogic/Object.h index a73dc154..c199eb58 100644 --- a/Code/Game/GameLogic/Object.h +++ b/Code/Game/GameLogic/Object.h @@ -15,6 +15,7 @@ namespace Oyster namespace Physics { class ICustomBody; + class State; } } namespace GameLogic @@ -36,6 +37,8 @@ namespace GameLogic int objectID; protected: Oyster::Physics::ICustomBody *rigidBody; + Oyster::Physics::ICustomBody::State *state; + }; } diff --git a/Code/Game/GameLogic/Player.cpp b/Code/Game/GameLogic/Player.cpp index ecf60dd3..a9e5b1d0 100644 --- a/Code/Game/GameLogic/Player.cpp +++ b/Code/Game/GameLogic/Player.cpp @@ -16,7 +16,7 @@ struct Player::PrivateData teamID = -1; playerState = PLAYER_STATE::PLAYER_STATE_IDLE; - lookDir = Oyster::Math::Float3(1,0,0); + lookDir = Oyster::Math::Float4(1,0,0); } ~PrivateData() @@ -31,7 +31,7 @@ struct Player::PrivateData int teamID; Weapon *weapon; PLAYER_STATE playerState; - Oyster::Math::Float3 lookDir; + Oyster::Math::Float4 lookDir; }myData; @@ -49,8 +49,6 @@ Player::~Player(void) void Player::Move(const PLAYER_MOVEMENT &movement) { - //Oyster::Math::Float3 currentVelocity = rigidBody->GetRigidLinearVelocity(); - switch(movement) { case PLAYER_MOVEMENT::PLAYER_MOVEMENT_FORWARD: @@ -77,23 +75,23 @@ void Player::Move(const PLAYER_MOVEMENT &movement) void Player::MoveForward() { - //API::Instance().ApplyForceAt(rigidBody,rigidBody->GetCenter(),myData->lookDir * 100); + state->ApplyLinearImpulse(myData->lookDir * 100); } void Player::MoveBackwards() { - //API::Instance().ApplyForceAt(rigidBody,rigidBody->GetCenter(),-myData->lookDir * 100); + state->ApplyLinearImpulse(-myData->lookDir * 100); } void Player::MoveRight() { //Do cross product with forward vector and negative gravity vector - //Oyster::Math::Float3 r = (-rigidBody->GetGravityNormal()).Cross(myData->lookDir); - //API::Instance().ApplyForceAt(rigidBody, rigidBody->GetCenter(), r * 100); + Oyster::Math::Float4 r = (-rigidBody->GetGravityNormal()).Cross((Oyster::Math::Float3)myData->lookDir); + state->ApplyLinearImpulse(r * 100); } void Player::MoveLeft() { //Do cross product with forward vector and negative gravity vector - //Oyster::Math::Float3 r = -(-rigidBody->GetGravityNormal()).Cross(myData->lookDir); - //API::Instance().ApplyForceAt(rigidBody, rigidBody->GetCenter(), r * 100); + Oyster::Math::Float4 r = -(-rigidBody->GetGravityNormal()).Cross((Oyster::Math::Float3)myData->lookDir); + state->ApplyLinearImpulse(-r * 100); } void Player::UseWeapon(const WEAPON_FIRE &fireInput) @@ -106,7 +104,7 @@ void Player::Respawn(Oyster::Math::Float3 spawnPoint) //API::Instance().SetCenter(rigidBody,spawnPoint); myData->life = 100; myData->playerState = PLAYER_STATE::PLAYER_STATE_IDLE; - myData->lookDir = Oyster::Math::Float3(1,0,0); + myData->lookDir = Oyster::Math::Float4(1,0,0); } void Player::Jump() From 586031aa948fdf7199d91873d7d4a991f118f6bd Mon Sep 17 00:00:00 2001 From: Erik Persson Date: Fri, 10 Jan 2014 10:08:42 +0100 Subject: [PATCH 4/6] GameLogic - making sure GameLogic uses the new physics api --- Code/Game/GameLogic/Level.cpp | 2 +- Code/Game/GameLogic/Object.cpp | 4 ++++ Code/Game/GameLogic/Object.h | 11 ++--------- Code/Game/GameLogic/Player.cpp | 17 ++++++++--------- Code/Game/GameLogic/Weapon.h | 2 -- 5 files changed, 15 insertions(+), 21 deletions(-) diff --git a/Code/Game/GameLogic/Level.cpp b/Code/Game/GameLogic/Level.cpp index f0d1b935..9f4416aa 100644 --- a/Code/Game/GameLogic/Level.cpp +++ b/Code/Game/GameLogic/Level.cpp @@ -10,7 +10,7 @@ using namespace GameLogic; struct Level::PrivateData { - PrivateData() + PrivateData() { } diff --git a/Code/Game/GameLogic/Object.cpp b/Code/Game/GameLogic/Object.cpp index 9e516907..e824c1d5 100644 --- a/Code/Game/GameLogic/Object.cpp +++ b/Code/Game/GameLogic/Object.cpp @@ -23,6 +23,8 @@ Object::Object() this->objectID = GID(); this->type = OBJECT_TYPE::OBJECT_TYPE_UNKNOWN; + + rigidBody->GetState(state); } Object::Object(void* collisionFunc, OBJECT_TYPE type) @@ -40,6 +42,8 @@ Object::Object(void* collisionFunc, OBJECT_TYPE type) this->objectID = GID(); this->type = type; + + rigidBody->GetState(state); } diff --git a/Code/Game/GameLogic/Object.h b/Code/Game/GameLogic/Object.h index c199eb58..6d6437f1 100644 --- a/Code/Game/GameLogic/Object.h +++ b/Code/Game/GameLogic/Object.h @@ -9,15 +9,8 @@ #include "GameLogicStates.h" #include "GameLogicDef.h" +#include -namespace Oyster -{ - namespace Physics - { - class ICustomBody; - class State; - } -} namespace GameLogic { class DANBIAS_GAMELOGIC_DLL Object @@ -37,7 +30,7 @@ namespace GameLogic int objectID; protected: Oyster::Physics::ICustomBody *rigidBody; - Oyster::Physics::ICustomBody::State *state; + Oyster::Physics::ICustomBody::State state; }; diff --git a/Code/Game/GameLogic/Player.cpp b/Code/Game/GameLogic/Player.cpp index a9e5b1d0..626e565f 100644 --- a/Code/Game/GameLogic/Player.cpp +++ b/Code/Game/GameLogic/Player.cpp @@ -16,7 +16,7 @@ struct Player::PrivateData teamID = -1; playerState = PLAYER_STATE::PLAYER_STATE_IDLE; - lookDir = Oyster::Math::Float4(1,0,0); + lookDir = Oyster::Math::Float4(1,0,0,0); } ~PrivateData() @@ -75,23 +75,23 @@ void Player::Move(const PLAYER_MOVEMENT &movement) void Player::MoveForward() { - state->ApplyLinearImpulse(myData->lookDir * 100); + state.ApplyLinearImpulse(myData->lookDir * 100); } void Player::MoveBackwards() { - state->ApplyLinearImpulse(-myData->lookDir * 100); + state.ApplyLinearImpulse(-myData->lookDir * 100); } void Player::MoveRight() { //Do cross product with forward vector and negative gravity vector Oyster::Math::Float4 r = (-rigidBody->GetGravityNormal()).Cross((Oyster::Math::Float3)myData->lookDir); - state->ApplyLinearImpulse(r * 100); + state.ApplyLinearImpulse(r * 100); } void Player::MoveLeft() { //Do cross product with forward vector and negative gravity vector Oyster::Math::Float4 r = -(-rigidBody->GetGravityNormal()).Cross((Oyster::Math::Float3)myData->lookDir); - state->ApplyLinearImpulse(-r * 100); + state.ApplyLinearImpulse(-r * 100); } void Player::UseWeapon(const WEAPON_FIRE &fireInput) @@ -101,7 +101,7 @@ void Player::UseWeapon(const WEAPON_FIRE &fireInput) void Player::Respawn(Oyster::Math::Float3 spawnPoint) { - //API::Instance().SetCenter(rigidBody,spawnPoint); + myData->life = 100; myData->playerState = PLAYER_STATE::PLAYER_STATE_IDLE; myData->lookDir = Oyster::Math::Float4(1,0,0); @@ -109,7 +109,7 @@ void Player::Respawn(Oyster::Math::Float3 spawnPoint) void Player::Jump() { - //API::Instance().ApplyForceAt(rigidBody,rigidBody->GetCenter(),-Oyster::Math::Float3(0,1,0) * 100); + } bool Player::IsWalking() @@ -127,8 +127,7 @@ bool Player::IsIdle() Oyster::Math::Float3 Player::GetPos() { - //return rigidBody->GetCenter(); - return Oyster::Math::Float3(0,0,0); + return (Oyster::Math::Float3)state.GetCenterPosition(); } Oyster::Math::Float3 Player::GetLookDir() diff --git a/Code/Game/GameLogic/Weapon.h b/Code/Game/GameLogic/Weapon.h index cdd1a3b7..719a853c 100644 --- a/Code/Game/GameLogic/Weapon.h +++ b/Code/Game/GameLogic/Weapon.h @@ -34,8 +34,6 @@ namespace GameLogic bool IsValidSocket(int socketID); int GetCurrentSocketID(); - - private: struct PrivateData; From c541d032e79ebdb2499db8cafe3be37ac4cc51f4 Mon Sep 17 00:00:00 2001 From: lindaandersson Date: Fri, 10 Jan 2014 10:47:54 +0100 Subject: [PATCH 5/6] GL - can move a obj on the client via the server --- Code/Game/DanBiasGame/DanBiasGame_Impl.cpp | 5 ++-- .../GameClientState/C_obj/C_DynamicObj.cpp | 1 + .../GameClientState/C_obj/C_Player.cpp | 2 +- .../GameClientState/C_obj/C_StaticObj.cpp | 1 + .../GameClientState/C_obj/C_UIobject.cpp | 1 + .../DanBiasGame/GameClientState/GameState.cpp | 13 +++++++++- .../DanBiasServer/GameSession/GameSession.cpp | 24 ++++++++++++------- Code/Game/GameLogic/Object.h | 9 +------ 8 files changed, 35 insertions(+), 21 deletions(-) diff --git a/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp index 57d47292..b71f6dcd 100644 --- a/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp +++ b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp @@ -23,7 +23,8 @@ namespace DanBias { Oyster::Network::NetworkClient* nwClient; Client::GameClientState* gameClientState; - + + void NetworkCallback(Oyster::Network::CustomNetProtocol& p) override { int pType = p[0].value.netInt; @@ -159,7 +160,7 @@ namespace DanBias m_data->recieverObj = new MyRecieverObject; - // m_data->recieverObj->nwClient = new Oyster::Network::NetworkClient(m_data->recieverObj, Oyster::Network::NetworkProtocolCallbackType_Object); + m_data->recieverObj->nwClient = new Oyster::Network::NetworkClient(m_data->recieverObj, Oyster::Network::NetworkProtocolCallbackType_Object); m_data->recieverObj->nwClient->Connect(desc.port, desc.IP); if (!m_data->recieverObj->nwClient->IsConnected()) diff --git a/Code/Game/DanBiasGame/GameClientState/C_obj/C_DynamicObj.cpp b/Code/Game/DanBiasGame/GameClientState/C_obj/C_DynamicObj.cpp index f47fc9fe..3df74e40 100644 --- a/Code/Game/DanBiasGame/GameClientState/C_obj/C_DynamicObj.cpp +++ b/Code/Game/DanBiasGame/GameClientState/C_obj/C_DynamicObj.cpp @@ -26,6 +26,7 @@ void C_DynamicObj::Init(ModelInitData modelInit) privData->model = Oyster::Graphics::API::CreateModel(modelInit.modelPath); privData->model->WorldMatrix = modelInit.world; privData->model->Visible = modelInit.visible; + privData->ID = modelInit.id; } void C_DynamicObj::setPos(Oyster::Math::Float4x4 world) { diff --git a/Code/Game/DanBiasGame/GameClientState/C_obj/C_Player.cpp b/Code/Game/DanBiasGame/GameClientState/C_obj/C_Player.cpp index 86acaf4b..4cd6fbd3 100644 --- a/Code/Game/DanBiasGame/GameClientState/C_obj/C_Player.cpp +++ b/Code/Game/DanBiasGame/GameClientState/C_obj/C_Player.cpp @@ -28,7 +28,7 @@ void C_Player::Init(ModelInitData modelInit) privData->model = Oyster::Graphics::API::CreateModel(modelInit.modelPath); privData->model->WorldMatrix = modelInit.world; privData->model->Visible = modelInit.visible; - + privData->ID = modelInit.id; } void C_Player::setPos(Oyster::Math::Float4x4 world) diff --git a/Code/Game/DanBiasGame/GameClientState/C_obj/C_StaticObj.cpp b/Code/Game/DanBiasGame/GameClientState/C_obj/C_StaticObj.cpp index c5f2e119..177b032b 100644 --- a/Code/Game/DanBiasGame/GameClientState/C_obj/C_StaticObj.cpp +++ b/Code/Game/DanBiasGame/GameClientState/C_obj/C_StaticObj.cpp @@ -28,6 +28,7 @@ void C_StaticObj::Init(ModelInitData modelInit) privData->model = Oyster::Graphics::API::CreateModel(modelInit.modelPath); privData->model->WorldMatrix = modelInit.world; privData->model->Visible = modelInit.visible; + privData->ID = modelInit.id; } void C_StaticObj::setPos(Oyster::Math::Float4x4 world) diff --git a/Code/Game/DanBiasGame/GameClientState/C_obj/C_UIobject.cpp b/Code/Game/DanBiasGame/GameClientState/C_obj/C_UIobject.cpp index 226d8ca7..fa5dff04 100644 --- a/Code/Game/DanBiasGame/GameClientState/C_obj/C_UIobject.cpp +++ b/Code/Game/DanBiasGame/GameClientState/C_obj/C_UIobject.cpp @@ -24,6 +24,7 @@ void C_UIobject::Init(ModelInitData modelInit) privData->model = Oyster::Graphics::API::CreateModel(modelInit.modelPath); privData->model->WorldMatrix = modelInit.world; privData->model->Visible = modelInit.visible; + privData->ID = modelInit.id; } void C_UIobject::setPos(Oyster::Math::Float4x4 world) diff --git a/Code/Game/DanBiasGame/GameClientState/GameState.cpp b/Code/Game/DanBiasGame/GameClientState/GameState.cpp index bf156d3e..cc4bbe53 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/GameState.cpp @@ -40,6 +40,12 @@ bool GameState::Init(Oyster::Network::NetworkClient* nwClient) } GameState::gameStateState GameState::LoadGame() { + Oyster::Graphics::Definitions::Pointlight plight; + plight.Pos = Oyster::Math::Float3(0,3,0); + plight.Color = Oyster::Math::Float3(0,1,0); + plight.Radius = 5; + plight.Bright = 2; + Oyster::Graphics::API::AddLight(plight); LoadModels(L"map"); InitCamera(Oyster::Math::Float3(0,0,5.4f)); return gameStateState_playing; @@ -56,18 +62,22 @@ bool GameState::LoadModels(std::wstring mapFile) modelData.world = Oyster::Math3D::Float4x4::identity; modelData.visible = true; modelData.modelPath = L"..\\Content\\worldDummy"; + modelData.id = 0; // load models C_Object* obj = new C_Player(); privData->object.push_back(obj); privData->object[privData->object.size() -1 ]->Init(modelData); - Oyster::Math3D::Float4x4 translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(2,2,2)); + Oyster::Math3D::Float4x4 translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(-2,2,2)); modelData.world = modelData.world * translate; modelData.modelPath = L"..\\Content\\worldDummy"; + modelData.id ++; obj = new C_DynamicObj(); privData->object.push_back(obj); privData->object[privData->object.size() -1 ]->Init(modelData); + + return true; } bool GameState::InitCamera(Oyster::Math::Float3 startPos) @@ -209,6 +219,7 @@ void GameState::Protocol( ObjPos* pos ) { world[i] = pos->worldPos[i]; } + for (int i = 0; i < privData->object.size(); i++) { if(privData->object[i]->GetId() == pos->object_ID) diff --git a/Code/Game/DanBiasServer/GameSession/GameSession.cpp b/Code/Game/DanBiasServer/GameSession/GameSession.cpp index 866626c4..e5238620 100644 --- a/Code/Game/DanBiasServer/GameSession/GameSession.cpp +++ b/Code/Game/DanBiasServer/GameSession/GameSession.cpp @@ -156,19 +156,25 @@ namespace DanBias { case protocol_Gameplay_PlayerNavigation: { + + Oyster::Math::Float4x4 world = Oyster::Math::Matrix::identity; if(p[1].value.netBool) //bool bForward; - c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_FORWARD); + world.v[3].x = 2; + //c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_FORWARD); if(p[2].value.netBool) //bool bBackward; - c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_BACKWARD); + world.v[3].x = -2; + //c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_BACKWARD); if(p[5].value.netBool) //bool bStrafeRight; - c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_RIGHT); + world.v[3].y = 2; + //c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_RIGHT); if(p[6].value.netBool) //bool bStrafeLeft; - c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_LEFT); - - //Oyster::Math::Float4x4 p; - Protocol_ObjectPosition op;//(c.GetPlayer()->GetRigidBody(), c.GetPlayer()->GetID()); - //op.object_ID = c.GetPlayer()->GetID(); - Send(op.GetProtocol()); + world.v[3].y = -2; + //c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_LEFT); + + Protocol_ObjectPosition res(world, 0); + Send(res.GetProtocol()); + + } break; case protocol_Gameplay_PlayerMouseMovement: diff --git a/Code/Game/GameLogic/Object.h b/Code/Game/GameLogic/Object.h index c199eb58..c880e90d 100644 --- a/Code/Game/GameLogic/Object.h +++ b/Code/Game/GameLogic/Object.h @@ -9,15 +9,8 @@ #include "GameLogicStates.h" #include "GameLogicDef.h" +#include -namespace Oyster -{ - namespace Physics - { - class ICustomBody; - class State; - } -} namespace GameLogic { class DANBIAS_GAMELOGIC_DLL Object From 059b3dd5e46e18b9c4e6611598dafd35f5fd00e0 Mon Sep 17 00:00:00 2001 From: Erik Persson Date: Fri, 10 Jan 2014 12:33:04 +0100 Subject: [PATCH 6/6] GameLogic - Basic game interface made (functions not yet implemented) --- Code/Game/GameLogic/Game.cpp | 71 +++++++++++++++++++++ Code/Game/GameLogic/Game.h | 88 +++++++++++++++++++++++++++ Code/Game/GameLogic/GameLogic.vcxproj | 2 + Code/Game/GameLogic/Object.cpp | 1 - Code/Game/GameLogic/Player.cpp | 4 +- Code/Game/GameLogic/Player.h | 2 +- 6 files changed, 164 insertions(+), 4 deletions(-) create mode 100644 Code/Game/GameLogic/Game.cpp create mode 100644 Code/Game/GameLogic/Game.h diff --git a/Code/Game/GameLogic/Game.cpp b/Code/Game/GameLogic/Game.cpp new file mode 100644 index 00000000..806ac6d2 --- /dev/null +++ b/Code/Game/GameLogic/Game.cpp @@ -0,0 +1,71 @@ +#include "Game.h" +#include "Player.h" +#include "Level.h" + +using namespace GameLogic; + +struct Game::PrivateData +{ + PrivateData() + { + + } + + ~PrivateData() + { + + } + + Player **players; + Level *level; + +}myData; + + +Game::Game(void) +{ + myData = new PrivateData(); +} + +Game::~Game(void) +{ + if(myData) + { + delete myData; + } +} + +void Game::MovePlayer(int playerID, const PLAYER_MOVEMENT &movement) +{ + +} + +void Game::PlayerUseWeapon(int playerID, const WEAPON_FIRE &Usage) +{ + +} + +void Game::GetPlayerPos(int playerID) +{ + +} + +void Game::GetAllPlayerPos() +{ + +} + +Game::PlayerData Game::CreatePlayer() +{ + +} + +void Game::CreateTeam() +{ + +} + +void Game::NewFrame() +{ + +} \ No newline at end of file diff --git a/Code/Game/GameLogic/Game.h b/Code/Game/GameLogic/Game.h new file mode 100644 index 00000000..a70dc842 --- /dev/null +++ b/Code/Game/GameLogic/Game.h @@ -0,0 +1,88 @@ +#ifndef GAME_H +#define GAME_H + +#include "GameLogicStates.h" +namespace GameLogic +{ + class Game + { + + public: + struct PlayerData + { + int playerID; + int teamID; + + PlayerData() + { + playerID = 0; + teamID = 0; + } + + PlayerData(int playerID,int teamID) + { + this->playerID = playerID; + this->teamID = teamID; + + } + + ~PlayerData() + { + + } + }; + + public: + Game(void); + ~Game(void); + + /******************************************************** + * Moves the chosen player based on input + * @param playerID: ID of the player you want to recieve the message + * @param movement: enum value on what kind of action is to be taken + ********************************************************/ + void MovePlayer(int playerID, const PLAYER_MOVEMENT &movement); + + /******************************************************** + * Uses the chosen players weapon based on input + * @param playerID: ID of the player you want to recieve the message + * @param Usage: enum value on what kind of action is to be taken + ********************************************************/ + void PlayerUseWeapon(int playerID, const WEAPON_FIRE &Usage); + + /******************************************************** + * Gets a specific players position + * @param playerID: ID of the player whos position you want + ********************************************************/ + void GetPlayerPos(int playerID); + + /******************************************************** + * Gets the position of all players currently in the game + ********************************************************/ + void GetAllPlayerPos(); + + /******************************************************** + * Creates a player and returns PlayerData containing ID of the player + ********************************************************/ + PlayerData CreatePlayer(); + + /******************************************************** + * Creates a team + ********************************************************/ + void CreateTeam(); + + /******************************************************** + * Runs a update of the gamelogic and physics + ********************************************************/ + void NewFrame(); + + + private: + struct PrivateData; + PrivateData *myData; + + }; +} + + +#endif diff --git a/Code/Game/GameLogic/GameLogic.vcxproj b/Code/Game/GameLogic/GameLogic.vcxproj index 500f8bbc..c67ef3d9 100644 --- a/Code/Game/GameLogic/GameLogic.vcxproj +++ b/Code/Game/GameLogic/GameLogic.vcxproj @@ -173,6 +173,7 @@ + @@ -190,6 +191,7 @@ + diff --git a/Code/Game/GameLogic/Object.cpp b/Code/Game/GameLogic/Object.cpp index e824c1d5..49ff7780 100644 --- a/Code/Game/GameLogic/Object.cpp +++ b/Code/Game/GameLogic/Object.cpp @@ -50,7 +50,6 @@ Object::Object(void* collisionFunc, OBJECT_TYPE type) Object::~Object(void) { - } OBJECT_TYPE Object::GetType() diff --git a/Code/Game/GameLogic/Player.cpp b/Code/Game/GameLogic/Player.cpp index 626e565f..a3702a53 100644 --- a/Code/Game/GameLogic/Player.cpp +++ b/Code/Game/GameLogic/Player.cpp @@ -94,9 +94,9 @@ void Player::MoveLeft() state.ApplyLinearImpulse(-r * 100); } -void Player::UseWeapon(const WEAPON_FIRE &fireInput) +void Player::UseWeapon(const WEAPON_FIRE &Usage) { - myData->weapon->Use(fireInput); + myData->weapon->Use(Usage); } void Player::Respawn(Oyster::Math::Float3 spawnPoint) diff --git a/Code/Game/GameLogic/Player.h b/Code/Game/GameLogic/Player.h index 2cc703ac..e9ad03da 100644 --- a/Code/Game/GameLogic/Player.h +++ b/Code/Game/GameLogic/Player.h @@ -33,7 +33,7 @@ namespace GameLogic * Uses the weapon based on input * @param fireInput: enum value on what kind of action is to be taken ********************************************************/ - void UseWeapon(const WEAPON_FIRE &fireInput); + void UseWeapon(const WEAPON_FIRE &Usage); /******************************************************** * Respawns the player, this resets several stats and settings on the player