Physics-Simulator  v1.4.0-beta.2
clsCannonball Class Reference

This class is used to create and control each of the balls. More...

#include "source/cannonball.h"

Public Member Functions

 clsCannonball ()
 
 ~clsCannonball ()
 
void setValues (double, LOC, double, double, int)
 
LOC getplace (void)
 
LOC getScreenPlace (void)
 
void setplace (LOC)
 
void update (double)
 
void updateForces (void)
 
dblXY getVelocity (void)
 
dblXY getForces (void)
 
void setVelocity (dblXY)
 
PP getPhysicalProps (void)
 
void setPhysicalProps (PP)
 
BOX getBOX (void)
 
void writeInfo (void)
 
void togglePause (void)
 
bool isPaused (void)
 
void checkEdges (void)
 
void setEdgePosition (void)
 
void addForce (dblXY)
 
dblXY getdbLOC (void)
 
void setdbLOC (dblXY)
 

Public Attributes

bool blnstarted_
 
bool blncheckphysics_
 

Detailed Description

This class is used to create and control each of the balls.

Constructor & Destructor Documentation

◆ clsCannonball()

clsCannonball::clsCannonball ( )

The default Constructor for the cannonballs. It has to call the values as default so we can create it in the array. The values are changed later. The default values are as follows:

  • deltat = 1 / 60 (for 60 fps)
  • acc.x = 0
  • acc.y = Global::Physics::fGravity
  • props.radius = 5
  • props.density = Global::Physics::uBallDensity
  • place = 0
  • dblLoc = place casted as a double
  • Vel = 0

◆ ~clsCannonball()

clsCannonball::~clsCannonball ( )

Member Function Documentation

◆ addForce()

void clsCannonball::addForce ( dblXY  newforces)

◆ checkEdges()

void clsCannonball::checkEdges ( void  )

Checks and does stuff if ball is colliding with edges.

◆ getBOX()

BOX clsCannonball::getBOX ( void  )

Returns the ball's box

◆ getdbLOC()

dblXY clsCannonball::getdbLOC ( void  )

◆ getForces()

dblXY clsCannonball::getForces ( void  )

Returns forces on ball.

◆ getPhysicalProps()

PP clsCannonball::getPhysicalProps ( void  )

Returns the ball's physical properties

◆ getplace()

LOC clsCannonball::getplace ( void  )

Returns the ball's place

◆ getScreenPlace()

LOC clsCannonball::getScreenPlace ( void  )

Returns center of ball in terms of screen coordinates

◆ getVelocity()

dblXY clsCannonball::getVelocity ( void  )

Returns the ball's velocity

◆ isPaused()

bool clsCannonball::isPaused ( void  )

Returns if paused or not

◆ setdbLOC()

void clsCannonball::setdbLOC ( dblXY  newplace)

◆ setEdgePosition()

void clsCannonball::setEdgePosition ( void  )

Set position if colliding with edges

◆ setPhysicalProps()

void clsCannonball::setPhysicalProps ( PP  newprops)

Set the ball's physical properties (only used on CollidePerfectInelastic)

◆ setplace()

void clsCannonball::setplace ( LOC  newplace)

Set the ball's place

◆ setValues()

void clsCannonball::setValues ( double  r,
LOC  init_place,
double  init_vel,
double  init_angle,
int  newID 
)

Changes the values of the ball to whatever is entered.

Parameters
r= radius of the ball.
init_place= its starting location.
init_vel= its starting velocity.
init_angle= its starting angle (in radians).
Returns
void

◆ setVelocity()

void clsCannonball::setVelocity ( dblXY  newvel)

Sets the ball's velocity

◆ togglePause()

void clsCannonball::togglePause ( void  )

Enable/disable pause

◆ update()

void clsCannonball::update ( double  newdeltat)

This will do the following:

  • Update ball's position
  • Update ball's velocity
  • Call clsCannonball::dragUpdateAcc if blnDragEnabled is true
  • Log the ball's location (if enabled)
  • Update CollisionBox
  • Set the ball's blnstarted to false (stopping future updates) if total velocity is less than Global::Physics::fMinVelocity or equals NaN
Parameters
newdeltat= the time (in seconds) that have passed since the last update (see tick.cpp)
Returns
void
Here is the call graph for this function:

◆ updateForces()

void clsCannonball::updateForces ( void  )

Updates all the forces on the ball.

Here is the call graph for this function:

◆ writeInfo()

void clsCannonball::writeInfo ( void  )

Writes information bout the ball to the console

Member Data Documentation

◆ blncheckphysics_

bool clsCannonball::blncheckphysics_

If physics should be checked. It is disabled if the ball collides, so that when looping through all of the balls, it doesn't mark the same collision twice

◆ blnstarted_

bool clsCannonball::blnstarted_

Whether or not the ball is "started" if it is, the program will update it and won't let a new ball replace it in its array spot.


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