Utility Entities

Being the common denominator dependency of other packages, over time, entities package ended up accumaling certain utility classes.

These Utility Entities are sometimes utilized by manifest entities while being constructed, but also find themselves used in other ways as well.

class Camera

Describes a Camera object.

Public Functions

inline Camera(Vector<float> position, Vector<float> size, Vector<float> safezone_size)

Construct a new Camera object.

Parameters:
  • positionPosition of the camera.

  • size – Size of the complete viewport.

  • safezone_size – Size of the safezone in which the character can move without moving the camera.

inline Camera(Vector<float> position, Vector<float> size)

Construct a new Camera object.

Defaults to a 600x600 safezone.

Parameters:
  • positionPosition of the camera.

  • size – Size of the complete viewport.

inline Camera()

Construct a new Camera object.

Constructs a full hd viewport with a 600x600 safezone.

Rect viewport() const

Get the viewport of the camera.

Viewport denotes the regions visible to the camera within the greater level.

Returns:

Rect Returns the zone as a rectangle.

Rect safezone() const

Get the safezone boundaries of the camera.

Returns:

Rect Rectangle to the safezone boundaries.

const Vector<float> &position() const

Return the position of the camera.

Returns:

const Vector& const ref to the position vector.

const Vector<float> &size() const

Size of the camera viewport.

Returns:

const Vector& Reference to the viewport.

const Vector<float> &safezone_size() const

Size of the safezone.

Returns:

const Vector&

bool contains(const Vector<float> &point) const

Check if camera contains the point.

Parameters:

point – Point to check if inside.

Returns:

true

Returns:

false

bool safezone_contains(const Vector<float> &point) const

Check if the safezone contains the point.

Parameters:

point – Point to check against.

Returns:

true

Returns:

false

void move(const Vector<float> &move_by)

Move the camera by the given vector.

Parameters:

move_by

struct Position

Reperesents position in 2D space.

template<typename T = float>
struct Vector
class Rect

Public Functions

bool contains(float x, float y) const

Evaluate whether or not a certain x, y coord pair falls within this rectangle.

Parameters:
  • x – Horizontal offset of the point.

  • y – Vertical offset of the point.

Returns:

true If the point is within the rectangle.

Returns:

false If the point is outside the rectangle.

Friends

friend Rect operator+(Rect left, const Rect &right)

Create a new rectangle by shifting wrt to the right rectangle.

Shift the left rectangle’s position wrt to the right rectangle’s width and height, ignore the x and y values of the right rectangle, preserve the width and height of the left rectangle.

friend Rect operator-(Rect left, const Rect &right)

Reverse of the +.