Danbias/Code/Game/DanBiasServer/GameSession/GameSession_Logic.cpp

90 lines
2.5 KiB
C++
Raw Normal View History

/////////////////////////////////////////////////////////////////////
// Created by [Dennis Andersen] [2013]
/////////////////////////////////////////////////////////////////////
#include "GameSession.h"
#include "GameClient.h"
#include <Protocols.h>
#include <PostBox\PostBox.h>
#include <GameLogicStates.h>
#include <Windows.h>
2014-01-15 08:18:06 +01:00
#include <OysterMath.h>
#define DELTA_TIME_20 0.05f
2014-01-20 15:47:52 +01:00
#define DELTA_TIME_24 0.04166666666666666666666666666667f
#define DELTA_TIME_30 0.03333333333333333333333333333333f
#define DELTA_TIME_60 0.01666666666666666666666666666667f
#define DELTA_TIME_120 0.00833333333333333333333333333333f
using namespace Utility::DynamicMemory;
using namespace Oyster;
using namespace Oyster::Network;
using namespace Oyster::Thread;
using namespace GameLogic;
namespace DanBias
{
//TEST SHIT
GameAPI *game = &GameAPI::Instance();
DynamicArray<IPlayerData*> players;
//TEST SHIT
bool GameSession::DoWork( )
{
2014-01-20 15:47:52 +01:00
if(this->isRunning)
2014-01-15 08:18:06 +01:00
{
//TEST SHIT
//player creation and testing
//players.Resize(10);
//for(int i = 0; i < 10; i++)
//{
// players[i] = game->CreatePlayer();WWW
// players[i]->Move(GameLogic::PLAYER_MOVEMENT::PLAYER_MOVEMENT_BACKWARD);
// players[i]->Move(GameLogic::PLAYER_MOVEMENT::PLAYER_MOVEMENT_FORWARD);
// players[i]->Move(GameLogic::PLAYER_MOVEMENT::PLAYER_MOVEMENT_JUMP);
// players[i]->Move(GameLogic::PLAYER_MOVEMENT::PLAYER_MOVEMENT_LEFT);
// players[i]->Move(GameLogic::PLAYER_MOVEMENT::PLAYER_MOVEMENT_RIGHT);
// //using weapon testing
// players[i]->UseWeapon(GameLogic::WEAPON_FIRE::WEAPON_USE_PRIMARY_PRESS);
// players[i]->UseWeapon(GameLogic::WEAPON_FIRE::WEAPON_USE_PRIMARY_RELEASE);
// players[i]->UseWeapon(GameLogic::WEAPON_FIRE::WEAPON_USE_SECONDARY_PRESS);
// players[i]->UseWeapon(GameLogic::WEAPON_FIRE::WEAPON_USE_SECONDARY_RELEASE);
// players[i]->UseWeapon(GameLogic::WEAPON_FIRE::WEAPON_USE_UTILLITY_PRESS);
//}
//TEST SHIT
2014-01-20 15:47:52 +01:00
double dt = this->timer.getElapsedSeconds();
gameInstance.SetFrameTimeLength((float)dt);
if(dt >= DELTA_TIME_20)
2014-01-20 15:47:52 +01:00
{
this->ParseEvents();
2014-01-16 12:26:14 +01:00
2014-01-20 15:47:52 +01:00
this->gameInstance.NewFrame();
2014-01-20 15:47:52 +01:00
this->UpdateGameObjects();
2014-01-20 15:47:52 +01:00
this->timer.reset();
}
}
return this->isRunning;
}
void GameSession::UpdateGameObjects()
{
2014-01-20 15:47:52 +01:00
if(clients.Size() >= 1 && clients[0])
2014-01-16 12:26:14 +01:00
{
Oyster::Math::Float4x4 world = this->clients[0]->GetPlayer()->GetOrientation();
Protocol_ObjectPosition p(world, 2);
2014-01-16 12:26:14 +01:00
Send(p.GetProtocol());
}
}
}//End namespace DanBias