Definition at line 118 of file pong.cpp.
◆ Ball()
| anonymous_namespace{pong.cpp}::Ball::Ball |
( |
const glm::vec3 & | pos, |
|
|
const glm::vec3 & | vel, |
|
|
float | r ) |
|
inlineexplicit |
◆ modelMatrix()
| glm::mat4 anonymous_namespace{pong.cpp}::Ball::modelMatrix |
( |
| ) |
const |
|
inlinenodiscard |
Definition at line 150 of file pong.cpp.
150 {
151 glm::mat4 model(1.0f);
152 model = glm::translate(model,
position);
154 model = glm::scale(model, glm::vec3(
radius));
155 return model;
156 }
glm::quat rollingOrientation
◆ resetBall()
| void anonymous_namespace{pong.cpp}::Ball::resetBall |
( |
| ) |
|
|
inline |
Definition at line 133 of file pong.cpp.
133 {
134 position = glm::vec3(0.0f, 0.0f, 0.0f);
136 const float angle = glm::radians(static_cast<float>(std::rand() % 120 - 60));
138
139 float vx = std::cos(angle);
140 float vy = std::sin(angle);
141
142 if (std::abs(vx) < 0.5f) {
143 vx = (vx < 0.0f) ? -0.5f : 0.5f;
144 }
145
146 vx *= (std::rand() % 2 == 0) ? 1.0f : -1.0f;
148 }
◆ update()
| void anonymous_namespace{pong.cpp}::Ball::update |
( |
float | deltaTime, |
|
|
Paddle & | paddle1, |
|
|
Paddle & | paddle2, |
|
|
int & | score1, |
|
|
int & | score2 ) |
|
inline |
Definition at line 158 of file pong.cpp.
158 {
162
163 const glm::vec3 movement =
velocity * deltaTime;
164 updateRollingOrientation(movement);
166
177 }
178
179 handlePaddleCollision(paddle1);
180 handlePaddleCollision(paddle2);
181
183 ++score2;
185 return;
186 }
188 ++score1;
190 }
191 }
◆ hitPaddle1
| bool anonymous_namespace{pong.cpp}::Ball::hitPaddle1 = false |
◆ hitPaddle2
| bool anonymous_namespace{pong.cpp}::Ball::hitPaddle2 = false |
◆ hitWall
| bool anonymous_namespace{pong.cpp}::Ball::hitWall = false |
◆ lastImpactPos
| glm::vec3 anonymous_namespace{pong.cpp}::Ball::lastImpactPos {0.0f} |
◆ position
| glm::vec3 anonymous_namespace{pong.cpp}::Ball::position |
◆ radius
| float anonymous_namespace{pong.cpp}::Ball::radius = 0.05f |
◆ rollingOrientation
| glm::quat anonymous_namespace{pong.cpp}::Ball::rollingOrientation {1.0f, 0.0f, 0.0f, 0.0f} |
Definition at line 128 of file pong.cpp.
128{1.0f, 0.0f, 0.0f, 0.0f};
◆ speed
| float anonymous_namespace{pong.cpp}::Ball::speed = 1.0f |
◆ velocity
| glm::vec3 anonymous_namespace{pong.cpp}::Ball::velocity |
The documentation for this class was generated from the following file: