Creepy-simulation
 
Loading...
Searching...
No Matches
FieldParams Class Reference

A class for managing game field parameters. More...

#include <FieldParams.hpp>

Public Member Functions

auto & getDistanceFunc ()
 Retrieves the distance calculation function.
 
auto & getBounds ()
 Retrieves the field boundaries.
 
std::optional< PointcheckIntersections (Point unitsOldCoord, Point unitsNewCoord) const
 Checks for intersections of an object's trajectory with any obstacle on the field.
 
bool checkInsideBlock (Point coord) const
 Checks if a point is inside an obstacle.
 
 FieldParams (const Rectangle &bounds, const std::function< double(Point p1, Point p2)> &distanceFunc)
 Constructor for the FieldParams class.
 
void setBedrock (const Rectangle &bedrock)
 Adds a new obstacle to the field.
 
void deleteBedrock (const Rectangle &bedrock)
 

Detailed Description

A class for managing game field parameters.

FieldParams provides functionality to define field boundaries, add obstacles, and check object collisions with these obstacles.

Constructor & Destructor Documentation

◆ FieldParams()

FieldParams::FieldParams ( const Rectangle bounds,
const std::function< double(Point p1, Point p2)> &  distanceFunc 
)
inline

Constructor for the FieldParams class.

Parameters
boundsThe boundaries of the game field.
distanceFuncA function to calculate the distance between points.

Member Function Documentation

◆ checkInsideBlock()

bool FieldParams::checkInsideBlock ( Point  coord) const

Checks if a point is inside an obstacle.

Parameters
coordThe coordinates of the point.
Returns
true if the point is inside an obstacle, false otherwise.

◆ checkIntersections()

std::optional< Point > FieldParams::checkIntersections ( Point  unitsOldCoord,
Point  unitsNewCoord 
) const

Checks for intersections of an object's trajectory with any obstacle on the field.

Parameters
unitsOldCoordThe old coordinates of the object.
unitsNewCoordThe new coordinates of the object.
Returns
The intersection point or std::nullopt if no intersection occurs.

◆ deleteBedrock()

void FieldParams::deleteBedrock ( const Rectangle bedrock)
inline

◆ getBounds()

auto & FieldParams::getBounds ( )
inline

Retrieves the field boundaries.

Returns
A reference to the Rectangle object representing the field boundaries.

◆ getDistanceFunc()

auto & FieldParams::getDistanceFunc ( )
inline

Retrieves the distance calculation function.

Returns
A reference to the function.

◆ setBedrock()

void FieldParams::setBedrock ( const Rectangle bedrock)
inline

Adds a new obstacle to the field.

Parameters
bedrockA rectangle representing the obstacle.

The documentation for this class was generated from the following files: