Add progress ball object code.

This commit is contained in:
Joey de Vries
2020-04-23 12:30:50 +02:00
parent 85af3b93fa
commit 01def67b0d
4 changed files with 98 additions and 9 deletions

View File

@@ -17,12 +17,12 @@ BallObject::BallObject(glm::vec2 pos, float radius, glm::vec2 velocity, Texture2
glm::vec2 BallObject::Move(float dt, unsigned int window_width)
{
// If not stuck to player board
// if not stuck to player board
if (!this->Stuck)
{
// Move the ball
// move the ball
this->Position += this->Velocity * dt;
// Then check if outside window bounds and if so, reverse velocity and restore at correct position
// then check if outside window bounds and if so, reverse velocity and restore at correct position
if (this->Position.x <= 0.0f)
{
this->Velocity.x = -this->Velocity.x;
@@ -42,7 +42,7 @@ glm::vec2 BallObject::Move(float dt, unsigned int window_width)
return this->Position;
}
// Resets the ball to initial Stuck Position (if ball is outside window bounds)
// resets the ball to initial Stuck Position (if ball is outside window bounds)
void BallObject::Reset(glm::vec2 position, glm::vec2 velocity)
{
this->Position = position;