mirror of
https://github.com/JoeyDeVries/LearnOpenGL.git
synced 2026-01-11 02:53:23 +08:00
Add progress ball object code.
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user