Ensure objects are square
This commit is contained in:
parent
966e651b1a
commit
d3e9475130
15
main.c
15
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),
|
||||
|
Loading…
x
Reference in New Issue
Block a user