The object manager.
More...
#include <ObjectManager.h>
|
|
Sage::CParticleDesc2D | m_cPDesc0 |
| | Particle descriptor for balls in step mode.
|
| |
|
Sage::CParticleDesc2D | m_cPDesc1 |
| | Particle descriptor for collisions in step mode.
|
| |
|
Sage::CParticleDesc2D | m_cPDesc2 |
| | Particle descriptor for collisions in real-time mode.
|
| |
|
CObject * | m_pCueBall = nullptr |
| | Cue ball object pointer.
|
| |
|
CObject * | m_p8Ball = nullptr |
| | 8 ball object pointer.
|
| |
|
float | m_fCueAngle = 0 |
| | Cue ball impulse angle.
|
| |
|
bool | m_bDrawImpulseVector = true |
| | Whether to draw the impulse vector.
|
| |
|
|
static Sage::CSpriteRenderer * | m_pRenderer = nullptr |
| | Pointer to the renderer.
|
| |
|
static CObjectManager * | m_pObjectManager = nullptr |
| | Pointer to the object manager.
|
| |
|
static Sage::CParticleEngine2D * | m_pParticleEngine = nullptr |
| | Pointer to particle engine.
|
| |
|
static bool | m_bShowCollisions = false |
| | Show ball positions at TOI.
|
| |
|
static bool | m_bStepMode = false |
| | Is in step mode.
|
| |
|
static bool | m_bStep = false |
| | Step flag.
|
| |
|
static float | m_fXMargin = 78.0f |
| | Horizontal margin.
|
| |
|
static float | m_fYMargin = 64.0f |
| | Vertical margin.
|
| |
|
static Vector2 | m_vMargin = Vector2(m_fXMargin, m_fYMargin) |
| | Margins.
|
| |
|
static Vector2 | m_vTopLPocket = Vector2(71, 478) |
| | Position of top left pocket.
|
| |
|
static Vector2 | m_vTopRPocket = Vector2(955, 478) |
| | Position of top right pocket.
|
| |
|
static Vector2 | m_vTopCPocket = Vector2(514, 478) |
| | Position of top center pocket.
|
| |
|
static Vector2 | m_vBotLPocket = Vector2(71, 53) |
| | Position of bottom left pocket.
|
| |
|
static Vector2 | m_vBotRPocket = Vector2(955, 53) |
| | Position of bottom right pocket.
|
| |
|
static Vector2 | m_vBotCPocket = Vector2(514, 48) |
| | Position of bottom center pocket.
|
| |
A managed collection of all of the game objects.
◆ CObjectManager()
| CObjectManager::CObjectManager |
( |
| ) |
|
Initialize the sprite descriptors for the circle and thick circle particles used to show discrete motion and collision points.
◆ ~CObjectManager()
| CObjectManager::~CObjectManager |
( |
| ) |
|
Delete the cue-ball and 8-ball objects.
◆ AdjustCueBall()
| void CObjectManager::AdjustCueBall |
( |
float | d | ) |
|
Adjust the cue ball up or down on the base line, being careful stop it at the horizontal rails. This should only be used in eGameState::Initial, but no check is made here.
- Parameters
-
◆ AdjustImpulseVector()
| void CObjectManager::AdjustImpulseVector |
( |
float | a | ) |
|
Adjust the angle of the impulse vector. This should only be used in eGameState::Initial or eGameState::SetupShot, but no check is made here.
- Parameters
-
| a | Amount to add to the angle of the impulse vector. |
◆ AllStopped()
| bool CObjectManager::AllStopped |
( |
| ) |
|
Check whether both the cue-ball and the 8-ball have stopped moving. Notice that we can set the velocity vector to the zero vector and expect it to succeed because CObject::move zeros out the velocity of slow-moving objects.
- Returns
- true If both balls have stopped moving.
◆ BallDown()
| bool CObjectManager::BallDown |
( |
| ) |
|
Check whether the cue-ball or the 8-ball is in a pocket.
- Returns
- true If one of the balls is in a pocket.
◆ BroadPhase()
| void CObjectManager::BroadPhase |
( |
| ) |
|
|
private |
Collision detection and response for all balls against each other and the rails and pockets. We do pocket collision for all balls first to remove them from the subsequent calculations.
◆ Clear()
| void CObjectManager::Clear |
( |
| ) |
|
Delete all of the objects in the game. Ideally this should consist of a switch statement, but there are only two objects here, the cue-ball and the 8-ball.
◆ Create()
| void CObjectManager::Create |
( |
eSprite | t, |
|
|
const Vector2 & | v ) |
Create an object and save a pointer to it. Ideally this should consist of a switch statement, but there are only two objects here, the cue-ball and the 8-ball.
- Parameters
-
| t | Sprite type. |
| v | Initial position. |
◆ CueBallDown()
| bool CObjectManager::CueBallDown |
( |
| ) |
|
Check whether the cue-ball is down a pocket.
- Returns
- true If the cue-ball is in a pocket.
◆ Draw()
| void CObjectManager::Draw |
( |
| ) |
|
Draw all of the objects in the game, two balls, the directional arrow, and the step mode indicator and the collision indicator if necessary.
◆ Move()
| void CObjectManager::Move |
( |
| ) |
|
Move all of the objects in the object list and perform broad phase collision detection and response. If in Step Mode, drop a particle.
◆ NarrowPhase()
Ball to ball collision detection and response. Deflect the balls in the appropriate directions and speeds, and play a sound at the point of impact at a volume proportional to the relative speed of at time of impact. See Section 5.2.1 of the documentation for details of the geometry used here.
- Parameters
-
| p0 | Pointer to first object. |
| p1 | Pointer to first object. |
◆ PocketCollide()
| void CObjectManager::PocketCollide |
( |
CObject * | b | ) |
|
|
private |
Collision detection and response for ball-in-pocket. Check for a collision and does the necessary housework for disabling a ball that is in a pocket. If there is a collision, a sound is played at a volume proportional to the speed of collision and panned to the left or right according to where the pocket is on the table.
- Parameters
-
| b | Pointer to a ball object to collide with pockets. |
◆ RailCollide()
| void CObjectManager::RailCollide |
( |
CObject * | b | ) |
|
|
private |
Collision detection and response for ball hitting any rail. Check for a collision and do the necessary housework for reflecting the ball if it hits a rail. If there is a collision, a sound is played at a volume proportional to the speed of collision at the point of impact. See Section 5.2.2 of the documentation for details of the geometry used here.
- Parameters
-
| b | Pointer to a ball object to collide with rails. |
◆ ResetImpulseVector()
| void CObjectManager::ResetImpulseVector |
( |
| ) |
|
Make the impulse vector point from the center of the cue-ball to the center of the 8-ball and set it as visible so it gets drawn (assuming that the only reason to reset the impulse vector is because it needs to be drawn).
◆ Shoot()
| void CObjectManager::Shoot |
( |
| ) |
|
Shoot the cue-ball by giving it a fixed impulse. Disable the drawing of the impulse vector and play a sound that is panned left or right depending on where the cue-ball is on the table.