Creepy-simulation
 
Loading...
Searching...
No Matches
FieldParams.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <list>
4#include <optional>
5
6#include "utils.hpp"
15 std::list<Rectangle> bedrocks_;
16 Rectangle bounds_;
17 std::function<double(Point p1, Point p2)> distanceFunc;
26 [[nodiscard]] static std::optional<Point> checkIntersection(Point unitsOldCoord, Point unitsNewCoord, Point corner1,
27 Point corner2) ;
33 [[nodiscard]] std::vector<Point> getCorners(Rectangle bedrock) const;
34
35 public:
40 [[nodiscard]] auto& getDistanceFunc() { return distanceFunc; }
45 [[nodiscard]] auto& getBounds() { return bounds_; }
52 [[nodiscard]] std::optional<Point> checkIntersections(Point unitsOldCoord, Point unitsNewCoord) const;
58 [[nodiscard]] bool checkInsideBlock(Point coord) const;
64 FieldParams(const Rectangle& bounds, const std::function<double(Point p1, Point p2)>& distanceFunc)
65 : bounds_(bounds), distanceFunc(distanceFunc) {};
70 void setBedrock(const Rectangle& bedrock) { bedrocks_.push_front(bedrock); }
71
72 void deleteBedrock(const Rectangle& bedrock) { bedrocks_.remove(bedrock); }
73};
A class for managing game field parameters.
Definition FieldParams.hpp:14
std::optional< Point > checkIntersections(Point unitsOldCoord, Point unitsNewCoord) const
Checks for intersections of an object's trajectory with any obstacle on the field.
Definition FieldParams.cpp:42
auto & getDistanceFunc()
Retrieves the distance calculation function.
Definition FieldParams.hpp:40
void setBedrock(const Rectangle &bedrock)
Adds a new obstacle to the field.
Definition FieldParams.hpp:70
FieldParams(const Rectangle &bounds, const std::function< double(Point p1, Point p2)> &distanceFunc)
Constructor for the FieldParams class.
Definition FieldParams.hpp:64
bool checkInsideBlock(Point coord) const
Checks if a point is inside an obstacle.
Definition FieldParams.cpp:58
auto & getBounds()
Retrieves the field boundaries.
Definition FieldParams.hpp:45
void deleteBedrock(const Rectangle &bedrock)
Definition FieldParams.hpp:72
Represents a 2D point with x and y coordinates.
Definition utils.hpp:10
Represents a rectangle defined by two points: bottom-left and top-right.
Definition utils.hpp:24