修改渲染底层,新增场景摄像机逻辑,地图可行区域逻辑

This commit is contained in:
2025-10-08 23:58:15 +08:00
parent df2cacdb92
commit 1b011b9b68
23 changed files with 5350 additions and 40 deletions

View File

@@ -1,4 +1,5 @@
#include "GameMapCamera.h"
#include "EngineCore/Game.h"
#include "Actor/Map/GameMap.h"
#include "Actor/Object/BaseObject.h"
#include <algorithm>
@@ -45,10 +46,23 @@ void GameMapCamera::SyncPosByFromParent(float deltaTime)
{
if (this->_FromActor != nullptr)
{
// int R_X, R_Y, R_Z;
// R_X = std::min(std::max(this->_FromActor->X, 533), MovableAreaX - 533);
// R_Y = std::min(std::max(this->_FromActor->Y, 300), MovableAreaY - 300);
// R_Z = 0;
float width_Separate = Game::GetInstance().Screen_W / 2;
float height_Separate = Game::GetInstance().Screen_H / 2;
int R_X, R_Y, R_Z;
R_X = std::fmin(std::fmax(this->_FromActor->Position.x, width_Separate), _ParentMap->_MapLength - width_Separate);
R_Y = std::fmin(std::fmax(this->_FromActor->Position.y, height_Separate), _ParentMap->_MapHeight - height_Separate);
R_Z = 0;
// SDL_Log("R_X: %d, R_Y: %d, R_Z: %d", R_X, R_Y, R_Z);
// SetPos(R_X, R_Y, R_Z);
for (auto Layer : _ParentMap->_LayerMap)
{
if (Layer.first == "distantback")
{
Layer.second->SetPos(VecFPos((-R_X + width_Separate) * BackgroundMoveSpeed, -R_Y + R_Z + height_Separate + 120 + BackgroundOffset));
}
else
Layer.second->SetPos(VecFPos((-R_X + width_Separate), -R_Y + R_Z + height_Separate + 120 + BackgroundOffset));
}
}
}