From e0a4d684fc38cc3db7a92660e61ff63aa9edbf56 Mon Sep 17 00:00:00 2001 From: N0VA Date: Tue, 17 Feb 2026 14:44:39 +0100 Subject: [PATCH] Generate a world and show the centre quadrant --- iris_c/main.c | 45 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/iris_c/main.c b/iris_c/main.c index 19b073a..72ea830 100644 --- a/iris_c/main.c +++ b/iris_c/main.c @@ -2,16 +2,53 @@ #include #include "random.h" +#include "world.h" + +static const char *quadrant_type_name(quadrant_type type) { + switch (type) { + case Q_EMPTY: return "Empty"; + case Q_ASTEROID_FIELD: return "Asteroid field"; + case Q_STAR_SYSTEM: return "Star system"; + case Q_NEBULA: return "Nebula"; + case Q_BLACK_HOLE: return "Black hole"; + case Q_WHITE_HOLE: return "White hole"; + case Q_PULSAR: return "Pulsar"; + case Q_QUASAR: return "Quasar"; + case Q_SUPERNOVA: return "Supernova"; + case Q_ANOMALY: return "Anomaly"; + case Q_SINGULARITY: return "Singularity"; + case Q_COUNT: return "Count"; + default: return "Undefined"; + } +} int main() { uint32_t seed; printf("Enter seed: "); scanf("%u", &seed); set_random_seed(seed); - uint32_t num = random_range(20); - for (uint32_t i = 0; i < num; i++) { - printf("%u\n", random_u32()); + + world_t world; + world_generate(&world); + + uint16_t x = WORLD_WIDTH / 2; + uint16_t y = WORLD_HEIGHT / 2; + const quadrant_t *centre = world_get_quadrant(&world, x, y); + if (centre == NULL) { + printf("Failed to read centre quadrant.\n"); + return 1; } - printf("%u random numbers\n", num); + + printf("Generated world: %ux%u\n", WORLD_WIDTH, WORLD_HEIGHT); + printf( + "Centre (%u, %u): type=%s (%d), old=%s, visited=%s, discovered=%s\n", + x, y, + quadrant_type_name(centre->type), + (int)centre->type, + centre->is_old ? "true" : "false", + centre->is_visited ? "true" : "false", + centre->is_discovered ? "true" : "false" + ); + return 0; }