m.m15
Vector2 fscreen_dims;
-Camera3D cam;
Vector3 cam_reset_position;
Image barrow_image;
Texture barrow_texture;
// Absolute position of the center of the barrow model in the world
Vector3 barrow_position;
-// Dead center of the barrow, used for camera spawn etc
+// Dead center of the barrow, used for playtime.camera spawn etc
Vector3 map_center;
// Scale factor from image -> model
Vector3 player_collide_point;
Ray player_collide_ray;
RayCollision player_collision;
-Vector3 player_velocity;
-Vector3 player_rotation;
-Vector3 player_angles;
Vector3 map_center;
float forward_speed = 0.015f;
*/
void drawing_game_mode()
{
- Vector2 from_center_coords = (Vector2){cam.position.x, cam.position.z};
+ Vector2 from_center_coords = (Vector2){playtime.cam.position.x, playtime.cam.position.z};
from_center_coords.x -= barrow_scale_factor.x/2;
from_center_coords.y += barrow_scale_factor.z/2;
/* -PI, PI */
- player_angles.y = Vector2Angle(Vector2Normalize(from_center_coords), (Vector2){1.0f, 0.0f});
+ playtime.player_angles.y = Vector2Angle(Vector2Normalize(from_center_coords), (Vector2){1.0f, 0.0f});
ClearBackground(BLACK);
- BeginMode3D(cam);
+ BeginMode3D(playtime.cam);
BeginShaderMode(shader);
if (barrow_visible)
EndShaderMode();
- for (int n = 0; n < room_count; n++)
+ for (int n = 0; n < playtime.room_count; n++)
{
- Vector3 each = room_positions[n];
+ Vector3 each = playtime.room_positions[n];
DrawSphere(each, 0.1, RED);
}
orb_normal_color = ColorNormalize(orb_color);
orb_intensity = 84.0f; /* TODO: normalized distance from center, but lighting shader already has this. */
- orb_directionality = player_angles;
+ orb_directionality = playtime.player_angles;
DrawTextureEx(hand_01_texture, hand_position, hand_rotation, hand_scale, orb_color);
const int line_height = 32;
DrawFPS(fscreen_dims.x - 80, 10);
DrawTexturePro(floor_texture, minimap_src, minimap_dest, (Vector2){0.0f, 0.0f}, 0.0f, RAYWHITE);
- DrawText(TextFormat(V3_FORMAT(cam.position), V3_UNROLL(cam.position)), 0, 128, 16, GREEN);
- DrawText(TextFormat(V3_FORMAT(cam.target), V3_UNROLL(cam.target)), 0, 128+line_height, 16, GREEN);
- DrawText(TextFormat(V3_FORMAT(player_angles), V3_UNROLL(player_angles)), 0, 128+(line_height*2), 16, GREEN);
+ DrawText(TextFormat(V3_FORMAT(playtime.cam.position), V3_UNROLL(playtime.cam.position)), 0, 128, 16, GREEN);
+ DrawText(TextFormat(V3_FORMAT(playtime.cam.target), V3_UNROLL(playtime.cam.target)), 0, 128+line_height, 16, GREEN);
+ DrawText(TextFormat(V3_FORMAT(playtime.player_angles), V3_UNROLL(playtime.player_angles)), 0, 128+(line_height*2), 16, GREEN);
DrawText(TextFormat("ray hit:%d length %.2f" V3_FORMAT(player_collision.point), player_collision.hit, player_collision.distance, player_collision.point), 0, 128+(line_height*3), 16, GREEN);
DrawText(TextFormat(V3_FORMAT(player_collide_ray.position), V3_UNROLL(player_collide_ray.position), V3_UNROLL(player_collide_ray.direction)), 0, 128+(line_height*4), 16, GREEN);
- DrawText(TextFormat(V3_FORMAT(room_positions[0]), V3_UNROLL(room_positions[0])), 0, 128+(line_height*5), 16, GREEN);
+ DrawText(TextFormat(V3_FORMAT(playtime.room_positions[0]), V3_UNROLL(playtime.room_positions[0])), 0, 128+(line_height*5), 16, GREEN);
DrawText(TextFormat(V3_FORMAT(barrow_position), V3_UNROLL(barrow_position)), 0, 128+(line_height*6), 16, GREEN);
DrawText(TextFormat(V3_FORMAT(floor_position), V3_UNROLL(floor_position)), 0, 128+(line_height*7), 16, GREEN);
DrawText(TextFormat(V3_FORMAT(barrow_size), V3_UNROLL(barrow_extent)), 0, 128+(line_height*8), 16, GREEN);
void drawing_resource_ready_mode()
{
- static int status_phase = 0;
const float font_size = 32.0f;
- const char format_string[] = "%s\n\n%3.2f%%";
const char tribute_string[] = "This game is dedicated to the North American Muskrat, Ondatra zibethicus";
ClearBackground(LIGHTGRAY);
{
const float frame_time = GetFrameTime();
- Vector3 new_player_velocity = player_velocity;
- Vector3 new_player_rotation = player_rotation;
+ Vector3 player_velocity = playtime.player_velocity;
+ Vector3 player_rotation = playtime.player_rotation;
KeyboardKey key = GetKeyPressed();
do
{
if (IsKeyDown(KEY_W) || IsKeyDown(KEY_K))
{
- new_player_velocity.x = forward_speed * frame_time;
+ player_velocity.x = forward_speed * frame_time;
}
else if (IsKeyDown(KEY_S) || IsKeyDown(KEY_J))
{
- new_player_velocity.x = -forward_speed * frame_time;
+ player_velocity.x = -forward_speed * frame_time;
}
if (IsKeyDown(KEY_A) || IsKeyDown(KEY_H))
{
- new_player_rotation.x = -rotate_speed * frame_time;
+ player_rotation.x = -rotate_speed * frame_time;
}
else if (IsKeyDown(KEY_D) || IsKeyDown(KEY_L))
{
- new_player_rotation.x = rotate_speed * frame_time;
+ player_rotation.x = rotate_speed * frame_time;
}
if (IsKeyDown(KEY_T))
{
- cam.target.y += DEG2RAD * 20.0;
+ playtime.cam.target.y += DEG2RAD * 20.0;
}
else if (IsKeyDown(KEY_G))
{
- cam.target.y -= DEG2RAD * 20.0;
+ playtime.cam.target.y -= DEG2RAD * 20.0;
}
if (IsKeyReleased(KEY_B))
if (IsKeyReleased(KEY_Z))
{
- cam.position = cam_reset_position;
+ playtime.cam.position = cam_reset_position;
}
if (IsKeyReleased(KEY_ONE))
/* Collision test */
/* Cast straight up */
- player_collide_ray = (Ray){cam.position, vec3_up};
+ player_collide_ray = (Ray){playtime.cam.position, vec3_up};
player_collision = GetRayCollisionMesh(player_collide_ray, barrow_model.meshes[0U], barrow_mat);
- player_rotation = new_player_rotation;
+ playtime.player_rotation = player_rotation;
if (false && player_collision.hit && player_collision.distance < 1.30f)
{
- player_velocity.x *= -1.05;
+ playtime.player_velocity.x *= -1.05;
}
else
{
- player_velocity = new_player_velocity;
+ playtime.player_velocity = player_velocity;
}
switch(key)
Vector3 axis = map_center;
float angle = DEG2RAD*0.0f;
- for (int n = 0; n < room_count; n++)
+ for (int n = 0; n < playtime.room_count; n++)
{
// Scale room positions down from gentime positions
- printf("room %d at %f %f %f\n", n, V3_UNROLL(room_positions[n]));
- room_positions[n].x /= 4;
- room_positions[n].z /= 4;
- room_positions[n].y += 0.6f;
- room_positions[n] = Vector3RotateByAxisAngle(room_positions[n], axis, angle);
- printf("room moved to %f %f %f\n", V3_UNROLL(room_positions[n]));
+ printf("room %d at %f %f %f\n", n, V3_UNROLL(playtime.room_positions[n]));
+ playtime.room_positions[n].x /= 4;
+ playtime.room_positions[n].z /= 4;
+ playtime.room_positions[n].y += 0.6f;
+ playtime.room_positions[n] = Vector3RotateByAxisAngle(playtime.room_positions[n], axis, angle);
+ printf("room moved to %f %f %f\n", V3_UNROLL(playtime.room_positions[n]));
}
/* Grab the full transformation matrix of the upper barrow for use in collision */
cam_reset_position = map_center;
cam_reset_position.y = 1.0f;
- cam = (Camera3D){0};
- cam.position = cam_reset_position;
- cam.target = cam.position;
- cam.target.x += 3.0f;
- cam.up = (Vector3){0.0f, 1.0f, 0.0f};
- cam.fovy = 90.0f;
- cam.projection = CAMERA_PERSPECTIVE;
+
+ /* if not loading a save */
+ if (1)
+ {
+ playtime.cam = (Camera3D){0};
+ playtime.cam.position = cam_reset_position;
+ playtime.cam.target = playtime.cam.position;
+ playtime.cam.target.x += 3.0f;
+ playtime.cam.up = (Vector3){0.0f, 1.0f, 0.0f};
+ playtime.cam.fovy = 90.0f;
+ playtime.cam.projection = CAMERA_PERSPECTIVE;
+ }
+ else
+ {
+ /* Load a save */
+ }
/*
I know these are good at 60 fps. Per-second speed to move to FPS/independent movement.
{
int func_idx = resource_state;
- player_collide_point = cam.position;
+ player_collide_point = playtime.cam.position;
//player_collide_point.y -= 1.0f;
controlfuncs[func_idx]();
- SetShaderValue(shader, cam_position_shader_loc, &cam.position, SHADER_UNIFORM_VEC3);
+ SetShaderValue(shader, cam_position_shader_loc, &playtime.cam.position, SHADER_UNIFORM_VEC3);
SetShaderValue(shader, screen_dims_shader_loc, &fscreen_dims, SHADER_UNIFORM_VEC2);
SetShaderValue(shader, map_center_shader_loc, &map_center, SHADER_UNIFORM_VEC3);
SetShaderValue(shader, orb_color_shader_loc, &orb_normal_color, SHADER_UNIFORM_VEC4);
SetShaderValue(shader, orb_intensity_shader_loc, &orb_intensity, SHADER_UNIFORM_FLOAT);
SetShaderValue(shader, orb_directionality_shader_loc, &orb_directionality, SHADER_UNIFORM_VEC3);
- UpdateCameraPro(&cam, player_velocity, player_rotation, 0.0f);
+ UpdateCameraPro(&playtime.cam, playtime.player_velocity, playtime.player_rotation, 0.0f);
BeginDrawing();
renderfuncs[func_idx]();
EndDrawing();
const float frame_time = GetFrameTime();
/* Decay forward velocity and rotation */
- player_velocity.x = Lerp(player_velocity.x, 0.0f, forward_speed_decay * frame_time);
- player_rotation.x = Lerp(player_rotation.x, 0.0f, rotate_speed_decay * frame_time);
+ playtime.player_velocity.x = Lerp(playtime.player_velocity.x, 0.0f, forward_speed_decay * frame_time);
+ playtime.player_rotation.x = Lerp(playtime.player_rotation.x, 0.0f, rotate_speed_decay * frame_time);
}
- should_quit = 1;
+ playtime.should_quit = 1;
UnloadImage(barrow_image);
UnloadTexture(barrow_texture);