diff options
| author | kotorifan <kotorifan05@gmail.com> | 2026-04-21 23:57:34 +0200 |
|---|---|---|
| committer | kotorifan <kotorifan05@gmail.com> | 2026-04-21 23:57:34 +0200 |
| commit | b40d44202ed0c79cbb769edba8de57412d07501a (patch) | |
| tree | 00109eba9702b3d117ca9ea3fc9ff9163a3dabba /src/graphics.c | |
| parent | a2c8cd78cdb0532496ee6487878b7c52a782e871 (diff) | |
| download | trashbinphysics-b40d44202ed0c79cbb769edba8de57412d07501a.tar.gz | |
Enough for today
Diffstat (limited to 'src/graphics.c')
| -rw-r--r-- | src/graphics.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/graphics.c b/src/graphics.c index 42a06cd..ecc0a58 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -1,8 +1,9 @@ // graphics.c #include <raylib.h> #include <stdint.h> +#include <stdio.h> #include "graphics.h" -#include "math.h" +#include "common.h" void init_graphics(uint32_t x, uint32_t y, const char* title) { @@ -37,16 +38,16 @@ void draw_graphics_object(const object_t* obj) Vector2 pos = obj->pos; - switch(obj->type) { - case OBJECT_CIRCLE: - DrawCircleV(pos, obj->size_x, color); + switch(obj->obj_type) { + case SHAPE_CIRCLE: + DrawCircleV(pos, obj->size_x/2.0f, color); break; - case OBJECT_SQUARE: + 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 OBJECT_RECTANGLE: + 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); @@ -56,18 +57,18 @@ void draw_graphics_object(const object_t* obj) void draw_graphics_objects(const object_t* world, uint32_t count) { - for (uint32_t iter = 0; iter < count, i++) + for (uint32_t iter = 0; iter < count; iter++) { - if(world[iter].registered) draw_graphics_object(&world[i]); + if(world[iter].registered) draw_graphics_object(&world[iter]); } } -void draw_graphics_info(uint32_t fps, uint32_t objs, uint32_t max_objs) +void draw_graphics_info(uint32_t objs) { char buffer[128]; - snprintf(buffer, sizeof(buffer), "FPS: %d", fps; + snprintf(buffer, sizeof(buffer), "FPS: %d", GetFPS()); DrawText(buffer, 10, 10, 20, BLACK); - snprintf(buffer, sizeof(buffer), "OBJ: %d/%d", objs, max_objs); + snprintf(buffer, sizeof(buffer), "OBJ: %d/%d", objs, MAX_OBJECTS); DrawText(buffer, 10, 35, 20, BLACK); DrawText("ESC: Exit", 10, 60, 20, BLACK); DrawText("R: Random velocity", 10, 85, 20, BLACK); |
