lite saker + debug fönster

This commit is contained in:
Erik Persson 2013-11-26 11:30:49 +01:00
parent 5cc6ff81b5
commit d87e643777
7 changed files with 62 additions and 74 deletions

View File

@ -4,9 +4,44 @@ using namespace GameLogic;
CollisionManager::CollisionManager(void)
{
refManager = new RefManager();
}
CollisionManager::~CollisionManager(void)
{
SAFE_DELETE(refManager);
}
void CollisionManager::ColisionEvent(Oyster::Physics::ICustomBody &obj1, Oyster::Physics::ICustomBody &obj2)
{
Object *realObj1 = refManager->GetMap(obj1);
Object *realObj2 = refManager->GetMap(obj2);
switch(realObj1->GetType())
{
case Object::OBJECT_TYPE_PLAYER:
if (realObj2->GetType() == Object::OBJECT_TYPE_BOX )
{
PlayerVBox(*((Player*)realObj1),*((DynamicObject*)realObj2));
}
break;
case Object::OBJECT_TYPE_BOX:
if (realObj2->GetType() == Object::OBJECT_TYPE_PLAYER)
{
PlayerVBox(*((Player*)realObj2),*((DynamicObject*)realObj1));
}
break;
}
}
void CollisionManager::PlayerVBox(Player &player, DynamicObject &box)
{
//spela ljud? ta skada? etc etc
}

View File

@ -17,11 +17,12 @@ namespace GameLogic
CollisionManager(void);
~CollisionManager(void);
private:
void ColisionEvent(Oyster::Physics::ICustomBody &obj1, Oyster::Physics::ICustomBody &obj2);
void PlayerVBox(Player &player, DynamicObject &box);
private:
RefManager *refManager;
};

View File

@ -59,3 +59,8 @@ void Object::Render()
model->info->Vertices.Apply(0);
Oyster::Graphics::Core::deviceContext->Draw(model->info->VertexCount,0);
}
Object::OBJECT_TYPE Object::GetType()
{
return this->type;
}

View File

@ -4,23 +4,33 @@
#include "Model/Model.h"
#include "Render/Rendering/Render.h"
#include "Utilities.h"
#include "PhysicsAPI.h"
namespace GameLogic
{
class Object
{
public:
Object(void);
virtual ~Object(void);
enum OBJECT_TYPE
{
OBJECT_TYPE_PLAYER,
OBJECT_TYPE_BOX,
};
void Render();
OBJECT_TYPE GetType();
private:
OBJECT_TYPE type;
protected:
//either a model pointer or an ID to an arraypos filled with models that are to be rendered

View File

@ -7,73 +7,15 @@ using namespace Oyster::Physics;
using namespace Utility::DynamicMemory;
//void ColisionEvent(unsigned int obj1Ref, unsigned int obj2Ref)
//{
// const ICustomBody *body1 = &API::Instance().Peek( obj1Ref );
// const ICustomBody *body2 = &API::Instance().Peek( obj2Ref );
// if( body1 != &Error::nobody )
// {
// Object *obj1 = (Object*) const_cast<ICustomBody*>(body1);
//
// Object *obj2 = (Object*) const_cast<ICustomBody*>(body2);
//
// //switch( obj1->type )
// //{
// //case Player:
// // switch (obj2->type)
// // {
// // case låda:
// // //action
// // //soud
// // //particle effect
//
// // }
//
// //case låda :
//
//
// //}
// }
//
//}
void DestructionEvent(unsigned int obj1, ::Utility::DynamicMemory::UniquePointer<ICustomBody> obj2)
{
}
Player::Player(void)
:Object()
{
life = 10;
life = 100;
UniquePointer<ICustomBody> rigidBody = API::Instance().CreateSimpleRigidBody();
rigidBody = API::Instance().CreateSimpleRigidBody();
API::Instance().AddObject(rigidBody);
////ref = API::Instance().AddObject(API::Instance().CreateSimpleRigidBody());
//const ICustomBody* rB;
////rB = &API::Instance().Peek(ref);
////if( rB == &Error::nobody)
////{
//// //error
////}
//API::Instance().SetCenter(ref, Oyster::Math::Float3::null);
//API::Instance().SetMass_KeepMomentum(ref, 20);
//// get Tensor matrix (tröghetsmonent)
////API::Instance().SetMomentOfInertiaTensor_KeepMomentum(ref, tensorMatrix )
//
////Oyster::Math::Float3 ve = rB->GetCenter();
//API::Instance().SetDeltaTime(0.01f);
////API::Instance().ApplyForceAt(ref, rB->GetCenter(), Oyster::Math::Float3::null);
//
////API::Instance().SetAction(ColisionEvent);
////API::Instance().Update();
}
@ -83,8 +25,7 @@ Player::~Player(void)
}
void Player::Update()
{
//API::Instance().API::Update();
//API::Instance().API::ApplyForceAt(ref, )
}
void Player::Move()

View File

@ -7,8 +7,6 @@
namespace GameLogic
{
//void ColisionEvent(unsigned int obj1, unsigned int obj2);
void DestructionEvent(unsigned int obj1, ::Utility::DynamicMemory::UniquePointer<Oyster::Physics::ICustomBody> obj2);
class Player : public Object
{

View File

@ -8,20 +8,18 @@
namespace GameLogic
{
class RefManager
{
public:
RefManager(void);
~RefManager(void);
Object* GetMap(Oyster::Physics::ICustomBody &body);
void AddMapping(Oyster::Physics::ICustomBody &body, Object &obj);
Object* GetMap(Oyster::Physics::ICustomBody &body); //returns the object of an rigidBody, mainly used for CollisionHandler
void AddMapping(Oyster::Physics::ICustomBody &body, Object &obj); //adds a mapping with body as key and the object as a value
private:
std::map<Oyster::Physics::ICustomBody*,Object*> mapper; //shall be pointer from physics that map to an object
std::map<Oyster::Physics::ICustomBody*,Object*> mapper; //mapper points a rigidBody to an actual game object
};
}