Refactor WorldPos, WindowsPos done
This commit is contained in:
@@ -76,17 +76,17 @@ Window::~Window() {
|
||||
LOG_DEBUG(".");
|
||||
}
|
||||
|
||||
void Window::DrawSprite(const WorldPos &position, Sprite &s) {
|
||||
void Window::DrawSprite(const WindowPos &position, Sprite &s) {
|
||||
WorldPos size = s.GetSize();
|
||||
WorldPos img_center = s.GetCenter();
|
||||
SDL_FRect rect = {position.x - img_center.x, position.y - img_center.y,
|
||||
size.x, size.y};
|
||||
SDL_FRect rect = {position.x() - img_center.x(), position.y() - img_center.y(),
|
||||
size.x(), size.y()};
|
||||
SDL_RenderTexture(m_Renderer.get(), s.GetTexture(), nullptr, &rect);
|
||||
}
|
||||
|
||||
void Window::DrawRect(const WorldPos &position, const WorldPos size, uint8_t R,
|
||||
void Window::DrawRect(const WindowPos &position, const WindowPos size, uint8_t R,
|
||||
uint8_t G, uint8_t B, uint8_t A) {
|
||||
SDL_FRect rect = {position.x, position.y, size.x, size.y};
|
||||
SDL_FRect rect = {position.x(), position.y(), size.x(), size.y()};
|
||||
SDL_SetRenderDrawColor(m_Renderer.get(), R, G, B, A);
|
||||
SDL_RenderFillRect(m_Renderer.get(), &rect);
|
||||
}
|
||||
@@ -98,9 +98,9 @@ void Window::ClearWindow() {
|
||||
|
||||
void Window::Flush() { SDL_RenderPresent(m_Renderer.get()); }
|
||||
|
||||
void Window::DrawCircle(const WorldPos &position, float radius) {
|
||||
int cx = static_cast<int>(position.x);
|
||||
int cy = static_cast<int>(position.y);
|
||||
void Window::DrawCircle(const WindowPos &position, float radius) {
|
||||
int cx = static_cast<int>(position.x());
|
||||
int cy = static_cast<int>(position.y());
|
||||
SDL_SetRenderDrawColor(m_Renderer.get(), 255, 0, 0, 255);
|
||||
for (int i = 0; i < 360; ++i) {
|
||||
double a = i * M_PI / 180.0;
|
||||
@@ -110,9 +110,9 @@ void Window::DrawCircle(const WorldPos &position, float radius) {
|
||||
}
|
||||
}
|
||||
|
||||
void Window::DrawLine(const WorldPos &A, const WorldPos &B)
|
||||
void Window::DrawLine(const WindowPos &A, const WindowPos &B)
|
||||
{
|
||||
SDL_SetRenderDrawColor(m_Renderer.get(), 255, 0, 0, 255);
|
||||
SDL_RenderLine(m_Renderer.get(), A.x, A.y, B.x, B.y);
|
||||
SDL_RenderLine(m_Renderer.get(), A.x(), A.y(), B.x(), B.y());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user