GL - can play with two characters
This commit is contained in:
parent
0ae551f2d8
commit
e327f64702
|
@ -157,7 +157,13 @@ namespace DanBias
|
||||||
m_data->recieverObj->gameClientState = new Client::LobbyState();
|
m_data->recieverObj->gameClientState = new Client::LobbyState();
|
||||||
break;
|
break;
|
||||||
case Client::GameClientState::ClientState_Game:
|
case Client::GameClientState::ClientState_Game:
|
||||||
|
if(m_data->serverOwner)
|
||||||
|
DanBias::GameServerAPI::GameStart();
|
||||||
m_data->recieverObj->gameClientState = new Client::GameState();
|
m_data->recieverObj->gameClientState = new Client::GameState();
|
||||||
|
if(m_data->serverOwner)
|
||||||
|
((Client::GameState*)m_data->recieverObj->gameClientState)->setClientId(2);
|
||||||
|
else
|
||||||
|
((Client::GameState*)m_data->recieverObj->gameClientState)->setClientId(3);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
|
|
|
@ -114,6 +114,18 @@ bool GameState::LoadModels(std::wstring mapFile)
|
||||||
privData->object.push_back(obj);
|
privData->object.push_back(obj);
|
||||||
privData->object[privData->object.size() -1 ]->Init(modelData);
|
privData->object[privData->object.size() -1 ]->Init(modelData);
|
||||||
|
|
||||||
|
// add player model 2
|
||||||
|
modelData.world = Oyster::Math3D::Float4x4::identity;
|
||||||
|
translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(10, 320, 0));
|
||||||
|
|
||||||
|
modelData.world = modelData.world * translate;
|
||||||
|
modelData.visible = true;
|
||||||
|
modelData.modelPath = L"..\\Content\\Models\\char_white.dan";
|
||||||
|
modelData.id = 3;
|
||||||
|
// load models
|
||||||
|
obj = new C_Player();
|
||||||
|
privData->object.push_back(obj);
|
||||||
|
privData->object[privData->object.size() -1 ]->Init(modelData);
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -137,7 +149,10 @@ bool GameState::InitCamera(Oyster::Math::Float3 startPos)
|
||||||
privData->view = Oyster::Math3D::InverseOrientationMatrix(privData->view);
|
privData->view = Oyster::Math3D::InverseOrientationMatrix(privData->view);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
void GameState::setClientId(int id)
|
||||||
|
{
|
||||||
|
myId = id;
|
||||||
|
}
|
||||||
GameClientState::ClientState GameState::Update(float deltaTime, InputClass* KeyInput)
|
GameClientState::ClientState GameState::Update(float deltaTime, InputClass* KeyInput)
|
||||||
{
|
{
|
||||||
switch (privData->state)
|
switch (privData->state)
|
||||||
|
@ -344,7 +359,7 @@ void GameState::Protocol( ObjPos* pos )
|
||||||
//camera->setRight((Oyster::Math::Float3(world[0], world[1], world[2])));
|
//camera->setRight((Oyster::Math::Float3(world[0], world[1], world[2])));
|
||||||
//camera->setUp((Oyster::Math::Float3(world[4], world[5], world[6])));
|
//camera->setUp((Oyster::Math::Float3(world[4], world[5], world[6])));
|
||||||
//camera->setLook((Oyster::Math::Float3(world[8], world[9], world[10])));
|
//camera->setLook((Oyster::Math::Float3(world[8], world[9], world[10])));
|
||||||
if(i == 2) // playerobj
|
if(i == myId) // playerobj
|
||||||
{
|
{
|
||||||
camera->SetPosition(Oyster::Math::Float3(world[12], world[13]+2.2f, world[14]-1));
|
camera->SetPosition(Oyster::Math::Float3(world[12], world[13]+2.2f, world[14]-1));
|
||||||
camera->UpdateViewMatrix();
|
camera->UpdateViewMatrix();
|
||||||
|
|
|
@ -26,6 +26,7 @@ private:
|
||||||
bool key_Jump;
|
bool key_Jump;
|
||||||
Camera* camera;
|
Camera* camera;
|
||||||
|
|
||||||
|
int myId;
|
||||||
struct myData;
|
struct myData;
|
||||||
myData* privData;
|
myData* privData;
|
||||||
public:
|
public:
|
||||||
|
@ -36,7 +37,7 @@ public:
|
||||||
bool LoadModels(std::wstring mapFile) ;
|
bool LoadModels(std::wstring mapFile) ;
|
||||||
bool InitCamera(Oyster::Math::Float3 startPos) ;
|
bool InitCamera(Oyster::Math::Float3 startPos) ;
|
||||||
gameStateState LoadGame();
|
gameStateState LoadGame();
|
||||||
|
void setClientId(int id);
|
||||||
void readKeyInput(InputClass* KeyInput);
|
void readKeyInput(InputClass* KeyInput);
|
||||||
bool Render()override;
|
bool Render()override;
|
||||||
bool Release()override;
|
bool Release()override;
|
||||||
|
|
|
@ -88,11 +88,8 @@ GameClientState::ClientState LobbyState::Update(float deltaTime, InputClass* Key
|
||||||
// send data to server
|
// send data to server
|
||||||
// check data from server
|
// check data from server
|
||||||
|
|
||||||
|
|
||||||
if( KeyInput->IsKeyPressed(DIK_G))
|
if( KeyInput->IsKeyPressed(DIK_G))
|
||||||
{
|
{
|
||||||
if(!DanBias::GameServerAPI::GameStart())
|
|
||||||
return GameClientState::ClientState_Same;
|
|
||||||
return ClientState_Game;
|
return ClientState_Game;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -109,7 +109,7 @@ GameClientState::ClientState LoginState::Update(float deltaTime, InputClass* Key
|
||||||
if( KeyInput->IsKeyPressed(DIK_J))
|
if( KeyInput->IsKeyPressed(DIK_J))
|
||||||
{
|
{
|
||||||
// game ip
|
// game ip
|
||||||
nwClient->Connect(15151, "193.11.184.109");
|
nwClient->Connect(15151, "127.0.0.1");
|
||||||
|
|
||||||
if (!nwClient->IsConnected())
|
if (!nwClient->IsConnected())
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,9 +7,10 @@ Game::PlayerData::PlayerData()
|
||||||
{
|
{
|
||||||
//set some stats that are appropriate to a player
|
//set some stats that are appropriate to a player
|
||||||
Oyster::Physics::API::SimpleBodyDescription sbDesc;
|
Oyster::Physics::API::SimpleBodyDescription sbDesc;
|
||||||
sbDesc.centerPosition = Oyster::Math::Float3(0,320,0);
|
sbDesc.centerPosition = Oyster::Math::Float3(0,308,0);
|
||||||
sbDesc.size = Oyster::Math::Float3(4,7,4);
|
sbDesc.size = Oyster::Math::Float3(4,7,4);
|
||||||
sbDesc.mass = 70;
|
sbDesc.mass = 70;
|
||||||
|
sbDesc.restitutionCoeff = 0.5;
|
||||||
//create rigid body
|
//create rigid body
|
||||||
Oyster::Physics::ICustomBody *rigidBody = Oyster::Physics::API::Instance().CreateRigidBody(sbDesc).Release();
|
Oyster::Physics::ICustomBody *rigidBody = Oyster::Physics::API::Instance().CreateRigidBody(sbDesc).Release();
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ void Level::InitiateLevel(float radius)
|
||||||
|
|
||||||
ICustomBody::State state;
|
ICustomBody::State state;
|
||||||
rigidBody->GetState(state);
|
rigidBody->GetState(state);
|
||||||
state.SetRestitutionCoeff(0.01);
|
state.SetRestitutionCoeff(0.2);
|
||||||
rigidBody->SetState(state);
|
rigidBody->SetState(state);
|
||||||
|
|
||||||
levelObj = new StaticObject(rigidBody, LevelCollisionBefore, LevelCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_WORLD);
|
levelObj = new StaticObject(rigidBody, LevelCollisionBefore, LevelCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_WORLD);
|
||||||
|
|
|
@ -123,7 +123,7 @@ void Object::BeginFrame()
|
||||||
{
|
{
|
||||||
Oyster::Math3D::SnapAngularAxis(Oyster::Math::Float4(setState.GetAngularAxis(), 0), Oyster::Math::Float4::standard_unit_y, -Oyster::Math::Float4(setState.GetGravityNormal()), axis);
|
Oyster::Math3D::SnapAngularAxis(Oyster::Math::Float4(setState.GetAngularAxis(), 0), Oyster::Math::Float4::standard_unit_y, -Oyster::Math::Float4(setState.GetGravityNormal()), axis);
|
||||||
setState.SetRotation(axis.xyz);
|
setState.SetRotation(axis.xyz);
|
||||||
|
setState.SetAngularMomentum(Float3::null);
|
||||||
Oyster::Math::Float3 debug = ::LinearAlgebra3D::WorldAxisOf(::LinearAlgebra3D::Rotation(axis.xyz), Oyster::Math::Float3::standard_unit_y);
|
Oyster::Math::Float3 debug = ::LinearAlgebra3D::WorldAxisOf(::LinearAlgebra3D::Rotation(axis.xyz), Oyster::Math::Float3::standard_unit_y);
|
||||||
debug += setState.GetGravityNormal();
|
debug += setState.GetGravityNormal();
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,12 +86,14 @@ namespace DanBias
|
||||||
if(dynamic_cast<IPlayerData*> (movedObject))
|
if(dynamic_cast<IPlayerData*> (movedObject))
|
||||||
{
|
{
|
||||||
IPlayerData* temp = (IPlayerData*)movedObject;
|
IPlayerData* temp = (IPlayerData*)movedObject;
|
||||||
temp->GetID();
|
|
||||||
|
int id = temp->GetID();
|
||||||
Oyster::Math::Float4x4 world = temp->GetOrientation();
|
Oyster::Math::Float4x4 world = temp->GetOrientation();
|
||||||
|
|
||||||
Protocol_ObjectPosition p(world, 2);
|
Protocol_ObjectPosition p(world, id);
|
||||||
GameSession::gameSession->Send(*p.GetProtocol());
|
GameSession::gameSession->Send(*p.GetProtocol());
|
||||||
}
|
}
|
||||||
|
|
||||||
GameLogic::IObjectData* obj = NULL;
|
GameLogic::IObjectData* obj = NULL;
|
||||||
if(dynamic_cast<GameLogic::ILevelData*>(movedObject))
|
if(dynamic_cast<GameLogic::ILevelData*>(movedObject))
|
||||||
{
|
{
|
||||||
|
@ -100,10 +102,10 @@ namespace DanBias
|
||||||
{
|
{
|
||||||
if(obj->GetObjectType() == OBJECT_TYPE_WORLD)
|
if(obj->GetObjectType() == OBJECT_TYPE_WORLD)
|
||||||
{
|
{
|
||||||
obj->GetID();
|
int id = obj->GetID();
|
||||||
Oyster::Math::Float4x4 world =obj->GetOrientation();
|
Oyster::Math::Float4x4 world =obj->GetOrientation();
|
||||||
|
|
||||||
Protocol_ObjectPosition p(world, 0);
|
Protocol_ObjectPosition p(world, id);
|
||||||
GameSession::gameSession->Send(*p.GetProtocol());
|
GameSession::gameSession->Send(*p.GetProtocol());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,9 +116,9 @@ namespace DanBias
|
||||||
{
|
{
|
||||||
if(obj->GetObjectType() == OBJECT_TYPE_BOX)
|
if(obj->GetObjectType() == OBJECT_TYPE_BOX)
|
||||||
{
|
{
|
||||||
obj->GetID();
|
int id = obj->GetID();
|
||||||
Oyster::Math::Float4x4 world = obj->GetOrientation();
|
Oyster::Math::Float4x4 world = obj->GetOrientation();
|
||||||
Protocol_ObjectPosition p(world, 1);
|
Protocol_ObjectPosition p(world, id);
|
||||||
GameSession::gameSession->Send(*p.GetProtocol());
|
GameSession::gameSession->Send(*p.GetProtocol());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue