breakout/include/Util.h

40 lines
753 B
C

#pragma once
#include <SFML/Graphics.hpp>
struct Color
{
Color() = default;
Color(float r_in, float g_in, float b_in, float a_in = 1.0f)
: r(r_in)
, g(g_in)
, b(b_in)
, a(a_in)
{ }
Color(sf::Color color_in)
: r((float)color_in.r / 255.f)
, g((float)color_in.g / 255.f)
, b((float)color_in.b / 255.f)
, a((float)color_in.a / 255.f)
{ }
float r{};
float g{};
float b{};
float a{};
sf::Color sfml()
{
return sf::Color{uint8_t(r * 255), uint8_t(g * 255), uint8_t(b * 255), uint8_t(a * 255)};
}
float* imgui()
{
return &r;
}
};
sf::Vector2f getOverlap(sf::FloatRect first, sf::FloatRect second);
sf::Vector2f velocityInRandomDir(float speed_in);
sf::Vector2f velocityInDirection(float speed_in, sf::Angle angle_in);