GL - added jump
This commit is contained in:
parent
c593fd2225
commit
7d9d8e4615
|
@ -282,6 +282,8 @@ void GameState::readKeyInput(InputClass* KeyInput)
|
|||
playerLookDir.lookDirZ = look.z;
|
||||
privData->nwClient->Send(playerLookDir);
|
||||
}
|
||||
|
||||
// shoot
|
||||
if(KeyInput->IsKeyPressed(DIK_Z))
|
||||
{
|
||||
if(!key_Shoot)
|
||||
|
@ -295,6 +297,20 @@ void GameState::readKeyInput(InputClass* KeyInput)
|
|||
else
|
||||
key_Shoot = false;
|
||||
|
||||
// jump
|
||||
if(KeyInput->IsKeyPressed(DIK_X))
|
||||
{
|
||||
if(!key_Jump)
|
||||
{
|
||||
GameLogic::Protocol_PlayerJump playerJump;
|
||||
playerJump.hasJumped = true;
|
||||
privData->nwClient->Send(playerJump);
|
||||
key_Jump = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
key_Jump = false;
|
||||
|
||||
// send event data
|
||||
//
|
||||
if(KeyInput->IsKeyPressed(DIK_L))
|
||||
|
|
|
@ -23,6 +23,7 @@ private:
|
|||
bool key_strafeRight;
|
||||
bool key_strafeLeft;
|
||||
bool key_Shoot;
|
||||
bool key_Jump;
|
||||
Camera* camera;
|
||||
|
||||
struct myData;
|
||||
|
|
|
@ -67,7 +67,13 @@ namespace DanBias
|
|||
|
||||
break;
|
||||
case protocol_Gameplay_PlayerShot:
|
||||
c->GetPlayer()->UseWeapon(GameLogic::WEAPON_USE_PRIMARY_PRESS);
|
||||
if (p[1].value.netBool)
|
||||
c->GetPlayer()->UseWeapon(GameLogic::WEAPON_USE_PRIMARY_PRESS);
|
||||
break;
|
||||
case protocol_Gameplay_PlayerJump:
|
||||
if (p[1].value.netBool)
|
||||
c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_JUMP);
|
||||
break;
|
||||
case protocol_Gameplay_ObjectDamage:
|
||||
|
||||
break;
|
||||
|
|
|
@ -148,6 +148,31 @@ namespace GameLogic
|
|||
Oyster::Network::CustomNetProtocol protocol;
|
||||
};
|
||||
|
||||
struct Protocol_PlayerJump :public Oyster::Network::CustomProtocolObject
|
||||
{
|
||||
bool hasJumped;
|
||||
|
||||
Protocol_PlayerJump()
|
||||
{
|
||||
this->protocol[protocol_INDEX_ID].value = protocol_Gameplay_PlayerJump;
|
||||
this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short;
|
||||
|
||||
this->protocol[1].type = Oyster::Network::NetAttributeType_Bool;
|
||||
}
|
||||
const Protocol_PlayerJump& operator=(Oyster::Network::CustomNetProtocol& val)
|
||||
{
|
||||
hasJumped = val[1].value.netBool;
|
||||
return *this;
|
||||
}
|
||||
Oyster::Network::CustomNetProtocol* GetProtocol() override
|
||||
{
|
||||
this->protocol[1].value = hasJumped;
|
||||
return &protocol;
|
||||
}
|
||||
|
||||
private:
|
||||
Oyster::Network::CustomNetProtocol protocol;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // !GAMELOGIC_PLAYER_PROTOCOLS_H
|
||||
|
|
|
@ -50,12 +50,13 @@
|
|||
#define protocol_Gameplay_PlayerLookDir 301
|
||||
#define protocol_Gameplay_PlayerChangeWeapon 302
|
||||
#define protocol_Gameplay_PlayerShot 303
|
||||
#define protocol_Gameplay_ObjectPickup 304
|
||||
#define protocol_Gameplay_ObjectDamage 305
|
||||
#define protocol_Gameplay_ObjectPosition 306
|
||||
#define protocol_Gameplay_ObjectEnabled 307
|
||||
#define protocol_Gameplay_ObjectDisabled 308
|
||||
#define protocol_Gameplay_ObjectCreate 309
|
||||
#define protocol_Gameplay_PlayerJump 304
|
||||
#define protocol_Gameplay_ObjectPickup 305
|
||||
#define protocol_Gameplay_ObjectDamage 306
|
||||
#define protocol_Gameplay_ObjectPosition 307
|
||||
#define protocol_Gameplay_ObjectEnabled 308
|
||||
#define protocol_Gameplay_ObjectDisabled 309
|
||||
#define protocol_Gameplay_ObjectCreate 310
|
||||
#define protocol_GameplayMAX 399
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue