From: Randy McShandy Date: Sun, 5 May 2024 00:21:00 +0000 (-0500) Subject: Slightly better room generation and some visual updates X-Git-Url: http://git.mcshandy.xyz/gitweb.cgi?a=commitdiff_plain;h=7c03d4a233e29eef4ed8fde30b0afb8a0faf48a7;p=barrow_crawler Slightly better room generation and some visual updates --- diff --git a/src/main.c b/src/main.c index b4a865d..da80527 100755 --- a/src/main.c +++ b/src/main.c @@ -13,7 +13,7 @@ void print_rlog(int logLevel, const char* text, va_list args) int main(int argc, char** argv) { - IVec2 grid_size = {.x = GRID_X * 1.0, .y = GRID_Y * 1.0}; + IVec2 grid_size = {.x = GRID_X * 1.5, .y = GRID_Y * 1.5}; FVec2 **grid = NULL; grid = (FVec2**)malloc(grid_size.x * sizeof(FVec2*)); for (int n = 0; n < grid_size.x; n++) diff --git a/src/render_raylib.c b/src/render_raylib.c index 19ebeae..66c6cee 100644 --- a/src/render_raylib.c +++ b/src/render_raylib.c @@ -12,6 +12,7 @@ Mesh barrow_meshes[1U]; Material barrow_material; Matrix barrow_transform; Vector3 barrow_position; +Vector3 barrow_scale; Vector3 player_velocity; Vector3 player_rotation; @@ -59,6 +60,7 @@ void process_inputs() void initialize_renderer() { + barrow_scale = (Vector3){64.0f, 8.0f, 64.0f}; barrow_position = (Vector3){-8.0f, 0.0f, -8.0f}; barrow_image = LoadImage("./barrow.png"); diffuse_texture = LoadTexture("./barrow_diffuse.png"); @@ -69,7 +71,7 @@ void initialize_renderer() while(!IsTextureReady(barrow_texture)){} while(!IsTextureReady(diffuse_texture)){} - barrow_meshes[0U] = GenMeshHeightmap(barrow_image, (Vector3){64.0f, 8.0f, 64.0f}); + barrow_meshes[0U] = GenMeshHeightmap(barrow_image, barrow_scale); barrow_model = LoadModelFromMesh(barrow_meshes[0]); barrow_model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = diffuse_texture; @@ -78,7 +80,7 @@ void initialize_renderer() cam.position.y += 3.0f; cam.target = (Vector3){0.0f, cam.position.y * 0.66f, 0.0f}; cam.up = (Vector3){0.0f, 1.0f, 0.0f}; - cam.fovy = 45.0f; + cam.fovy = 75.0f; cam.projection= CAMERA_PERSPECTIVE; DisableCursor(); @@ -103,6 +105,10 @@ void start_render_loop() EndMode3D(); DrawTexture(barrow_texture, 64, 64, RAYWHITE); + DrawCircle( + 64+(cam.position.x) + (barrow_image.width/4.0f), + 64+(cam.position.z) + (barrow_image.height/4.0f), + 2.0f, RED); DrawFPS(10, 10); EndDrawing(); diff --git a/src/structs.c b/src/structs.c index 530dfc7..c4d4a99 100644 --- a/src/structs.c +++ b/src/structs.c @@ -72,7 +72,7 @@ const Mat3 laplacian_kernel = const char chars[6] = {' ', ' ', ' ', '+', '#', '@'}; const int max_chars = sizeof(chars) / sizeof(chars[0]) - 1; -const IVec2 screen_dims = {.x = 1600, .y = 900}; +const IVec2 screen_dims = {.x = 1200, .y = 800}; const char* screen_title = "Barrow Crawler"; const int target_fps = 60; diff --git a/src/utils.c b/src/utils.c index d342796..532493c 100644 --- a/src/utils.c +++ b/src/utils.c @@ -115,19 +115,25 @@ int initialize(int worker_count, RD_Opts active_opt) } /* Set up seed-points to create connected rooms */ - const int seed_count = sqrt(grid_size.x) * 2; + const int seed_count = 9;//sqrt(grid_size.x) * 2; const int width = 12 * (grid_size.x/128); const int height = width * 1; + + float phase = ((rand() % 360)/(float)360) * (M_PI*2); for (int n = 0; n < seed_count; n++) { - int rand_x = rand() % grid_size.x; - int rand_y = rand() % grid_size.y; - grid[rand_x][rand_y].b = 1.0f; - grid[rand_x][rand_y].c = 0.0f; + /* Generate n seeds at even radial points, random phase offset */ + float angle = ((float)n/(float)seed_count) * (M_PI * 2); + angle += phase; + + int seed_x = ((cosf(angle) * (grid_size.x/4.0f)) + (grid_size.x/2.0f)); + int seed_y = ((sinf(angle) * (grid_size.x/4.0f)) + (grid_size.x/2.0f)); + grid[seed_x][seed_y].b = 1.0f; + grid[seed_x][seed_y].c = 0.0f; - for (int x = rand_x-(width/2); x < rand_x+(width/2); x++) + for (int x = seed_x-(width/2); x < seed_x+(width/2); x++) { - for (int y = rand_y-(height/2); y < rand_y+(height/2); y++) + for (int y = seed_y-(height/2); y < seed_y+(height/2); y++) { if (y >= grid_size.y || x >= grid_size.x || y < 0 || x < 0) continue;