aboutsummaryrefslogtreecommitdiffstats
path: root/src/graphics.c
diff options
context:
space:
mode:
authorkotorifan <kotorifan05@gmail.com>2026-04-21 19:55:51 +0200
committerkotorifan <kotorifan05@gmail.com>2026-04-21 19:55:51 +0200
commit1efdb8ab18042d9efc7c2e6addf7f414fbee5590 (patch)
tree5ffd6553ab46e5465c0d056bc6658a23b27c5e64 /src/graphics.c
parent476c10961d6ddba806cd9f587fc461c848d27401 (diff)
downloadtrashbinphysics-1efdb8ab18042d9efc7c2e6addf7f414fbee5590.tar.gz
Added graphics functions
Diffstat (limited to 'src/graphics.c')
-rw-r--r--src/graphics.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/graphics.c b/src/graphics.c
new file mode 100644
index 0000000..ccc3fa7
--- /dev/null
+++ b/src/graphics.c
@@ -0,0 +1,64 @@
+// graphics.c
+#include <raylib.h>
+#include <stdint.h>
+#include "graphics.h"
+#include "math.h"
+
+void init_graphics(uint32_t x, uint32_t y, const char* title)
+{
+ InitWindow(x, y, title);
+ SetTargetFPS(60);
+}
+
+void close_graphics(void)
+{
+ CloseWindow();
+}
+
+void begin_graphics_drawing(void)
+{
+ BeginDrawing();
+}
+
+void end_graphics_drawing(void)
+{
+ EndDrawing();
+}
+
+void clear_graphics(const Color color)
+{
+ ClearBackground(color);
+}
+
+void draw_graphics_object(const object_t* obj, Color color)
+{
+ if(!obj->registered) return;
+
+ Vector2 pos = obj->pos;
+
+ switch(obj->type) {
+ case OBJECT_CIRCLE:
+ DrawCircleV(pos, obj->size_x, color);
+ break;
+ case OBJECT_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 OBJECT_RECTANGLE:
+ DrawRectangleV(
+ (Vector2){pos.x - obj->size_x/2, pos.y - obj->size_y/2},
+ (Vector2){obj->size_x, obj->size_y}, color);
+ break;
+ }
+
+}
+
+void draw_graphics_objects(const object_t* world, uint32_t count, Color color)
+{
+
+}
+
+
+void draw_graphics_info(uint32_t fps, uint32_t objs, uint32_t max_objs);
+bool should_close_graphics(void);