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

VObject that generates and displays a gradient texture. This is done by generating a pixel-high texture as a gradient line, rendering it to the correct shape and applying it to the texture. More...

#include <VGradient.h>

Inheritance diagram for VGradient:
VObject VBase

Public Types

enum  VGradientType {
  LINEAR, RADIAL, ANGULAR, REFLECTIVE,
  DIAMOND
}
 Types of gradients that could be used (uses the types specified in Adobe Photoshop)
 
typedef VObject VSUPERCLASS
 Used to call parent class functions when they are overrided in class.
 
- Public Types inherited from VObject
enum  SidesTouching : unsigned char {
  TOUCHNONE = 0, TOUCHLEFT = 1 << 0, TOUCHRIGHT = 1 << 1, TOUCHTOP = 1 << 2,
  TOUCHBOTTOM = 1 << 3, TOUCHWALL = TOUCHLEFT | TOUCHRIGHT, TOUCHALL = TOUCHLEFT | TOUCHRIGHT | TOUCHTOP | TOUCHBOTTOM
}
 Flags for which sides are allowed to check if being overlapped for collision purposes.
 
typedef VBase VSUPERCLASS
 Used to call parent class functions when they are overrided in class.
 

Public Member Functions

 VGradient (float x, float y, float width, float height, VGradientType type=VGradientType::LINEAR, float resolution=1024.0f)
 
 VGradient (sf::Vector2f position, sf::Vector2f size=sf::Vector2f(), VGradientType type=VGradientType::LINEAR, float resolution=1024.0f)
 
void AddPoint (float position, const sf::Color &colour)
 
void UpdatePoint (unsigned int index, float position, const sf::Color &colour)
 
void UpdatePointColour (unsigned int index, const sf::Color &colour)
 
void UpdatePointPosition (unsigned int index, float position)
 
void RemovePoint (unsigned int index)
 
void SetType (VGradientType type)
 
void SetResolution (float resolution)
 
virtual void Destroy () override
 Destroys the gradient rendering data (and texture if disposable is set for true).
 
virtual void Draw (sf::RenderTarget &RenderTarget) override
 
- Public Member Functions inherited from VObject
 VObject (sf::Vector2f position, sf::Vector2f size=sf::Vector2f())
 
 VObject (float x=0, float y=0, float width=0, float height=0)
 
void SetPositionAtCentre (float x, float y)
 
void SetPositionAtCentre (sf::Vector2f newPos)
 
bool IsSolid ()
 
virtual void Reset (sf::Vector2f newPos)
 
virtual void Reset (float x, float y)
 
virtual void Hurt (float damage)
 
virtual void Update (float dt)
 
- Public Member Functions inherited from VBase
virtual void Kill ()
 
virtual void Revive ()
 Revives the object by setting both alive and exists back to true.
 

Public Attributes

sf::Vector2f Origin
 Origin of the 9-slice object in percentage (0.0f - 1.0f) for rotation.
 
sf::Color Tint = sf::Color::White
 Colour Tint of the Sprite.
 
sf::Vector2f Scale = sf::Vector2f(1.0f, 1.0f)
 Scale transform.
 
- Public Attributes inherited from VObject
sf::Vector2f Position
 Position of the object.
 
sf::Vector2f Size
 Size of the object.
 
sf::Vector2f Last
 Position of the object on the previous frame.
 
float Radius = 0
 Radius amount for Circle Collisions.
 
float Angle = 0
 Angle of object.
 
float AngleVelocity = 0
 Velocity of rotation.
 
float AngleAcceleration = 0
 Acceleration of rotation.
 
float AngleDrag = 0
 Drag of rotation.
 
float AngleMax = 10000
 Maximum Velocity of rotation.
 
bool Moves = true
 If true, updates the objects position and angle.
 
sf::Vector2f Velocity
 Velocity of movement.
 
sf::Vector2f Acceleration
 Acceleration of movement.
 
sf::Vector2f Drag
 Drag of movement.
 
sf::Vector2f MaxVelocity
 Maximum velocity of movement.
 
sf::Vector2f ScrollFactor
 The amount the object will appear to move when the camera scrolls (1.0f = Scrolls as fast as the camera, 0.5f = Scrolls half as fast as the camera). Good for parallax scrolling.
 
float RotateFactor = 1
 The amount the object will appear to rotate when the camera rotates (1.0f = Rotates as fast as the camera, 0.5f = Rotates half as fast as the camera). Good for parallax scrolling.
 
float ZoomFactor = 1
 The amount the object will appear to scale when the camera zooms (1.0f = Scales as fast as the camera, 0.5f = Scales half as fast as the camera). Good for parallax scrolling.
 
float Elasticity = 0
 Bounciness of the object (0 assumes no bounce)
 
float Mass = 1
 Mass of object in comparison to other objects in world.
 
float Health = 100
 Standard health value (object dies if health is <= 0 when modified in the Hurt function)
 
bool Immovable = false
 If true, the object will not change its velocity on collision.
 
unsigned char Touching = SidesTouching::TOUCHNONE
 Which sides are currently touching (is reset on each Update call!)
 
unsigned char WasTouching = SidesTouching::TOUCHNONE
 Which sides on previous frame were touching (is reset on each Update call!)
 
unsigned char AllowCollisions = SidesTouching::TOUCHALL
 Which sides are allowed to check collisions for.
 
bool CollisionXDrag = true
 Useful for moving platforms.
 
- Public Attributes inherited from VBase
bool active = true
 Base can be updated using Update if true.
 
bool visible = true
 Base can be rendered using Draw if true.
 
bool alive = true
 Helper member that is mainly used filter out behaviours to objects which aren't alive in the scene.
 
bool exists = true
 Base can be updated and rendered if true, else it would no longer be treated as being part of the scene.
 
VType type = NONE
 Base object type, typically set in the constructor of an inherited object to specify what type it is.
 
uint32_t RefCount = 0
 Counts the amount of times the object is referenced in groups, ensures an object is only destroyed when no longer part of a single group.
 

Protected Member Functions

virtual void updateTransform () override
 Update the tranform.
 
virtual void updateFrame ()
 Update the frame.
 
- Protected Member Functions inherited from VObject
virtual void updateMotion (float dt)
 

Protected Attributes

sf::VertexArray vertexArray
 Render infomation.
 
sf::RenderStates renderState
 The render states object.
 
std::vector< std::unique_ptr< VColourPoint > > points
 The colours of the gradient.
 
std::vector< VColourPoint * > sortedPoints
 The colours of the gradient, sorted for rendering purposes.
 
VGradientType gradientType
 The type of gradiant to use.
 
float gradResolution
 Gradient resolution;.
 
sf::RenderTexture renderTex
 Render texture.
 

Additional Inherited Members

- Static Public Member Functions inherited from VObject
static bool separate (VObject *a, VObject *b)
 
static bool separateCircle (VObject *a, VObject *b)
 
static bool touchFlag (VObject *a, VObject *b)
 
static float computeVelocity (float v, float a, float d, float max, float dt)
 
static bool TestInView (const sf::View &renderTargetView, sf::View *defaultView, VObject *o, const sf::FloatRect &renderBox=sf::FloatRect())
 
- Static Public Member Functions inherited from VBase
static const wchar_t * VString (const char *fmt,...)
 
static void VLog (const char *fmt,...)
 
static void VLogError (const char *fmt,...)
 
static void VClearLog ()
 
- Static Public Attributes inherited from VObject
static float SeparateBias
 Adds to the maximum overlap distance between objects.
 

Detailed Description

VObject that generates and displays a gradient texture. This is done by generating a pixel-high texture as a gradient line, rendering it to the correct shape and applying it to the texture.

Constructor & Destructor Documentation

◆ VGradient() [1/2]

VGradient::VGradient ( float  x,
float  y,
float  width,
float  height,
VGradientType  type = VGradientType::LINEAR,
float  resolution = 1024.0f 
)
Parameters
xX position of the sprite.
yY position of the sprite
widthWidth of the sprite (also sets the width of the render area).
heightHeight of the sprite (also sets the height of the render area).
typeType of gradient to use.
resolutionResolution of the generated gradient.

◆ VGradient() [2/2]

VGradient::VGradient ( sf::Vector2f  position,
sf::Vector2f  size = sf::Vector2f(),
VGradientType  type = VGradientType::LINEAR,
float  resolution = 1024.0f 
)
Parameters
positionPosition of the sprite.
sizeSize of the sprite (also sets the size of the render area).
typeType of gradient to use.
resolutionResolution of the generated gradient.

Member Function Documentation

◆ AddPoint()

void VGradient::AddPoint ( float  position,
const sf::Color &  colour 
)

Adds a new gradient point to the gradient strip. Points can be added in any order, and the class will sort them in position order on generation.

Parameters
positionA float between 0.0 and 1.0 to represent where on the initial gradient line should the renderer interpolate to the specified colour.
colourTint of the gradient at the specified position on the gradient line.

◆ Draw()

virtual void VGradient::Draw ( sf::RenderTarget &  RenderTarget)
overridevirtual

Renders the gradient object.

Parameters
RenderTargetThe game's sf::RenderTarget object to render data onto.

Reimplemented from VObject.

◆ RemovePoint()

void VGradient::RemovePoint ( unsigned int  index)

Remove an existing gradient point to the gradient strip.

Parameters
indexThe position in the array of colour indexes.

◆ SetResolution()

void VGradient::SetResolution ( float  resolution)
Parameters
resolutionResolution of the generated gradient.

◆ SetType()

void VGradient::SetType ( VGradientType  type)
Parameters
typeThe types of gradients that could be used (uses the types specified in Adobe Photoshop)

◆ UpdatePoint()

void VGradient::UpdatePoint ( unsigned int  index,
float  position,
const sf::Color &  colour 
)

Update an existing gradient point to the gradient strip.

Parameters
indexThe position in the array of colour indexes.
positionA float between 0.0 and 1.0 to represent where on the initial gradient line should the renderer interpolate to the specified colour.
colourTint of the gradient at the specified position on the gradient line.

◆ UpdatePointColour()

void VGradient::UpdatePointColour ( unsigned int  index,
const sf::Color &  colour 
)

Update the tint of an existing gradient point to the gradient strip.

Parameters
indexThe position in the array of colour indexes.
colourTint of the gradient at the specified position on the gradient line.

◆ UpdatePointPosition()

void VGradient::UpdatePointPosition ( unsigned int  index,
float  position 
)

Update the position of an existing gradient point to the gradient strip.

Parameters
indexThe position in the array of colour indexes.
positionA float between 0.0 and 1.0 to represent where on the initial gradient line should the renderer interpolate to the specified colour.

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