Merge branch 'GameLogic' of https://github.com/dean11/Danbias into GameLogic

This commit is contained in:
lindaandersson 2014-01-23 09:25:02 +01:00
commit 07e5519850
6 changed files with 22 additions and 5 deletions

View File

@ -25,18 +25,19 @@ void Level::InitiateLevel(float radius)
sbDesc.radius = 8; //radius; sbDesc.radius = 8; //radius;
sbDesc.mass = 10e12f; sbDesc.mass = 10e12f;
//sbDesc.mass = 0; //10^16 //sbDesc.mass = 0; //10^16
sbDesc.subscription_onCollisionResponse = Level::LevelCollision;
levelObj = new StaticObject(OBJECT_TYPE::OBJECT_TYPE_WORLD);
ICustomBody* rigidBody = API::Instance().CreateRigidBody(sbDesc).Release(); ICustomBody* rigidBody = API::Instance().CreateRigidBody(sbDesc).Release();
rigidBody->SetCustomTag(levelObj); rigidBody->SetCustomTag(levelObj);
API::Instance().AddObject(rigidBody);
ICustomBody::State state; ICustomBody::State state;
rigidBody->GetState(state); rigidBody->GetState(state);
state.SetRestitutionCoeff(0.1); state.SetRestitutionCoeff(0.1);
rigidBody->SetState(state); rigidBody->SetState(state);
levelObj = new StaticObject(rigidBody, LevelCollision, OBJECT_TYPE::OBJECT_TYPE_WORLD);
API::Gravity gravityWell; API::Gravity gravityWell;
gravityWell.gravityType = API::Gravity::GravityType_Well; gravityWell.gravityType = API::Gravity::GravityType_Well;

View File

@ -49,6 +49,17 @@ Object::Object(void* collisionFunc, OBJECT_TYPE type)
this->type = type; this->type = type;
} }
Object::Object(ICustomBody *rigidBody ,void* collisionFunc, OBJECT_TYPE type)
{
Oyster::Physics::API::Instance().AddObject(rigidBody);
rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_Collision)(collisionFunc));
this->objectID = GID();
this->type = type;
}
void Object::ApplyLinearImpulse(Oyster::Math::Float4 force) void Object::ApplyLinearImpulse(Oyster::Math::Float4 force)
{ {
setState.ApplyLinearImpulse(force); setState.ApplyLinearImpulse(force);

View File

@ -18,6 +18,7 @@ namespace GameLogic
public: public:
Object(); Object();
Object(void* collisionFunc, OBJECT_TYPE type); Object(void* collisionFunc, OBJECT_TYPE type);
Object(Oyster::Physics::ICustomBody *rigidBody ,void* collisionFunc, OBJECT_TYPE type);
~Object(void); ~Object(void);
OBJECT_TYPE GetType() const; OBJECT_TYPE GetType() const;

View File

@ -18,8 +18,6 @@ Player::Player()
lookDir = Oyster::Math::Float4(0,0,-1,0); lookDir = Oyster::Math::Float4(0,0,-1,0);
setState.SetCenterPosition(Oyster::Math::Float4(0,15,0,1)); setState.SetCenterPosition(Oyster::Math::Float4(0,15,0,1));
setState.SetReach(Oyster::Math::Float4(2,3.5,2,0)); setState.SetReach(Oyster::Math::Float4(2,3.5,2,0));
} }
Player::~Player(void) Player::~Player(void)

View File

@ -19,6 +19,11 @@ StaticObject::StaticObject(OBJECT_TYPE type)
:Object(NULL,type) :Object(NULL,type)
{ {
}
StaticObject::StaticObject(Oyster::Physics::ICustomBody *rigidBody,void* collisionFunc, OBJECT_TYPE type)
:Object(rigidBody,collisionFunc,type)
{
} }

View File

@ -17,6 +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(OBJECT_TYPE type); StaticObject(OBJECT_TYPE type);
~StaticObject(void); ~StaticObject(void);