Created test box that should now be shot at by the player
This commit is contained in:
parent
5b984db9ba
commit
1ed1bab751
|
@ -24,24 +24,39 @@ using namespace GameLogic;
|
|||
|
||||
namespace DanBias
|
||||
{
|
||||
//TEST SHIT
|
||||
GameAPI *game = &GameAPI::Instance();
|
||||
DynamicArray<IPlayerData*> players;
|
||||
|
||||
//TEST SHIT
|
||||
|
||||
bool GameSession::DoWork( )
|
||||
{
|
||||
if(this->isRunning)
|
||||
{
|
||||
if(GetAsyncKeyState(VK_UP))
|
||||
{
|
||||
Protocol_General_Status p(Protocol_General_Status::States_ready);
|
||||
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);
|
||||
}
|
||||
//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
|
||||
double dt = this->timer.getElapsedSeconds();
|
||||
gameInstance.SetFrameTimeLength((float)dt);
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &usage,
|
|||
********************************************************/
|
||||
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 hitSpace = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/4,1,1,20);
|
||||
Oyster::Collision3D::Frustrum hitFrustum = Oyster::Collision3D::Frustrum(Oyster::Math3D::ViewProjectionMatrix(aim,hitSpace));
|
||||
|
|
|
@ -5,25 +5,10 @@
|
|||
using namespace GameLogic;
|
||||
using namespace Utility::DynamicMemory;
|
||||
|
||||
struct AttatchmentSocket::PrivateData
|
||||
{
|
||||
PrivateData()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
~PrivateData()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
SmartPointer<IAttatchment> attatchment;
|
||||
|
||||
|
||||
}myData;
|
||||
|
||||
AttatchmentSocket::AttatchmentSocket(void)
|
||||
{
|
||||
this->attatchment = 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -34,17 +19,17 @@ AttatchmentSocket::~AttatchmentSocket(void)
|
|||
|
||||
IAttatchment* AttatchmentSocket::GetAttatchment()
|
||||
{
|
||||
return myData->attatchment;
|
||||
return this->attatchment;
|
||||
}
|
||||
|
||||
void AttatchmentSocket::SetAttatchment(IAttatchment *attatchment)
|
||||
{
|
||||
myData->attatchment = attatchment;
|
||||
this->attatchment = attatchment;
|
||||
}
|
||||
|
||||
void AttatchmentSocket::RemoveAttatchment()
|
||||
{
|
||||
|
||||
myData->attatchment = 0;
|
||||
this->attatchment = 0;
|
||||
|
||||
}
|
||||
|
|
|
@ -19,8 +19,7 @@ namespace GameLogic
|
|||
void RemoveAttatchment();
|
||||
|
||||
private:
|
||||
struct PrivateData;
|
||||
PrivateData *myData;
|
||||
IAttatchment *attatchment;
|
||||
};
|
||||
}
|
||||
#endif
|
|
@ -4,6 +4,7 @@
|
|||
#include "Player.h"
|
||||
#include "Level.h"
|
||||
#include "AttatchmentMassDriver.h"
|
||||
#include "Game.h"
|
||||
|
||||
using namespace Oyster;
|
||||
|
||||
|
@ -15,8 +16,9 @@ using namespace GameLogic;
|
|||
//Physics::ICustomBody::SubscriptMessage
|
||||
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())
|
||||
{
|
||||
|
@ -63,13 +65,13 @@ using namespace GameLogic;
|
|||
|
||||
}
|
||||
//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;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ using namespace GameLogic;
|
|||
Game::PlayerData::PlayerData()
|
||||
{
|
||||
Oyster::Physics::API::SimpleBodyDescription sbDesc;
|
||||
//set some stats that are appropriate to a player
|
||||
|
||||
//create rigidbody
|
||||
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)
|
||||
{
|
||||
this->player->Rotate(lookDir);
|
||||
//this->player->Rotate(lookDir);
|
||||
}
|
|
@ -38,6 +38,20 @@ void Level::InitiateLevel(float radius)
|
|||
|
||||
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;
|
||||
|
||||
gravityWell.gravityType = API::Gravity::GravityType_Well;
|
||||
|
|
|
@ -57,7 +57,7 @@ namespace GameLogic
|
|||
* @param rigidBodyLevel: physics object of 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:
|
||||
TeamManager teamManager;
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
Oyster::Physics::API::Instance().AddObject(rigidBody);
|
||||
rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_Collision)(collisionFunc));
|
||||
|
||||
this->rigidBody = rigidBody;
|
||||
this->type = type;
|
||||
this->objectID = GID();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -23,15 +23,27 @@ 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)
|
||||
: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)
|
||||
{
|
||||
if(weapon)
|
||||
{
|
||||
delete weapon;
|
||||
weapon = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void Player::Move(const PLAYER_MOVEMENT &movement)
|
||||
{
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace GameLogic
|
|||
public:
|
||||
StaticObject();
|
||||
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(OBJECT_TYPE type);
|
||||
~StaticObject(void);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "Weapon.h"
|
||||
#include "AttatchmentMassDriver.h"
|
||||
#include "Player.h"
|
||||
|
||||
|
||||
using namespace GameLogic;
|
||||
|
@ -15,9 +16,21 @@ Weapon::Weapon()
|
|||
attatchmentSockets = 0;
|
||||
}
|
||||
|
||||
Weapon::Weapon(int MaxNrOfSockets)
|
||||
Weapon::Weapon(int MaxNrOfSockets,Player *owner)
|
||||
{
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace GameLogic
|
|||
{
|
||||
public:
|
||||
Weapon(void);
|
||||
Weapon(int nrOfAttatchmentSockets);
|
||||
Weapon(int nrOfAttatchmentSockets, Player *owner);
|
||||
~Weapon(void);
|
||||
|
||||
void Use(const WEAPON_FIRE &usage, float dt);
|
||||
|
|
Loading…
Reference in New Issue