修改渲染底层,新增场景摄像机逻辑,地图可行区域逻辑
This commit is contained in:
@@ -45,6 +45,6 @@ void ActiveObject::Update(float deltaTime)
|
||||
SetPosition(Position);
|
||||
SDL_LogError(0, "修正Z轴");
|
||||
}
|
||||
// 执行父对象的更新
|
||||
// 执行父类的更新
|
||||
BaseObject::Update(deltaTime);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "BaseObject.h"
|
||||
|
||||
#include "Actor/Map/GameMap.h"
|
||||
BaseObject::BaseObject()
|
||||
{
|
||||
Init(); // 调用了RenderBase的Init函数 对象才会被执行回调
|
||||
@@ -12,6 +12,10 @@ BaseObject::~BaseObject()
|
||||
|
||||
void BaseObject::SetPosition(VecFPos3 pos)
|
||||
{
|
||||
if (pos.y != this->Position.y)
|
||||
{
|
||||
SetRenderZOrder((int)(this->Position.y)); // 设置渲染顺序
|
||||
}
|
||||
this->Position = pos;
|
||||
Actor::SetPos(VecFPos{this->Position.x, this->Position.y - this->Position.z});
|
||||
}
|
||||
@@ -29,6 +33,10 @@ void BaseObject::SetXpos(float x)
|
||||
|
||||
void BaseObject::SetYpos(float y)
|
||||
{
|
||||
if (y != this->Position.y)
|
||||
{
|
||||
SetRenderZOrder((int)(this->Position.y)); // 设置渲染顺序
|
||||
}
|
||||
this->Position.y = y;
|
||||
Actor::SetPos({this->Position.x, this->Position.y - this->Position.z});
|
||||
}
|
||||
@@ -56,17 +64,25 @@ int BaseObject::GetZpos()
|
||||
|
||||
void BaseObject::MoveBy(VecFPos3 pos)
|
||||
{
|
||||
this->Position.x += pos.x;
|
||||
this->Position.y += pos.y;
|
||||
this->Position.z += pos.z;
|
||||
// 只有moveby移动时判断所在地图中是否能够这样移动
|
||||
VecFPos3 RealPos = this->_AffMap->CheckIsItMovable(GetPosition(), pos);
|
||||
if (pos.y != 0)
|
||||
{
|
||||
SetRenderZOrder((int)(this->Position.y)); // 设置渲染顺序
|
||||
}
|
||||
this->Position = RealPos;
|
||||
Actor::SetPos({this->Position.x, this->Position.y - this->Position.z});
|
||||
}
|
||||
|
||||
void BaseObject::MoveBy(float x, float y, float z)
|
||||
{
|
||||
this->Position.x += x;
|
||||
this->Position.y += y;
|
||||
this->Position.z += z;
|
||||
// 只有moveby移动时判断所在地图中是否能够这样移动
|
||||
VecFPos3 RealPos = this->_AffMap->CheckIsItMovable(GetPosition(), VecFPos3({x, y, z}));
|
||||
if (y != 0)
|
||||
{
|
||||
SetRenderZOrder((int)(this->Position.y)); // 设置渲染顺序
|
||||
}
|
||||
this->Position = RealPos;
|
||||
Actor::SetPos({this->Position.x, this->Position.y - this->Position.z});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
#include "EngineFrame/Actor/Actor.h"
|
||||
#include "Asset/Common/ObjectVars.h"
|
||||
class GameMap;
|
||||
class BaseObject : public Actor
|
||||
{
|
||||
private:
|
||||
@@ -8,6 +9,7 @@ private:
|
||||
public:
|
||||
VecFPos3 Position; // 位置
|
||||
int Direction = 0; // 方向
|
||||
GameMap *_AffMap = nullptr; // 所在地图
|
||||
|
||||
public:
|
||||
BaseObject(/* args */);
|
||||
|
||||
Reference in New Issue
Block a user