Created test box that should now be shot at by the player

This commit is contained in:
Erik Persson 2014-01-27 13:54:57 +01:00
parent 5b984db9ba
commit 1ed1bab751
13 changed files with 95 additions and 48 deletions

View File

@ -24,24 +24,39 @@ using namespace GameLogic;
namespace DanBias namespace DanBias
{ {
//TEST SHIT
GameAPI *game = &GameAPI::Instance();
DynamicArray<IPlayerData*> players;
//TEST SHIT
bool GameSession::DoWork( ) bool GameSession::DoWork( )
{ {
if(this->isRunning) if(this->isRunning)
{ {
if(GetAsyncKeyState(VK_UP)) //TEST SHIT
{ //player creation and testing
Protocol_General_Status p(Protocol_General_Status::States_ready); //players.Resize(10);
Send(p.GetProtocol());
Sleep(100);
}
if(GetAsyncKeyState(VK_DOWN))
{
Oyster::Math::Float4x4 world = Oyster::Math::Matrix::identity;
Protocol_ObjectCreate p(world, 2, "../Content/crate");
Send(p.GetProtocol());
Sleep(100);
}
//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
double dt = this->timer.getElapsedSeconds(); double dt = this->timer.getElapsedSeconds();
gameInstance.SetFrameTimeLength((float)dt); gameInstance.SetFrameTimeLength((float)dt);

View File

@ -45,7 +45,7 @@ void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &usage,
********************************************************/ ********************************************************/
void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &usage, float dt) void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &usage, float dt)
{ {
Oyster::Math::Float4 pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (500 * dt); //Oyster::Math::Float4 pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (500 * dt);
Oyster::Math::Float4x4 aim = Oyster::Math3D::ViewMatrix_LookAtDirection(owner->GetLookDir(), owner->GetRigidBody()->GetGravityNormal(), owner->GetPosition()); Oyster::Math::Float4x4 aim = Oyster::Math3D::ViewMatrix_LookAtDirection(owner->GetLookDir(), owner->GetRigidBody()->GetGravityNormal(), owner->GetPosition());
Oyster::Math::Float4x4 hitSpace = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/4,1,1,20); Oyster::Math::Float4x4 hitSpace = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/4,1,1,20);
Oyster::Collision3D::Frustrum hitFrustum = Oyster::Collision3D::Frustrum(Oyster::Math3D::ViewProjectionMatrix(aim,hitSpace)); Oyster::Collision3D::Frustrum hitFrustum = Oyster::Collision3D::Frustrum(Oyster::Math3D::ViewProjectionMatrix(aim,hitSpace));

View File

@ -5,25 +5,10 @@
using namespace GameLogic; using namespace GameLogic;
using namespace Utility::DynamicMemory; using namespace Utility::DynamicMemory;
struct AttatchmentSocket::PrivateData
{
PrivateData()
{
}
~PrivateData()
{
}
SmartPointer<IAttatchment> attatchment;
}myData;
AttatchmentSocket::AttatchmentSocket(void) AttatchmentSocket::AttatchmentSocket(void)
{ {
this->attatchment = 0;
} }
@ -34,17 +19,17 @@ AttatchmentSocket::~AttatchmentSocket(void)
IAttatchment* AttatchmentSocket::GetAttatchment() IAttatchment* AttatchmentSocket::GetAttatchment()
{ {
return myData->attatchment; return this->attatchment;
} }
void AttatchmentSocket::SetAttatchment(IAttatchment *attatchment) void AttatchmentSocket::SetAttatchment(IAttatchment *attatchment)
{ {
myData->attatchment = attatchment; this->attatchment = attatchment;
} }
void AttatchmentSocket::RemoveAttatchment() void AttatchmentSocket::RemoveAttatchment()
{ {
myData->attatchment = 0; this->attatchment = 0;
} }

View File

@ -19,8 +19,7 @@ namespace GameLogic
void RemoveAttatchment(); void RemoveAttatchment();
private: private:
struct PrivateData; IAttatchment *attatchment;
PrivateData *myData;
}; };
} }
#endif #endif

View File

@ -4,6 +4,7 @@
#include "Player.h" #include "Player.h"
#include "Level.h" #include "Level.h"
#include "AttatchmentMassDriver.h" #include "AttatchmentMassDriver.h"
#include "Game.h"
using namespace Oyster; using namespace Oyster;
@ -15,8 +16,9 @@ using namespace GameLogic;
//Physics::ICustomBody::SubscriptMessage //Physics::ICustomBody::SubscriptMessage
void Player::PlayerCollision(Oyster::Physics::ICustomBody *rigidBodyPlayer, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss) void Player::PlayerCollision(Oyster::Physics::ICustomBody *rigidBodyPlayer, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss)
{ {
Player *player = ((Player*)(rigidBodyPlayer->GetCustomTag()));
Object *realObj = (Object*)obj->GetCustomTag(); Player *player = ((Game::PlayerData*)(rigidBodyPlayer->GetCustomTag()))->player;
Object *realObj = (Object*)obj->GetCustomTag(); //needs to be changed?
switch (realObj->GetType()) switch (realObj->GetType())
{ {
@ -63,13 +65,13 @@ using namespace GameLogic;
} }
//Oyster::Physics::ICustomBody::SubscriptMessage //Oyster::Physics::ICustomBody::SubscriptMessage
void Level::LevelCollision(const Oyster::Physics::ICustomBody *rigidBodyLevel, const Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss) void Level::LevelCollision(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss)
{ {
//return Physics::ICustomBody::SubscriptMessage_ignore_collision_response; //return Physics::ICustomBody::SubscriptMessage_ignore_collision_response;
} }
void AttatchmentMassDriver::ForcePushAction(Oyster::Physics::ICustomBody *obj) void AttatchmentMassDriver::ForcePushAction(Oyster::Physics::ICustomBody *obj)
{ {
Oyster::Math::Float4 pushForce = Oyster::Math::Float4(owner->GetLookDir()) * (500); Oyster::Math::Float4 pushForce = Oyster::Math::Float4(1,0,0,0) * (500);
((Object*)obj->GetCustomTag())->ApplyLinearImpulse(pushForce); ((Object*)obj->GetCustomTag())->ApplyLinearImpulse(pushForce);
} }

View File

@ -6,6 +6,7 @@ using namespace GameLogic;
Game::PlayerData::PlayerData() Game::PlayerData::PlayerData()
{ {
Oyster::Physics::API::SimpleBodyDescription sbDesc; Oyster::Physics::API::SimpleBodyDescription sbDesc;
//set some stats that are appropriate to a player
//create rigidbody //create rigidbody
Oyster::Physics::ICustomBody *rigidBody = Oyster::Physics::API::Instance().CreateRigidBody(sbDesc).Release(); Oyster::Physics::ICustomBody *rigidBody = Oyster::Physics::API::Instance().CreateRigidBody(sbDesc).Release();
@ -60,5 +61,5 @@ OBJECT_TYPE Game::PlayerData::GetObjectType() const
} }
void Game::PlayerData::Rotate(const Oyster::Math3D::Float3 lookDir) void Game::PlayerData::Rotate(const Oyster::Math3D::Float3 lookDir)
{ {
this->player->Rotate(lookDir); //this->player->Rotate(lookDir);
} }

View File

@ -38,6 +38,20 @@ void Level::InitiateLevel(float radius)
levelObj = new StaticObject(rigidBody, LevelCollision, OBJECT_TYPE::OBJECT_TYPE_WORLD); levelObj = new StaticObject(rigidBody, LevelCollision, OBJECT_TYPE::OBJECT_TYPE_WORLD);
API::SphericalBodyDescription sbDesc_TestBox;
sbDesc.centerPosition = Oyster::Math::Float4(3,15,0,0);
sbDesc.ignoreGravity = true;
sbDesc.radius = 8; //radius;
sbDesc.mass = 10e12f;
//sbDesc.mass = 0; //10^16
ICustomBody* rigidBody_TestBox = API::Instance().CreateRigidBody(sbDesc_TestBox).Release();
DynamicObject *testBox = new DynamicObject(rigidBody_TestBox,LevelCollision,OBJECT_TYPE::OBJECT_TYPE_BOX);
/*API::Gravity gravityWell; /*API::Gravity gravityWell;
gravityWell.gravityType = API::Gravity::GravityType_Well; gravityWell.gravityType = API::Gravity::GravityType_Well;

View File

@ -57,7 +57,7 @@ namespace GameLogic
* @param rigidBodyLevel: physics object of the level * @param rigidBodyLevel: physics object of the level
* @param obj: physics object for the object that collided with the level * @param obj: physics object for the object that collided with the level
********************************************************/ ********************************************************/
static void LevelCollision(const Oyster::Physics::ICustomBody *rigidBodyLevel, const Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss); static void LevelCollision(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss);
private: private:
TeamManager teamManager; TeamManager teamManager;

View File

@ -62,6 +62,12 @@ Object::Object(ICustomBody *rigidBody ,void* collisionFunc, OBJECT_TYPE type)
Object::Object(Oyster::Physics::ICustomBody *rigidBody ,void (*collisionFunc)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type) Object::Object(Oyster::Physics::ICustomBody *rigidBody ,void (*collisionFunc)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type)
{ {
Oyster::Physics::API::Instance().AddObject(rigidBody);
rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_Collision)(collisionFunc));
this->rigidBody = rigidBody;
this->type = type;
this->objectID = GID();
} }

View File

@ -23,13 +23,25 @@ Player::Player()
Player::Player(Oyster::Physics::ICustomBody *rigidBody ,void (*collisionFunc)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type) Player::Player(Oyster::Physics::ICustomBody *rigidBody ,void (*collisionFunc)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type)
:DynamicObject(rigidBody, collisionFunc, type) :DynamicObject(rigidBody, collisionFunc, type)
{ {
weapon = new Weapon(2,this);
this->life = 100;
this->teamID = -1;
this->playerState = PLAYER_STATE_IDLE;
lookDir = Oyster::Math::Float4(0,0,-1,0);
setState.SetCenterPosition(Oyster::Math::Float4(0,15,0,1));
setState.SetReach(Oyster::Math::Float4(2,3.5,2,0));
} }
Player::~Player(void) Player::~Player(void)
{ {
if(weapon)
{
delete weapon; delete weapon;
weapon = NULL; weapon = NULL;
}
} }

View File

@ -17,7 +17,7 @@ namespace GameLogic
public: public:
StaticObject(); StaticObject();
StaticObject(void* collisionFunc, OBJECT_TYPE type); StaticObject(void* collisionFunc, OBJECT_TYPE type);
StaticObject(Oyster::Physics::ICustomBody *rigidBody,void* collisionFunc, OBJECT_TYPE type); //StaticObject(Oyster::Physics::ICustomBody *rigidBody,void* collisionFunc, OBJECT_TYPE type);
StaticObject(Oyster::Physics::ICustomBody *rigidBody ,void (*collisionFunc)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type); StaticObject(Oyster::Physics::ICustomBody *rigidBody ,void (*collisionFunc)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type);
StaticObject(OBJECT_TYPE type); StaticObject(OBJECT_TYPE type);
~StaticObject(void); ~StaticObject(void);

View File

@ -1,5 +1,6 @@
#include "Weapon.h" #include "Weapon.h"
#include "AttatchmentMassDriver.h" #include "AttatchmentMassDriver.h"
#include "Player.h"
using namespace GameLogic; using namespace GameLogic;
@ -15,9 +16,21 @@ Weapon::Weapon()
attatchmentSockets = 0; attatchmentSockets = 0;
} }
Weapon::Weapon(int MaxNrOfSockets) Weapon::Weapon(int MaxNrOfSockets,Player *owner)
{ {
attatchmentSockets.Resize(MaxNrOfSockets); attatchmentSockets.Resize(MaxNrOfSockets);
attatchmentSockets[0] = new AttatchmentSocket();
weaponState = WEAPON_STATE_IDLE;
currentNrOfAttatchments = 0;
selectedAttatchment = 0;
//give the weapon a massdriver on socket 0
IAttatchment *mD = new AttatchmentMassDriver(*owner);
attatchmentSockets[0]->SetAttatchment(mD);
this->currentNrOfAttatchments = 1;
SelectAttatchment(0);
//give the weapon a massdriver on socket 0
} }

View File

@ -16,7 +16,7 @@ namespace GameLogic
{ {
public: public:
Weapon(void); Weapon(void);
Weapon(int nrOfAttatchmentSockets); Weapon(int nrOfAttatchmentSockets, Player *owner);
~Weapon(void); ~Weapon(void);
void Use(const WEAPON_FIRE &usage, float dt); void Use(const WEAPON_FIRE &usage, float dt);