44 lines
1.0 KiB
C++
44 lines
1.0 KiB
C++
#pragma once
|
|
#include <memory>
|
|
#include <SDL_rect.h>
|
|
#include <vector>
|
|
|
|
#include "Constants.h"
|
|
#include "KVector2d.h"
|
|
|
|
namespace KapitanGame
|
|
{
|
|
class KPawn;
|
|
|
|
class KCamera
|
|
{
|
|
public:
|
|
explicit KCamera(const SDL_FRect& map)
|
|
: Viewport({
|
|
(map.w - Constants::SCREEN_WIDTH) / 2.f, (map.h - Constants::SCREEN_HEIGHT) / 2.f,
|
|
Constants::SCREEN_WIDTH * 1.f,
|
|
Constants::SCREEN_HEIGHT * 1.f
|
|
}), PlayArea({
|
|
0, 0,
|
|
Constants::SCREEN_WIDTH - Constants::WINDOW_DEAD_ZONE,
|
|
Constants::SCREEN_HEIGHT - Constants::WINDOW_DEAD_ZONE
|
|
}), FocusPoint(Viewport.x + Viewport.w / 2, Viewport.y + Viewport.h / 2),
|
|
Scale(1.f)
|
|
{
|
|
}
|
|
|
|
const SDL_FRect& GetViewport() const;
|
|
float GetScale() const;
|
|
const KVector2D& GetFocusPoint() const;
|
|
void Update(const std::vector<std::shared_ptr<KPawn>>& pawns, const SDL_FRect& map);
|
|
void SetDebug(const SDL_FRect& map);
|
|
const SDL_FRect& GetPlayArea() const;
|
|
private:
|
|
SDL_FRect Viewport;
|
|
SDL_FRect PlayArea;
|
|
KVector2D FocusPoint;
|
|
float Scale;
|
|
};
|
|
}
|
|
|