2dkg/2dkg_zad5/2dgk_zad5/KRect.h

40 lines
1.1 KiB
C
Raw Normal View History

2022-01-20 08:52:14 +01:00
#pragma once
#include <SDL_rect.h>
#include "KCollider.h"
namespace KapitanGame {
class KCircle;
class KRect final : public KCollider
{
public:
KRect(KSolid* parent, const float width, const float height)
: KCollider(parent),
Width(width),
Height(height)
{
}
[[nodiscard]] float GetWidth() const override;
[[nodiscard]] float GetHeight() const override;
static KVector2D GetSeparationVector(float left, float right, float top, float bottom);
bool IsCollision(const KCollider* other) const override;
KVector2D GetSeparationVector(const KCollider* other) const override;
[[nodiscard]] KVector2D GetSeparationVector(const SDL_FRect& map) const override;
private:
KVector2D GetSeparationVector(const KCircle* other) const;
KVector2D GetSeparationVector(const KRect* other) const;
bool IsCollision(const KCircle* other) const;
[[nodiscard]] float GetLeft() const;
[[nodiscard]] float GetRight() const;
[[nodiscard]] float GetBottom() const;
[[nodiscard]] float GetTop() const;
bool IsCollision(const KRect* other) const;
float Width;
float Height;
};
}