mirror of
https://github.com/GayPizzaSpecifications/cxx-swift-interop.git
synced 2025-08-03 13:11:31 +00:00
43 lines
885 B
C++
43 lines
885 B
C++
#pragma once
|
|
|
|
#include <simd/simd.h>
|
|
#include <vector>
|
|
|
|
struct Ball {
|
|
using vec2f = simd::float2;
|
|
|
|
private:
|
|
constexpr static float speed = 80.0f;
|
|
constexpr static float worldSize = 512.0f;
|
|
|
|
vec2f _position, _velocity;
|
|
float _size;
|
|
|
|
public:
|
|
Ball(vec2f pos, float angle, float ballSize) noexcept;
|
|
virtual ~Ball() noexcept = default;
|
|
|
|
void update(float deltaTime) noexcept;
|
|
|
|
[[nodiscard]] constexpr vec2f position() const noexcept {
|
|
return _position;
|
|
}
|
|
[[nodiscard]] constexpr vec2f velocity() const noexcept {
|
|
return _velocity;
|
|
}
|
|
[[nodiscard]] constexpr const float size() const noexcept {
|
|
return _size;
|
|
}
|
|
};
|
|
|
|
|
|
struct BallWorld {
|
|
std::vector<Ball> balls;
|
|
|
|
BallWorld() noexcept = default;
|
|
virtual ~BallWorld() noexcept = default;
|
|
|
|
void add(Ball::vec2f pos, float angle, float ballSize) noexcept;
|
|
void update(float deltaTime) noexcept;
|
|
};
|