diff --git a/main.cpp b/main.cpp index b6cfce9..30d4635 100644 --- a/main.cpp +++ b/main.cpp @@ -32,18 +32,17 @@ int main(int argc, char** argv) { callbacks::handleCallbacks(&eventHandler); - //SDL_FillRect(surface, NULL, SDL_MapRGB(surface->format, 0, 0, 0)); + ray2D ray = ray2D::trace(vector2(0, 201), vector2(.01, 0)); + ray2D ray2 = ray2D::trace(vector2(201, 0), vector2(0, .01)); - ray2D ray = ray2D::trace(vector2(0, 200), vector2(1, 0)); - //SDL_RenderClear(renderer); SDL_RenderDrawLine(renderer, ray.start.x, ray.start.y, ray.end.x, ray.end.y); - SDL_RenderPresent(renderer); + SDL_RenderDrawLine(renderer, ray2.start.x, ray2.start.y, ray2.end.x, ray2.end.y); - //global::entList.run(surface); - //global::entList3D.run(surface); + global::entList.run(renderer); + global::entList3D.run(renderer); - //SDL_UpdateWindowSurface(window); + SDL_RenderPresent(renderer); SDL_Delay(1); } SDL_DestroyWindow(window); diff --git a/stuff/objects/cube.h b/stuff/objects/cube.h index 3057056..a225ef3 100644 --- a/stuff/objects/cube.h +++ b/stuff/objects/cube.h @@ -14,9 +14,9 @@ struct cube : public square { this->z = z_; } - void run(SDL_Surface* surface) + void run(SDL_Renderer* renderer) { //SDL_Rect rect{ this->x, this->y, this->radius, this->radius }; - //SDL_FillRect(surface, &rect, SDL_MapRGB(surface->format, 0xFF, 0xFF, 0xFF)); + //SDL_RenderFillRect(renderer, &rect); } }; \ No newline at end of file diff --git a/stuff/objects/entityList2D.h b/stuff/objects/entityList2D.h index 0f6d623..c837707 100644 --- a/stuff/objects/entityList2D.h +++ b/stuff/objects/entityList2D.h @@ -9,11 +9,11 @@ entityList2D is the 2D entity container class class entityList2D : public std::vector { public: - void run(SDL_Surface* surface) + void run(SDL_Renderer* renderer) { for (square entity : *this) { - entity.run(surface); + entity.run(renderer); } } }; \ No newline at end of file diff --git a/stuff/objects/entityList3D.h b/stuff/objects/entityList3D.h index 168c59f..daae1e4 100644 --- a/stuff/objects/entityList3D.h +++ b/stuff/objects/entityList3D.h @@ -9,11 +9,11 @@ entityList3D is the 3D entity container class class entityList3D : public std::vector { public: - void run(SDL_Surface* surface) + void run(SDL_Renderer* renderer) { for (cube entity : *this) { - entity.run(surface); + entity.run(renderer); } } }; \ No newline at end of file diff --git a/stuff/objects/ray2D.h b/stuff/objects/ray2D.h index 41a0d6c..804ae57 100644 --- a/stuff/objects/ray2D.h +++ b/stuff/objects/ray2D.h @@ -23,7 +23,7 @@ struct ray2D { for (square object : global::entList) { - if (inRect(point, vector2(object.x - (object.radius / 2), object.y - (object.radius / 2)), vector2(object.x + (object.radius / 2), object.y + (object.radius / 2)))) + if (inRect(point, vector2(object.x, object.y), vector2(object.x + object.radius, object.y + object.radius))) { ray.start = start; ray.end = point; diff --git a/stuff/objects/square.h b/stuff/objects/square.h index 6d9e008..91d3d2c 100644 --- a/stuff/objects/square.h +++ b/stuff/objects/square.h @@ -16,9 +16,9 @@ struct square : public vector2 { this->radius = radius_; } - void run(SDL_Surface* surface) + void run(SDL_Renderer* renderer) { SDL_Rect rect{ this->x, this->y, this->radius, this->radius }; - SDL_FillRect(surface, &rect, SDL_MapRGB(surface->format, 0xFF, 0xFF, 0xFF)); + SDL_RenderFillRect(renderer, &rect); } }; \ No newline at end of file