📄 mapobj.cpp.svn-base
字号:
#include <hge.h>
#include "gameDef.h"
#include "mapObj.h"
#include "game/mainGameState.h"
Entity::iEntity *MapObj::getEntityInterface(EntityInterfaceId id)
{
switch(id)
{
case EII_CollisionEntity:
return &collisionEntity;
case EII_GraphicEntity:
return &graphicEntity;
}
return Entity::getEntityInterface(id);
}
void MapObj::CollisionEntity::onCollision(iCollisionEntity &o, const iContactInfo &ci)
{
HGE *hge = hgeCreate(HGE_VERSION);
float deltaTime = hge->Timer_GetDelta();
hge->Release();
TankContactInfo &tci = (TankContactInfo &)ci;
Point2f contactPos = tci.getData()->GetContact(0);
Point2f dir = o.getBody().GetPointVelocity(contactPos, deltaTime);
Point2f impulse = dir * 0.001f * o.getBody().getMass();
Point2f force = impulse / deltaTime;
//getBody().AddForce(force, contactPos);
}
void MapObj::GraphicEntity::render(float gameTime, float deltaTime)
{
deltaTime;
int frameTime = int(gameTime * 60);
assert(animShape);
RenderQueue::getSingleton().render(getEntity().pos, -getEntity().orientation, frameTime, animShape, GLI_MapObj0);
#ifdef _DEBUG
#if 0
const Rectf &r = getEntity().collisionEntity.getBoundingBox();
RenderQueue::getSingleton().render(Point2f(r.left, r.top), Point2f(r.right, r.top), ARGB(128, 0, 0, 255));
RenderQueue::getSingleton().render(Point2f(r.right, r.top), Point2f(r.right, r.bottom), ARGB(128, 0, 0, 255));
RenderQueue::getSingleton().render(Point2f(r.right, r.bottom), Point2f(r.left, r.bottom), ARGB(128, 0, 0, 255));
RenderQueue::getSingleton().render(Point2f(r.left, r.bottom), Point2f(r.left, r.top), ARGB(128, 0, 0, 255));
#endif
#endif
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -