//
// Created by m on 12/11/21.
//

#ifndef RLA_IIPP_CAMERA_HPP
#define RLA_IIPP_CAMERA_HPP


#include "point.hpp"
#include "rectangle.hpp"
#include <algorithm>

class Camera {
private:
    // center of the camera
    Point center=Point();
    int tiles_rendered_x=0;
    int tiles_rendered_y=0;
    int max_x=0;
    int max_y=0;
    Rectangle cached_bounds=Rectangle();
    Rectangle calculate_bounds();
public:
    Rectangle get_bounds();
    void move_camera(Point new_center);
    void set_bounds(int max_x, int max_y);
    Point camera_coords_to_screen_coords(Point camera_coord);
    Camera()=default;

    Camera(const Point &center, int tilesRenderedX, int tilesRenderedY, int maxX, int maxY) : center(center),
                                                                                              tiles_rendered_x(
                                                                                                      tilesRenderedX),
                                                                                              tiles_rendered_y(
                                                                                                      tilesRenderedY),
                                                                                              max_x(maxX),
                                                                                              max_y(maxY)
    {
        cached_bounds = calculate_bounds();
    }
};


#endif //RLA_IIPP_CAMERA_HPP
