This commit is contained in:
2025-05-13 14:03:43 +01:00
parent 716ea8638d
commit adb9d14c71
4 changed files with 206 additions and 25 deletions

View File

@@ -14,7 +14,7 @@
#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 ZONE_COLOR (Color){.r = 0xb4, .g = 0x65, .b = 0x4a, .a = 0xff}
#define WANDERER_COUNT 50000
#define WANDERER_COUNT 500000
#define ZONE_COUNT 5
#define WANDERER_SLOWDOWN_FACTOR 0.5f
#define WANDERER_SPEEDUP_FACTOR 2.0f
@@ -71,12 +71,17 @@ int main(void) {
InitWindow(WIDTH, HEIGHT, "DOD test");
SetTargetFPS(120);
Allocator arena = wapp_mem_arena_allocator_init(MB(10));
Allocator arena = wapp_mem_arena_allocator_init(MB(20));
XOR256State state = wapp_prng_xorshift_init_state();
Wanderer *wanderers = wapp_mem_allocator_alloc(&arena, sizeof(Wanderer) * WANDERER_COUNT);
SlowZone *zones = wapp_mem_allocator_alloc(&arena, sizeof(SlowZone) * ZONE_COUNT);
u64 wanderers_size = sizeof(Wanderer) * WANDERER_COUNT;
u64 zones_size = sizeof(SlowZone) * ZONE_COUNT;
Wanderer *wanderers = wapp_mem_allocator_alloc(&arena, wanderers_size);
SlowZone *zones = wapp_mem_allocator_alloc(&arena, zones_size);
assert(wanderers != NULL && zones != NULL);
memset(wanderers, 0, wanderers_size);
memset(zones, 0, zones_size);
for (u64 i = 0; i < WANDERER_COUNT; ++i) {
init_wanderer(&(wanderers[i]), &state);
}
@@ -84,25 +89,31 @@ int main(void) {
init_slow_zone(&(zones[i]),&state);
}
// while (!WindowShouldClose()) {
// for (u64 i = 0; i < WANDERER_COUNT; ++i) {
// move_wanderer(&(wanderers[i]), zones);
// }
//
// BeginDrawing();
//
// ClearBackground(BG_COLOR);
//
// #ifndef NDEBUG
// for (u64 i = 0; i < ZONE_COUNT; ++i) {
// render_slow_zone(&(zones[i]));
// }
// #endif
//
// for (u64 i = 0; i < WANDERER_COUNT; ++i) {
// render_wanderer(&(wanderers[i]));
// }
//
// EndDrawing();
// }
while (!WindowShouldClose()) {
for (u64 i = 0; i < WANDERER_COUNT; ++i) {
move_wanderer(&(wanderers[i]), zones);
}
BeginDrawing();
ClearBackground(BG_COLOR);
#ifndef NDEBUG
for (u64 i = 0; i < ZONE_COUNT; ++i) {
render_slow_zone(&(zones[i]));
}
#endif
for (u64 i = 0; i < WANDERER_COUNT; ++i) {
render_wanderer(&(wanderers[i]));
}
EndDrawing();
}