aboutsummaryrefslogtreecommitdiffstats
path: root/src/graphics.c
diff options
context:
space:
mode:
authorkotorifan <kotorifan05@gmail.com>2026-04-27 17:02:49 +0200
committerkotorifan <kotorifan05@gmail.com>2026-04-27 17:02:49 +0200
commit1ff5ed07b840f4f5de81592f7a9b04debf38c447 (patch)
treea25b2cccd860522d944f1e19fd186462ff842a9c /src/graphics.c
parentc8ec0d2d0c57c42499f9ea95ef0ddd6ef3764f26 (diff)
downloadtrashbinphysics-1ff5ed07b840f4f5de81592f7a9b04debf38c447.tar.gz
SAT works now
Diffstat (limited to 'src/graphics.c')
-rw-r--r--src/graphics.c32
1 files changed, 13 insertions, 19 deletions
diff --git a/src/graphics.c b/src/graphics.c
index 60ad4ff..0f31d6a 100644
--- a/src/graphics.c
+++ b/src/graphics.c
@@ -1,10 +1,15 @@
-// graphics.c
+/**
+ * @file graphics.c
+ * @brief All things related to graphics
+ * @date 2026-04-27
+ */
#include <raylib.h>
#include <stdint.h>
#include <stdio.h>
#include "graphics.h"
#include "common.h"
+
void init_graphics(uint32_t x, uint32_t y, const char* title)
{
InitWindow(x, y, title);
@@ -33,28 +38,17 @@ void clear_graphics(const Color color)
void draw_graphics_object(const object_t* obj)
{
- const Color color = obj->color;
- if(!obj->registered) return;
-
- Vector2 pos = obj->pos;
+ // shapes smaller than 3 don't make sense
+ if(obj->vertices == NULL || obj->vertex_n < 3) return;
- switch(obj->obj_type) {
- case SHAPE_CIRCLE:
- DrawCircleV(pos, obj->size_x/2.0f, color);
- break;
- case SHAPE_SQUARE:
- DrawRectangleV(
- (Vector2){pos.x - obj->size_x/2, pos.y - obj->size_y/2},
- (Vector2){obj->size_x, obj->size_y}, color);
- break;
- case SHAPE_RECTANGLE:
- DrawRectangleV(
- (Vector2){pos.x - obj->size_x/2, pos.y - obj->size_y/2},
- (Vector2){obj->size_x, obj->size_y}, color);
- break;
+ for(u32 iter = 0; iter < obj->vertex_n; iter++) {
+ Vector2 start = obj->vertices[iter];
+ Vector2 end = obj->vertices[(iter + 1) % obj->vertex_n];
+ DrawLineEx(start, end, obj->line_thickness, obj->color);
}
}
+
void draw_graphics_objects(const object_t* world, uint32_t count)
{
for (uint32_t iter = 0; iter < count; iter++)