Clove
A Simple Physics Engine to simulate Hooke's law in a 2D environment
Loading...
Searching...
No Matches
Square Class Reference

Draw a Square. More...

#include <Square.h>

Inheritance diagram for Square:
Drawable

Public Member Functions

 Square (float xpos, float ypos)
void draw ()
 Create a square.
void calculateVelocity (float deltaTime)
 Calculates the velocity of an object and it's force.
bool isColliding (Rectangle &rect)
 Collision detection for when the object touches an rectangle object. (In Clove it'll be the platform).
void updateLocation ()
 Update square's location based on factor's such as gravity.
void addBounce ()
 Add bounce to object through inverting position.
std::vector< float > & getVertices ()
 Return reference to vertices vector for general modification uses.
void setVertices (std::vector< float > newVertices)
 Set coordinates of object's vertices.
float getMass () const
 Return object's weight.
void setForce (float newForce)
 Set object's force.
float getForce () const
 Return object's force.
void setApplyForce ()
 Set flag to apply object's mass or not to rectangle.
bool getApplyForce () const
 Get Flag stating whether or not to apply mass to rectangle.
void setFallingFlag (bool newFlag)
 Set Flag stating whether or not object is falling.
bool getFallingFlag () const
 Get Flag stating whether or not object is falling.
int getNumberOfTimesBounced () const
 Get the number of times the object has bounced.
void incrementNumberOfTimesBounced ()
 Increment number of times the object has bounced.
float getVelocity () const
 Return the object's current velocity.
void setVelocity (float newVelocity)
 Update the object's Velocity.
void setIsTouching ()
 Set a flag to determine whether or not a square is touching the platform.
void setDecay (float newDecay)
 Set the object's bounce decay value.
float getDecay () const
 return decay of object's bounce
bool getIsTouching () const
 Get the 'Is touching square' flag.
float & getPositionY ()
Public Member Functions inherited from Drawable
void draw ()

Additional Inherited Members

Protected Attributes inherited from Drawable
std::vector< float > vertices
 Shape Corners.
std::vector< unsigned int > indices
 Use to select specific vertices to draw.
unsigned int numberOfVertices = 0
 How many Vertices we wish to draw.
unsigned int vertexLocation = 0
 Vertex attribute index in Shader.
unsigned int vertexSize = 0
 How many dimensions is the vector.
unsigned int stride = 0
 The space between consectuive vertex attributes (In Bytes).
const void * byteOffset = nullptr
 Offset in VBO.
VAO ArrayObject
VBO BufferObject
EBO ElementBufferObject

Detailed Description

Draw a Square.

Member Function Documentation

◆ calculateVelocity()

void Square::calculateVelocity ( float deltaTime)

Calculates the velocity of an object and it's force.

Parameters
deltaTimeTime between frames

◆ isColliding()

bool Square::isColliding ( Rectangle & rect)

Collision detection for when the object touches an rectangle object. (In Clove it'll be the platform).

Parameters
rectRectangle being operated on

◆ setDecay()

void Square::setDecay ( float newDecay)
inline

Set the object's bounce decay value.

Parameters
newDecayNew decay value

◆ setFallingFlag()

void Square::setFallingFlag ( bool newFlag)
inline

Set Flag stating whether or not object is falling.

Parameters
newFlagNew value for fallingFlag

◆ setForce()

void Square::setForce ( float newForce)
inline

Set object's force.

Parameters
newForceNew force value

◆ setVelocity()

void Square::setVelocity ( float newVelocity)
inline

Update the object's Velocity.

Parameters
newVelocityNew velocity value

◆ setVertices()

void Square::setVertices ( std::vector< float > newVertices)
inline

Set coordinates of object's vertices.

Parameters
newVerticesNew vertices values

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