From d3e9475130e09e195ffa9b1db8ebfd4cc1be0b08 Mon Sep 17 00:00:00 2001 From: Abdelrahman Date: Sat, 10 May 2025 13:11:03 +0100 Subject: [PATCH] Ensure objects are square --- main.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/main.c b/main.c index 779538f..d9412d8 100644 --- a/main.c +++ b/main.c @@ -7,11 +7,11 @@ #define HEIGHT 720 #define HALF_WIDTH (WIDTH * 0.5f) #define HALF_HEIGHT (HEIGHT * 0.5f) -#define MAX_OBJ_DIM 80 -#define MIN_OBJ_DIM 20 +#define MAX_OBJ_DIM 30 +#define MIN_OBJ_DIM 15 #define BG_COLOR (Color){.r = 0xea, .g = 0xf2, .b = 0xe3, .a = 0xff} #define FG_COLOR (Color){.r = 0x42, .g = 0x4C, .b = 0x55, .a = 0xff} -#define OBJECT_COUNT 1 +#define OBJECT_COUNT 10 #define MSG_BUF_LEN 4096 #define abs(A) (A < 0 ? A * -1 : A) #define min(A, B) (A < B ? A : B) @@ -48,7 +48,7 @@ void move_object(Object *object); f32 get_random_float(XOR256State *state); int main(void) { - InitWindow(WIDTH, HEIGHT, "Handle test"); + InitWindow(WIDTH, HEIGHT, "DOD test"); SetTargetFPS(120); Allocator arena = wapp_mem_arena_allocator_init(MB(10)); @@ -97,10 +97,13 @@ void init_object(Object *object, XOR256State *state) { .x = wapp_prng_xorshift_256(state) % WIDTH, .y = wapp_prng_xorshift_256(state) % HEIGHT, }; + + f32 scale = (f32)((wapp_prng_xorshift_256(state) % (MAX_OBJ_DIM + 1 - MIN_OBJ_DIM)) + MIN_OBJ_DIM); object->scale = (Scale){ - .width = max(wapp_prng_xorshift_256(state) % MAX_OBJ_DIM, MIN_OBJ_DIM), - .height = max(wapp_prng_xorshift_256(state) % MAX_OBJ_DIM, MIN_OBJ_DIM), + .width = scale, + .height = scale, }; + object->velocity = (Velocity){ .x = get_random_float(state), // .y = get_random_float(state),