+#include <stddef.h>
#include <raylib.h>
#define RAYMATH_IMPLEMENTATION
#include <raymath.h>
Vector3 vec3_up = {0.0f, 1.0f, 0.0f};
Vector3 vec3_down = {0.0f, -1.0f, 0.0f};
+typedef void(*renderfunc)();
+#define MAX_RENDERFUNCS 2U
+renderfunc renderfuncs[MAX_RENDERFUNCS];
+
+/* Render the regular game mode.
+NOTE: Only call inside a Raylib BeginDrawing() block!
+*/
+void drawing_game_mode()
+{
+ ClearBackground(BLACK);
+
+ BeginMode3D(cam);
+ BeginShaderMode(shader);
+
+ DrawModelEx(coffin_model, coffin_position, coffin_rotation_axis, coffin_rotation, coffin_scale, DARKGRAY);
+ DrawModelEx(barrow_model, barrow_position, barrow_rotation_axis, barrow_rotation, barrow_scale, DARKGRAY);
+ DrawModelEx(floor_model, floor_position, floor_rotation_axis, floor_rotation, floor_scale, DARKGRAY);
+ DrawRay(player_collide_ray, WHITE);
+
+ EndShaderMode();
+ EndMode3D();
+
+#if DEBUG_GAME_INFO==1
+ Rectangle minimap_dest = {.width = 64.0f*img_export_scale.x, .height = 64.0f*img_export_scale.y, .x = 0.0f, .y = 0.0f};
+ Rectangle minimap_src = {.width = barrow_texture.width, .height = barrow_texture.height, .x = 0.0f, .y = 0.0f};
+
+ DrawTexturePro(floor_texture, minimap_src, minimap_dest, (Vector2){0.0f, 0.0f}, 0.0f, RAYWHITE);
+ DrawFPS(fscreen_dims.x - 80, 10);
+ DrawText(TextFormat("cam x %f\ncam y %f\ncam z %f", cam.position.x, cam.position.y, cam.position.z), 0, 128, 16, GREEN);
+ DrawText(TextFormat("ray hit %d\nlength %f", player_collision.hit, player_collision.distance), 0, 256, 16, GREEN);
+#endif /* DEBUG_GAME_INFO */
+}
+
+/* Something to render while waiting on resources to be generated.
+NOTE: Only call inside a Raylib BeginDrawing() block!
+*/
+void drawing_resource_wait_mode()
+{
+ static int ellipses_counter = 0;
+ const char wait_string[] = "Generating resources...";
+ const int sector_speed = 2U;
+ const int sector_segments = 16;
+ const float sector_radius = 32.0f;
+ const Vector2 sector_center = {fscreen_dims.x/2.0f, 3*(fscreen_dims.y/4.0f)};
+
+ ellipses_counter+=sector_speed;
+
+ const int font_size = 32;
+ const int text_width = MeasureText(wait_string, font_size);
+
+ ClearBackground(RAYWHITE);
+ DrawText(wait_string, (fscreen_dims.x/2.0f) - (text_width/2.0f), fscreen_dims.y/2.0f, font_size, BLACK);
+ DrawCircleSector(sector_center, sector_radius,
+ (ellipses_counter % 360),
+ ((ellipses_counter % 360)*2),
+ sector_segments, RED);
+
+ DrawCircleSector(sector_center, sector_radius * 0.8f,
+ (ellipses_counter % 360),
+ ((ellipses_counter % 360)*2),
+ sector_segments, RAYWHITE);
+}
+
+
void process_inputs()
{
Vector3 new_player_velocity = player_velocity;
while(!IsModelReady(coffin_model)){}
coffin_model.materials[0].shader = shader;
}
+
+ /* Rendering handler setup */
+ renderfuncs[0U] = drawing_resource_wait_mode;
+ renderfuncs[1U] = drawing_game_mode;
}
/* Values that are required to initialize Raylib. */
wait_initialize_resources();
initialize_renderer();
- Rectangle minimap_dest = {.width = 64.0f*img_export_scale.x, .height = 64.0f*img_export_scale.y, .x = 0.0f, .y = 0.0f};
- Rectangle minimap_src = {.width = barrow_texture.width, .height = barrow_texture.height, .x = 0.0f, .y = 0.0f};
-
SetTargetFPS(target_fps);
while (!WindowShouldClose())
{
UpdateCameraPro(&cam, player_velocity, player_rotation, 0.0f);
BeginDrawing();
- ClearBackground(BLACK);
-
- BeginMode3D(cam);
- BeginShaderMode(shader);
- DrawModelEx(coffin_model, coffin_position, coffin_rotation_axis, coffin_rotation, coffin_scale, DARKGRAY);
- DrawModelEx(barrow_model, barrow_position, barrow_rotation_axis, barrow_rotation, barrow_scale, DARKGRAY);
- DrawModelEx(floor_model, floor_position, floor_rotation_axis, floor_rotation, floor_scale, DARKGRAY);
- DrawRay(player_collide_ray, WHITE);
- EndShaderMode();
- EndMode3D();
-
- DrawTexturePro(floor_texture, minimap_src, minimap_dest, (Vector2){0.0f, 0.0f}, 0.0f, RAYWHITE);
- DrawFPS(fscreen_dims.x - 80, 10);
- DrawText(TextFormat("cam x %f\ncam y %f\ncam z %f", cam.position.x, cam.position.y, cam.position.z), 0, 128, 16, GREEN);
- DrawText(TextFormat("ray hit %d\nlength %f", player_collision.hit, player_collision.distance), 0, 256, 16, GREEN);
+ renderfuncs[resource_generation_finished]();
EndDrawing();
/* Decay forward velocity and rotation */