]> git.mcshandy.xyz Git - barrow_crawler/commitdiff
Slightly better room generation and some visual updates
authorRandy McShandy <randy@mcshandy.xyz>
Sun, 5 May 2024 00:21:00 +0000 (19:21 -0500)
committerRandy McShandy <randy@mcshandy.xyz>
Sun, 5 May 2024 00:21:00 +0000 (19:21 -0500)
src/main.c
src/render_raylib.c
src/structs.c
src/utils.c

index b4a865d6dc0af3c4caa74172eefd92446dc19a6d..da8052703ebd5195263ca38940aa9479bda4d0d5 100755 (executable)
@@ -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++)
index 19ebeaeec69cb3d328e52015d052f416d5db18a6..66c6ceeaeda1cdbc907ebba53f2d6bf19ac01965 100644 (file)
@@ -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();
 
index 530dfc70fec2f6c557a3dbeeac95eab27ed2066d..c4d4a99cab1feb7eab01021f526b547fab43e0f5 100644 (file)
@@ -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;
 
index d342796e26788921deaa88049e95e8e10ca3c8da..532493c77038728b2967761eb6d197e3e77c39ef 100644 (file)
@@ -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;