2dkg/2dkg_zad5/2dgk_zad5/KCamera.h
2022-01-20 08:52:14 +01:00

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;
};
}