minor improvements

This commit is contained in:
2024-09-22 01:04:59 +10:00
parent 77603b582c
commit 3a7afe366b
3 changed files with 5 additions and 7 deletions

View File

@ -30,8 +30,6 @@ void Ball::update(float deltaTime) noexcept {
} }
BallWorld::BallWorld() noexcept : balls() {}
void BallWorld::add(Ball::vec2f pos, float angle, float ballSize) noexcept { void BallWorld::add(Ball::vec2f pos, float angle, float ballSize) noexcept {
balls.emplace_back(Ball{ pos, angle, ballSize }); balls.emplace_back(Ball{ pos, angle, ballSize });
} }

View File

@ -19,10 +19,10 @@ public:
void update(float deltaTime) noexcept; void update(float deltaTime) noexcept;
[[nodiscard]] constexpr const vec2f& position() const noexcept { [[nodiscard]] constexpr vec2f position() const noexcept {
return _position; return _position;
} }
[[nodiscard]] constexpr const vec2f& velocity() const noexcept { [[nodiscard]] constexpr vec2f velocity() const noexcept {
return _velocity; return _velocity;
} }
[[nodiscard]] constexpr const float size() const noexcept { [[nodiscard]] constexpr const float size() const noexcept {
@ -34,7 +34,7 @@ public:
struct BallWorld { struct BallWorld {
std::vector<Ball> balls; std::vector<Ball> balls;
BallWorld() noexcept; BallWorld() noexcept = default;
virtual ~BallWorld() noexcept = default; virtual ~BallWorld() noexcept = default;
void add(Ball::vec2f pos, float angle, float ballSize) noexcept; void add(Ball::vec2f pos, float angle, float ballSize) noexcept;

View File

@ -82,8 +82,8 @@ class Application {
for ball in balls.balls { for ball in balls.balls {
let position = ball.position(), size = ball.size() let position = ball.position(), size = ball.size()
var rect = SDL_FRect( var rect = SDL_FRect(
x: position.pointee.x - size, x: position.x - size,
y: position.pointee.y - size, y: position.y - size,
w: size * 2.0, w: size * 2.0,
h: size * 2.0 h: size * 2.0
) )