Vigilante Game Framework  1.0.0.8
A 2D/3D C++ Game Framework using SFML.
Public Types | Public Member Functions | List of all members
VPath Class Reference

The path setting class. More...

#include <VPath.h>

Public Types

enum  VPathType { LINE, CURVE, NUMPATHTYPES }
 The types of paths to use. More...
 

Public Member Functions

void SetPath (const std::vector< sf::Vector2f > &points)
 
void AddPoint (sf::Vector2f point)
 
void RemovePoint (unsigned int index)
 
void ClearPath ()
 Ckears the entire list of points, effectively removing the path.
 
int GetNumPoints ()
 
bool IsActive ()
 
void SetPathType (VPathType pathType)
 
VPathType GetPathType ()
 
void SetSpeed (float speed)
 
float GetSpeed ()
 
void SetUpdateAngle (bool active)
 
void SetInterpolationType (VInterpolate::VInterpolateType type)
 
VInterpolate::VInterpolateType GetInterpolationType ()
 
void StartFollowing (VObject *object, std::function< void()> onComplete)
 
void StopFollowing ()
 Stops the object from following the path. Good for any sudden events.
 
sf::Vector2f GetPoint (float t)
 
void Update (float dt)
 
void Draw (sf::RenderTarget &RenderTarget)
 

Detailed Description

The path setting class.

Member Enumeration Documentation

◆ VPathType

The types of paths to use.

Enumerator
LINE 

Follows a straight line between each point.

CURVE 

Follows a curved path based on all defined points.

Member Function Documentation

◆ AddPoint()

void VPath::AddPoint ( sf::Vector2f  point)

Add a point to the end of the path.

Parameters
pointThe point to add to the end of the path.

◆ Draw()

void VPath::Draw ( sf::RenderTarget &  RenderTarget)

Render the path (useful for debugging purposes).

Parameters
RenderTargetThe Render Target to render the path towards.

◆ GetInterpolationType()

VInterpolate::VInterpolateType VPath::GetInterpolationType ( )
Returns
The current type of interpolation function being used for the object following the path.

◆ GetNumPoints()

int VPath::GetNumPoints ( )
Returns
The number of points currently in the path.

◆ GetPathType()

VPathType VPath::GetPathType ( )
Returns
The current path type.

◆ GetPoint()

sf::Vector2f VPath::GetPoint ( float  t)

Gets an exact point in the entire path from a single point in time.

Parameters
tThe position in the point as a point in time. T has to be between 0 and 1.

◆ GetSpeed()

float VPath::GetSpeed ( )
Returns
The current speed of following the path.

◆ IsActive()

bool VPath::IsActive ( )
Returns
True if the current path is being actively used by an object.

◆ RemovePoint()

void VPath::RemovePoint ( unsigned int  index)

Remove a point from the path.

Parameters
indexThe element in the list of points to remove from the path, has to be within range 0 to (size-1).

◆ SetInterpolationType()

void VPath::SetInterpolationType ( VInterpolate::VInterpolateType  type)

Sets the kind of interpolation to use for the object following the path, uses the VInterpolate class. The default is Linear.

Parameters
typeThe type of interpolation to use.

◆ SetPath()

void VPath::SetPath ( const std::vector< sf::Vector2f > &  points)

Sets a path based on a list of points.

Parameters
pointsThe list of points to set the path. Path follows the points in order of the list.

◆ SetPathType()

void VPath::SetPathType ( VPathType  pathType)

Sets the type of path. See VPathType for reference.

Parameters
pathTypeThe type of path to set.

◆ SetSpeed()

void VPath::SetSpeed ( float  speed)

Sets the speed of the current path, defined as 1 / time. Default value is 1, which assumes the object will complete the path in one second. 0.5 = 2 seconds. 2 = 0.5 seconds, etc.

Parameters
speedThe new speed of the path following.

◆ SetUpdateAngle()

void VPath::SetUpdateAngle ( bool  active)

Sets whether the object following the path should update its angle. Assumes that the object is facing right when angle is 0.

Parameters
activeWhether updating the angle is active or not.

◆ StartFollowing()

void VPath::StartFollowing ( VObject object,
std::function< void()>  onComplete 
)

Activates the path to be followed. It also resets the path to the beginning of each call.

Parameters
objectThe game object that should follow the path. This can be NULL.
onCompleteFunction that calls once the object has completed travelling along the path.

◆ Update()

void VPath::Update ( float  dt)

Updates the Path following.

Parameters
dtDelta Time between the previous and current frame.

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