diff --git a/CMakeLists.txt b/CMakeLists.txt index fecfbf9..0ddc4c4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,7 +25,6 @@ add_executable(Pong main.cpp SdlWrapper.h Game.h VisibleObjects/Ball.h - utils.h Vec2d/Vec2d.h Vec2d/Bump.h VisibleObjects/PlayerPaddle.h diff --git a/VisibleObjects/Ball.h b/VisibleObjects/Ball.h index 2d93d7c..ffac56e 100644 --- a/VisibleObjects/Ball.h +++ b/VisibleObjects/Ball.h @@ -3,7 +3,6 @@ // #pragma once -#include "../utils.h" #include "../Vec2d/Vec2d.h" #include "PlayerPaddle.h" #include diff --git a/utils.h b/utils.h deleted file mode 100644 index cfbc783..0000000 --- a/utils.h +++ /dev/null @@ -1,57 +0,0 @@ -// -// Created by love on 2024-01-18. -// - -#pragma once - -#include "SDL.h" - - -int roundUpToMultipleOfEight(int v) { - return (v + (8 - 1)) & -8; -} - -// https://stackoverflow.com/questions/38334081/how-to-draw-circles-arcs-and-vector-graphics-in-sdl -void DrawCircle(SDL_Renderer *renderer, SDL_Point ¢er, int radius) { - // 35 / 49 is a slightly biased approximation of 1/sqrt(2) - const int arrSize = roundUpToMultipleOfEight(radius * 8 * 35 / 49); - SDL_Point points[arrSize]; - int drawCount = 0; - - const int32_t diameter = (radius * 2); - - int32_t x = (radius - 1); - int32_t y = 0; - int32_t tx = 1; - int32_t ty = 1; - int32_t error = (tx - diameter); - - while (x >= y) { - // Each of the following renders an octant of the circle - points[drawCount + 0] = {center.x + x, center.y - y}; - points[drawCount + 1] = {center.x + x, center.y + y}; - points[drawCount + 2] = {center.x - x, center.y - y}; - points[drawCount + 3] = {center.x - x, center.y + y}; - points[drawCount + 4] = {center.x + y, center.y - x}; - points[drawCount + 5] = {center.x + y, center.y + x}; - points[drawCount + 6] = {center.x - y, center.y - x}; - points[drawCount + 7] = {center.x - y, center.y + x}; - - drawCount += 8; - - if (error <= 0) { - ++y; - error += ty; - ty += 2; - } - - if (error > 0) { - --x; - tx += 2; - error += (tx - diameter); - } - } - - SDL_RenderDrawPoints(renderer, points, drawCount); -} -