Merge branch 'GameLogic' of https://github.com/dean11/Danbias into GameLogic
This commit is contained in:
commit
3d973c16a2
|
@ -1,6 +1,6 @@
|
||||||
#include "CollisionManager.h"
|
#include "CollisionManager.h"
|
||||||
|
|
||||||
|
using namespace Oyster;
|
||||||
|
|
||||||
namespace GameLogic
|
namespace GameLogic
|
||||||
{
|
{
|
||||||
|
@ -8,10 +8,10 @@ namespace GameLogic
|
||||||
namespace CollisionManager
|
namespace CollisionManager
|
||||||
{
|
{
|
||||||
|
|
||||||
void PlayerCollision(Oyster::Physics::ICustomBody &rigidBodyPlayer,Oyster::Physics::ICustomBody &obj)
|
Physics::ICustomBody::SubscriptMessage PlayerCollision(const Oyster::Physics::ICustomBody *rigidBodyPlayer, const Oyster::Physics::ICustomBody *obj)
|
||||||
{
|
{
|
||||||
Player *player = ((Player*)GameLogic::RefManager::getInstance()->GetMap(rigidBodyPlayer));
|
Player *player = ((Player*)GameLogic::RefManager::getInstance()->GetMap(*rigidBodyPlayer));
|
||||||
Object *realObj = GameLogic::RefManager::getInstance()->GetMap(obj);
|
Object *realObj = GameLogic::RefManager::getInstance()->GetMap(*obj);
|
||||||
|
|
||||||
switch (realObj->GetType())
|
switch (realObj->GetType())
|
||||||
{
|
{
|
||||||
|
@ -24,6 +24,7 @@ namespace GameLogic
|
||||||
}
|
}
|
||||||
|
|
||||||
//spela ljud? ta skada? etc etc
|
//spela ljud? ta skada? etc etc
|
||||||
|
return Physics::ICustomBody::SubscriptMessage_none;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerVBox(Player &player, DynamicObject &box)
|
void PlayerVBox(Player &player, DynamicObject &box)
|
||||||
|
@ -31,10 +32,10 @@ namespace GameLogic
|
||||||
//spela ljud? ta skada? etc etc
|
//spela ljud? ta skada? etc etc
|
||||||
}
|
}
|
||||||
|
|
||||||
void BoxCollision(Oyster::Physics::ICustomBody &rigidBodyBox, Oyster::Physics::ICustomBody &obj)
|
Physics::ICustomBody::SubscriptMessage BoxCollision(const Oyster::Physics::ICustomBody *rigidBodyBox, const Oyster::Physics::ICustomBody *obj)
|
||||||
{
|
{
|
||||||
DynamicObject *box = ((DynamicObject*)GameLogic::RefManager::getInstance()->GetMap(rigidBodyBox));
|
DynamicObject *box = ((DynamicObject*)GameLogic::RefManager::getInstance()->GetMap(*rigidBodyBox));
|
||||||
Object *realObj = GameLogic::RefManager::getInstance()->GetMap(obj);
|
Object *realObj = GameLogic::RefManager::getInstance()->GetMap(*obj);
|
||||||
|
|
||||||
switch (realObj->GetType())
|
switch (realObj->GetType())
|
||||||
{
|
{
|
||||||
|
@ -45,6 +46,8 @@ namespace GameLogic
|
||||||
PlayerVBox(*(Player*)realObj,*box);
|
PlayerVBox(*(Player*)realObj,*box);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return Physics::ICustomBody::SubscriptMessage_none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -13,8 +13,9 @@ namespace GameLogic
|
||||||
namespace CollisionManager
|
namespace CollisionManager
|
||||||
{
|
{
|
||||||
//these are the main collision functions
|
//these are the main collision functions
|
||||||
void PlayerCollision(Oyster::Physics::ICustomBody &rigidBodyPlayer,Oyster::Physics::ICustomBody &obj);
|
//typedef SubscriptMessage (*EventAction_Collision)( const ICustomBody *proto, const ICustomBody *deuter );
|
||||||
void BoxCollision(Oyster::Physics::ICustomBody &rigidBodyBox, Oyster::Physics::ICustomBody &obj);
|
Oyster::Physics::ICustomBody::SubscriptMessage PlayerCollision(const Oyster::Physics::ICustomBody *rigidBodyPlayer, const Oyster::Physics::ICustomBody *obj);
|
||||||
|
Oyster::Physics::ICustomBody::SubscriptMessage BoxCollision(const Oyster::Physics::ICustomBody *rigidBodyBox, const Oyster::Physics::ICustomBody *obj);
|
||||||
|
|
||||||
//these are the specific collision case functions
|
//these are the specific collision case functions
|
||||||
void PlayerVBox(Player &player, DynamicObject &box);
|
void PlayerVBox(Player &player, DynamicObject &box);
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
#include "DynamicObject.h"
|
#include "DynamicObject.h"
|
||||||
|
#include "CollisionManager.h"
|
||||||
|
|
||||||
using namespace GameLogic;
|
using namespace GameLogic;
|
||||||
using namespace Oyster::Physics;
|
using namespace Oyster::Physics;
|
||||||
using namespace Utility::DynamicMemory;
|
using namespace Utility::DynamicMemory;
|
||||||
|
|
||||||
DynamicObject::DynamicObject(void)
|
DynamicObject::DynamicObject(std::wstring objFile)
|
||||||
:Object()
|
:Object(objFile)
|
||||||
{
|
{
|
||||||
|
rigidBody->SetSubscription(CollisionManager::BoxCollision);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace GameLogic
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DynamicObject(void);
|
DynamicObject(std::wstring objFile);
|
||||||
~DynamicObject(void);
|
~DynamicObject(void);
|
||||||
|
|
||||||
void Update();
|
void Update();
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "Game.h"
|
#include "Game.h"
|
||||||
|
|
||||||
using namespace GameLogic;
|
using namespace GameLogic;
|
||||||
|
|
||||||
Game::Game(void)
|
Game::Game(void)
|
||||||
|
@ -26,7 +27,13 @@ Game::~Game(void)
|
||||||
|
|
||||||
void Game::Init()
|
void Game::Init()
|
||||||
{
|
{
|
||||||
player = new Player();
|
//Oyster::Physics::API::SetSubscription("remove object");
|
||||||
|
|
||||||
|
player = new Player(L"worldDummy");
|
||||||
|
|
||||||
|
box = new DynamicObject(L"crate");
|
||||||
|
//poi
|
||||||
|
//box = new physcTestObj("box");
|
||||||
camera = new Camera();
|
camera = new Camera();
|
||||||
}
|
}
|
||||||
void Game::StartGame()
|
void Game::StartGame()
|
||||||
|
@ -60,9 +67,11 @@ void Game::Update(keyInput keyPressed, float pitch, float yaw)
|
||||||
camera->Walk(0.1);
|
camera->Walk(0.1);
|
||||||
}
|
}
|
||||||
camera->UpdateViewMatrix();
|
camera->UpdateViewMatrix();
|
||||||
|
//poi Oyster::Physics::API::Update();
|
||||||
}
|
}
|
||||||
void Game::Render()
|
void Game::Render()
|
||||||
{
|
{
|
||||||
Oyster::Graphics::API::NewFrame(camera->View(), camera->Proj());
|
Oyster::Graphics::API::NewFrame(camera->View(), camera->Proj());
|
||||||
player->Render();
|
player->Render();
|
||||||
|
box->Render();
|
||||||
}
|
}
|
|
@ -21,6 +21,7 @@ namespace GameLogic
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Level* level;
|
Level* level;
|
||||||
|
DynamicObject* box;
|
||||||
Player* player;
|
Player* player;
|
||||||
Camera* camera;
|
Camera* camera;
|
||||||
};
|
};
|
||||||
|
|
|
@ -12,15 +12,16 @@ using namespace Oyster::Graphics::Model;
|
||||||
using namespace Utility::DynamicMemory;
|
using namespace Utility::DynamicMemory;
|
||||||
using namespace Oyster::Physics;
|
using namespace Oyster::Physics;
|
||||||
|
|
||||||
Object::Object(void)
|
Object::Object(std::wstring objFile)
|
||||||
{
|
{
|
||||||
|
|
||||||
model = new Model();
|
//model = new Model();
|
||||||
model = Oyster::Graphics::API::CreateModel(L"orca");
|
model = Oyster::Graphics::API::CreateModel(objFile);
|
||||||
|
|
||||||
API::SimpleBodyDescription sbDesc;
|
API::SimpleBodyDescription sbDesc;
|
||||||
//sbDesc.centerPosition =
|
//sbDesc.centerPosition =
|
||||||
|
|
||||||
|
//poi
|
||||||
ICustomBody* temp = rigidBody = API::Instance().CreateRigidBody(sbDesc).Release();
|
ICustomBody* temp = rigidBody = API::Instance().CreateRigidBody(sbDesc).Release();
|
||||||
|
|
||||||
GameLogic::RefManager::getInstance()->AddMapping(*rigidBody, *this);
|
GameLogic::RefManager::getInstance()->AddMapping(*rigidBody, *this);
|
||||||
|
|
|
@ -25,7 +25,7 @@ namespace GameLogic
|
||||||
OBJECT_TYPE_PLAYER,
|
OBJECT_TYPE_PLAYER,
|
||||||
OBJECT_TYPE_BOX,
|
OBJECT_TYPE_BOX,
|
||||||
};
|
};
|
||||||
Object(void);
|
Object(std::wstring objFile );
|
||||||
virtual ~Object(void);
|
virtual ~Object(void);
|
||||||
|
|
||||||
void Render();
|
void Render();
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
#include "Player.h"
|
#include "Player.h"
|
||||||
#include "OysterMath.h"
|
#include "OysterMath.h"
|
||||||
|
#include "CollisionManager.h"
|
||||||
|
|
||||||
using namespace GameLogic;
|
using namespace GameLogic;
|
||||||
using namespace Oyster::Physics;
|
using namespace Oyster::Physics;
|
||||||
|
|
||||||
Player::Player(void)
|
Player::Player(std::wstring objFile)
|
||||||
:Object()
|
:Object( objFile )
|
||||||
{
|
{
|
||||||
life = 100;
|
life = 100;
|
||||||
|
rigidBody->SetSubscription(CollisionManager::PlayerCollision);
|
||||||
}
|
}
|
||||||
Player::~Player(void)
|
Player::~Player(void)
|
||||||
{
|
{
|
||||||
|
@ -16,6 +18,7 @@ Player::~Player(void)
|
||||||
|
|
||||||
void Player::Update(keyInput keyPressed)
|
void Player::Update(keyInput keyPressed)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(keyPressed != keyInput_none)
|
if(keyPressed != keyInput_none)
|
||||||
{
|
{
|
||||||
Move(keyPressed);
|
Move(keyPressed);
|
||||||
|
@ -24,6 +27,7 @@ void Player::Update(keyInput keyPressed)
|
||||||
|
|
||||||
void Player::Move(keyInput keyPressed)
|
void Player::Move(keyInput keyPressed)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(keyPressed == keyInput_A)
|
if(keyPressed == keyInput_A)
|
||||||
{
|
{
|
||||||
Oyster::Math::Float3 pos = this->rigidBody->GetCenter();
|
Oyster::Math::Float3 pos = this->rigidBody->GetCenter();
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace GameLogic
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Player(void);
|
Player(std::wstring objFile);
|
||||||
~Player(void);
|
~Player(void);
|
||||||
|
|
||||||
/********************************************************
|
/********************************************************
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
using namespace GameLogic;
|
using namespace GameLogic;
|
||||||
|
|
||||||
typedef std::pair<Oyster::Physics::ICustomBody*, Object*> mapData;
|
typedef std::pair<const Oyster::Physics::ICustomBody*, Object*> mapData;
|
||||||
|
|
||||||
RefManager* RefManager::instance = 0;
|
RefManager* RefManager::instance = 0;
|
||||||
|
|
||||||
|
@ -34,12 +34,12 @@ RefManager* RefManager::getInstance( )
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
Object* RefManager::GetMap(Oyster::Physics::ICustomBody &body)
|
Object* RefManager::GetMap(const Oyster::Physics::ICustomBody &body)
|
||||||
{
|
{
|
||||||
return mapper[&body];
|
return mapper[&body];
|
||||||
}
|
}
|
||||||
|
|
||||||
void RefManager::AddMapping(Oyster::Physics::ICustomBody &body, Object &obj)
|
void RefManager::AddMapping( const Oyster::Physics::ICustomBody &body, Object &obj)
|
||||||
{
|
{
|
||||||
mapper.insert(mapData(&body,&obj));
|
mapper.insert(mapData(&body,&obj));
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,13 +23,13 @@ namespace GameLogic
|
||||||
void Release();
|
void Release();
|
||||||
|
|
||||||
|
|
||||||
Object* GetMap(Oyster::Physics::ICustomBody &body); //returns the object of an rigidBody, mainly used for CollisionHandler
|
Object* GetMap(const 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
|
void AddMapping(const Oyster::Physics::ICustomBody &body, Object &obj); //adds a mapping with body as key and the object as a value
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static RefManager* instance;
|
static RefManager* instance;
|
||||||
std::map<Oyster::Physics::ICustomBody*,Object*> mapper; //mapper points a rigidBody to an actual game object
|
std::map<const Oyster::Physics::ICustomBody*,Object*> mapper; //mapper points a rigidBody to an actual game object
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
|
|
||||||
using namespace GameLogic;
|
using namespace GameLogic;
|
||||||
|
|
||||||
StaticObject::StaticObject(void)
|
StaticObject::StaticObject(std::wstring objFile)
|
||||||
|
:Object(objFile)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace GameLogic
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
StaticObject(void);
|
StaticObject(std::wstring objFile);
|
||||||
~StaticObject(void);
|
~StaticObject(void);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
|
|
||||||
using namespace GameLogic;
|
using namespace GameLogic;
|
||||||
|
|
||||||
Weapon::Weapon(void)
|
Weapon::Weapon(std::wstring objFile)
|
||||||
|
:Object(objFile)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace GameLogic
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Weapon(void);
|
Weapon(std::wstring objFile);
|
||||||
~Weapon(void);
|
~Weapon(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in New Issue