This class is used to create and control each of the balls.
More...
#include "source/cannonball.h"
This class is used to create and control each of the balls.
◆ 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 |
( |
| ) |
|
◆ 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 |
| ) |
|
◆ getdbLOC()
dblXY clsCannonball::getdbLOC |
( |
void |
| ) |
|
◆ getForces()
dblXY clsCannonball::getForces |
( |
void |
| ) |
|
◆ getPhysicalProps()
PP clsCannonball::getPhysicalProps |
( |
void |
| ) |
|
Returns the ball's physical properties
◆ getplace()
LOC clsCannonball::getplace |
( |
void |
| ) |
|
◆ 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 |
| ) |
|
◆ 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 | ) |
|
◆ 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 | ) |
|
◆ togglePause()
void clsCannonball::togglePause |
( |
void |
| ) |
|
◆ 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
◆ updateForces()
void clsCannonball::updateForces |
( |
void |
| ) |
|
Updates all the forces on the ball.
◆ writeInfo()
void clsCannonball::writeInfo |
( |
void |
| ) |
|
Writes information bout the ball to the console
◆ 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: