GL - Added jumppad(implemented but not tested)
This commit is contained in:
parent
b810fa1586
commit
4ad86ae83b
|
@ -6,12 +6,14 @@
|
|||
#include "AttatchmentMassDriver.h"
|
||||
#include "Game.h"
|
||||
#include "CollisionManager.h"
|
||||
#include "JumpPad.h"
|
||||
|
||||
using namespace Oyster;
|
||||
|
||||
using namespace GameLogic;
|
||||
|
||||
void PlayerVObject(Player &player, Object &obj, Oyster::Math::Float kineticEnergyLoss);
|
||||
void SendObjectFlying(Oyster::Physics::ICustomBody &obj, Oyster::Math::Float3 force);
|
||||
|
||||
//Physics::ICustomBody::SubscriptMessage
|
||||
void Player::PlayerCollision(Oyster::Physics::ICustomBody *rigidBodyPlayer, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss)
|
||||
|
@ -42,6 +44,34 @@ using namespace GameLogic;
|
|||
//return Physics::ICustomBody::SubscriptMessage_none;
|
||||
}
|
||||
|
||||
void JumpPad::JumpPadActivated(Oyster::Physics::ICustomBody *rigidBodyJumpPad, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss)
|
||||
{
|
||||
JumpPad *jumpPad = (JumpPad*)(rigidBodyJumpPad->GetCustomTag());
|
||||
Object *realObj = (Object*)obj->GetCustomTag(); //needs to be changed?
|
||||
|
||||
switch (realObj->GetObjectType())
|
||||
{
|
||||
case OBJECT_TYPE::OBJECT_TYPE_GENERIC:
|
||||
break;
|
||||
case OBJECT_TYPE::OBJECT_TYPE_BOX:
|
||||
break;
|
||||
case OBJECT_TYPE::OBJECT_TYPE_PLAYER:
|
||||
SendObjectFlying(*obj, jumpPad->pushForce);
|
||||
break;
|
||||
case OBJECT_TYPE::OBJECT_TYPE_WORLD:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void SendObjectFlying(Oyster::Physics::ICustomBody &obj, Oyster::Math::Float3 force)
|
||||
{
|
||||
Oyster::Physics::ICustomBody::State state;
|
||||
|
||||
state = obj.GetState();
|
||||
state.ApplyLinearImpulse(force);
|
||||
obj.SetState(state);
|
||||
}
|
||||
|
||||
|
||||
void PlayerVObject(Player &player, Object &obj, Oyster::Math::Float kineticEnergyLoss)
|
||||
{
|
||||
|
|
|
@ -42,7 +42,7 @@ GameAPI& GameAPI::Instance()
|
|||
Game::Game(void)
|
||||
: initiated(false)
|
||||
, onMoveFnc(0)
|
||||
, onDeadFnc(0)
|
||||
, onDisableFnc(0)
|
||||
, frameTime(1.0f/120.0f)
|
||||
{}
|
||||
|
||||
|
@ -151,7 +151,7 @@ void Game::SetSubscription(GameEvent::ObjectEventFunctionType type, GameEvent::O
|
|||
this->onMoveFnc = functionPointer;
|
||||
break;
|
||||
case GameLogic::GameEvent::ObjectEventFunctionType_OnDead:
|
||||
this->onDeadFnc = functionPointer;
|
||||
this->onDisableFnc = functionPointer;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -183,6 +183,6 @@ void Game::PhysicsOnMove(const ICustomBody *object)
|
|||
}
|
||||
void Game::PhysicsOnDestroy(::Utility::DynamicMemory::UniquePointer<ICustomBody> proto)
|
||||
{
|
||||
if(gameInstance.onDeadFnc) gameInstance.onDeadFnc(0);
|
||||
if(gameInstance.onDisableFnc) gameInstance.onDisableFnc(0);
|
||||
}
|
||||
|
||||
|
|
|
@ -73,16 +73,14 @@ namespace GameLogic
|
|||
|
||||
float GetFrameTime() const;
|
||||
|
||||
private:
|
||||
static void PhysicsOnMove(const Oyster::Physics::ICustomBody *object);
|
||||
static void PhysicsOnDestroy(::Utility::DynamicMemory::UniquePointer<Oyster::Physics::ICustomBody> proto);
|
||||
|
||||
private:
|
||||
Utility::DynamicMemory::DynamicArray<PlayerData*> players;
|
||||
LevelData* level;
|
||||
float frameTime;
|
||||
bool initiated;
|
||||
GameEvent::ObjectEventFunction onDeadFnc;
|
||||
GameEvent::ObjectEventFunction onDisableFnc;
|
||||
GameEvent::ObjectEventFunction onMoveFnc;
|
||||
|
||||
};
|
||||
|
|
|
@ -183,6 +183,7 @@
|
|||
<ClInclude Include="GameLogicStates.h" />
|
||||
<ClInclude Include="GameMode.h" />
|
||||
<ClInclude Include="IAttatchment.h" />
|
||||
<ClInclude Include="JumpPad.h" />
|
||||
<ClInclude Include="Level.h" />
|
||||
<ClInclude Include="LevelLoader\LevelLoader.h" />
|
||||
<ClInclude Include="LevelLoader\Loader.h" />
|
||||
|
@ -206,6 +207,7 @@
|
|||
<ClCompile Include="Game_LevelData.cpp" />
|
||||
<ClCompile Include="Game_PlayerData.cpp" />
|
||||
<ClCompile Include="IAttatchment.cpp" />
|
||||
<ClCompile Include="JumpPad.cpp" />
|
||||
<ClCompile Include="Level.cpp" />
|
||||
<ClCompile Include="LevelLoader\LevelLoader.cpp" />
|
||||
<ClCompile Include="LevelLoader\Loader.cpp" />
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
#include "JumpPad.h"
|
||||
#include "PhysicsAPI.h"
|
||||
|
||||
using namespace GameLogic;
|
||||
using namespace Oyster::Physics;
|
||||
|
||||
JumpPad::JumpPad(void)
|
||||
{
|
||||
}
|
||||
|
||||
JumpPad::JumpPad(Oyster::Physics::ICustomBody *rigidBody ,Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter), Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type, Oyster::Math::Float3 pushForce)
|
||||
:StaticObject(rigidBody, collisionFuncBefore, collisionFuncAfter, type)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
JumpPad::~JumpPad(void)
|
||||
{
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
#ifndef JUMPPAD_H
|
||||
#define JUMPPAD_H
|
||||
#include "StaticObject.h"
|
||||
namespace GameLogic
|
||||
{
|
||||
class JumpPad : public StaticObject
|
||||
{
|
||||
public:
|
||||
JumpPad(void);
|
||||
|
||||
JumpPad(Oyster::Physics::ICustomBody *rigidBody
|
||||
,Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter)
|
||||
,Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss)
|
||||
,OBJECT_TYPE type, Oyster::Math::Float3 pushForce);
|
||||
|
||||
~JumpPad(void);
|
||||
|
||||
static void JumpPadActivated(Oyster::Physics::ICustomBody *rigidBodyJumpPad, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss);
|
||||
|
||||
private:
|
||||
Oyster::Math::Float3 pushForce;
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
#endif
|
|
@ -61,7 +61,6 @@ Player::~Player(void)
|
|||
void Player::BeginFrame()
|
||||
{
|
||||
weapon->Update(0.002f);
|
||||
//if(playerState == PLAYER_STATE_DEAD) Respawn(Oyster::Math::Float3(0,308,0));
|
||||
Object::BeginFrame();
|
||||
}
|
||||
|
||||
|
@ -205,7 +204,7 @@ void Player::DamageLife(int damage)
|
|||
{
|
||||
this->life = 0;
|
||||
playerState = PLAYER_STATE_DEAD;
|
||||
//do stuff that makes you dead
|
||||
this->gameInstance->onDisableFnc(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue