From 3a7afe366b0be963239d16e4fac5e5ddbc3a7756 Mon Sep 17 00:00:00 2001 From: a dinosaur Date: Sun, 22 Sep 2024 01:04:59 +1000 Subject: [PATCH] minor improvements --- Sources/CppBackend/ball.cpp | 2 -- Sources/CppBackend/ball.hpp | 6 +++--- Sources/SwiftFrontend/Application.swift | 4 ++-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Sources/CppBackend/ball.cpp b/Sources/CppBackend/ball.cpp index 2022a05..6078a2b 100644 --- a/Sources/CppBackend/ball.cpp +++ b/Sources/CppBackend/ball.cpp @@ -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 { balls.emplace_back(Ball{ pos, angle, ballSize }); } diff --git a/Sources/CppBackend/ball.hpp b/Sources/CppBackend/ball.hpp index c006257..51c9144 100644 --- a/Sources/CppBackend/ball.hpp +++ b/Sources/CppBackend/ball.hpp @@ -19,10 +19,10 @@ public: void update(float deltaTime) noexcept; - [[nodiscard]] constexpr const vec2f& position() const noexcept { + [[nodiscard]] constexpr vec2f position() const noexcept { return _position; } - [[nodiscard]] constexpr const vec2f& velocity() const noexcept { + [[nodiscard]] constexpr vec2f velocity() const noexcept { return _velocity; } [[nodiscard]] constexpr const float size() const noexcept { @@ -34,7 +34,7 @@ public: struct BallWorld { std::vector balls; - BallWorld() noexcept; + BallWorld() noexcept = default; virtual ~BallWorld() noexcept = default; void add(Ball::vec2f pos, float angle, float ballSize) noexcept; diff --git a/Sources/SwiftFrontend/Application.swift b/Sources/SwiftFrontend/Application.swift index 654bc41..9cb5e3a 100644 --- a/Sources/SwiftFrontend/Application.swift +++ b/Sources/SwiftFrontend/Application.swift @@ -82,8 +82,8 @@ class Application { for ball in balls.balls { let position = ball.position(), size = ball.size() var rect = SDL_FRect( - x: position.pointee.x - size, - y: position.pointee.y - size, + x: position.x - size, + y: position.y - size, w: size * 2.0, h: size * 2.0 )