feat: 实现游戏摄像机控制器并优化地图系统
重构地图系统,增加摄像机控制器管理相机行为。主要变更包括: - 新增 GameCameraController 类,支持跟随目标和调试模式 - 重构 GameMap 类,分离相机逻辑到控制器 - 优化地图资源加载和同步逻辑 - 改进动画系统的事件处理 - 添加地图测试场景用于快速验证
This commit is contained in:
53
Game/include/Camera/GameCameraController.h
Normal file
53
Game/include/Camera/GameCameraController.h
Normal file
@@ -0,0 +1,53 @@
|
||||
#pragma once
|
||||
|
||||
#include <frostbite2D/2d/actor.h>
|
||||
#include <frostbite2D/types/type_math.h>
|
||||
|
||||
struct _SDL_GameController;
|
||||
typedef struct _SDL_GameController SDL_GameController;
|
||||
|
||||
namespace frostbite2D {
|
||||
|
||||
class GameMap;
|
||||
|
||||
class GameCameraController {
|
||||
public:
|
||||
GameCameraController() = default;
|
||||
~GameCameraController();
|
||||
|
||||
void SetMap(GameMap* map);
|
||||
void SetTarget(Actor* target);
|
||||
void ClearTarget();
|
||||
|
||||
void SetDebugEnabled(bool enabled);
|
||||
bool IsDebugEnabled() const { return debugEnabled_; }
|
||||
|
||||
void SetZoom(float zoom);
|
||||
float GetZoom() const { return zoom_; }
|
||||
|
||||
void SetFocus(const Vec2& focus);
|
||||
const Vec2& GetFocus() const { return focus_; }
|
||||
|
||||
void SnapToDefaultFocus();
|
||||
void Update(float deltaTime);
|
||||
|
||||
private:
|
||||
void openDebugController();
|
||||
void closeDebugController();
|
||||
void updateDebugInput(float deltaTime);
|
||||
void applyFocus() const;
|
||||
|
||||
GameMap* map_ = nullptr;
|
||||
Actor* target_ = nullptr;
|
||||
SDL_GameController* debugController_ = nullptr;
|
||||
Vec2 focus_ = Vec2::Zero();
|
||||
|
||||
bool debugEnabled_ = false;
|
||||
bool initialized_ = false;
|
||||
|
||||
float zoom_ = 1.2f;
|
||||
float followLerpSpeed_ = 8.0f;
|
||||
float debugMoveSpeed_ = 800.0f;
|
||||
};
|
||||
|
||||
} // namespace frostbite2D
|
||||
Reference in New Issue
Block a user