comments and cleaning

This commit is contained in:
Jeeves 2025-05-28 07:07:58 -06:00
parent 18bff3cc00
commit 34f6d4d742
2 changed files with 7 additions and 9 deletions

3
.gitignore vendored
View file

@ -8,9 +8,10 @@ zig-out/
/build-*/ /build-*/
/docgen_tmp/ /docgen_tmp/
# Temporary project-specific dirs # Temporary project-specific things
vsh/ vsh/
dumped/ dumped/
menu/ menu/
font/ font/
reference/ reference/
screenshot.png

View file

@ -3,7 +3,7 @@ pub fn main() !void {
defer _ = gpa.deinit(); defer _ = gpa.deinit();
const allocator = gpa.allocator(); const allocator = gpa.allocator();
raylib.SetConfigFlags(raylib.FLAG_VSYNC_HINT | raylib.FLAG_WINDOW_RESIZABLE); raylib.SetConfigFlags(raylib.FLAG_VSYNC_HINT); // | raylib.FLAG_WINDOW_RESIZABLE);
raylib.InitWindow(@intFromFloat(screen_width), @intFromFloat(screen_height), "ReX"); raylib.InitWindow(@intFromFloat(screen_width), @intFromFloat(screen_height), "ReX");
defer raylib.CloseWindow(); defer raylib.CloseWindow();
@ -14,8 +14,6 @@ pub fn main() !void {
global_font = raylib.LoadFontEx("font/SCE-PS3-RD-R-LATIN.TTF", 32, 0, 250); global_font = raylib.LoadFontEx("font/SCE-PS3-RD-R-LATIN.TTF", 32, 0, 250);
raylib.SetTextureFilter(global_font.texture, raylib.TEXTURE_FILTER_TRILINEAR); raylib.SetTextureFilter(global_font.texture, raylib.TEXTURE_FILTER_TRILINEAR);
// const camera = createCamera();
var background = Background.init(); var background = Background.init();
var column = Column.init( var column = Column.init(
allocator, allocator,
@ -39,6 +37,7 @@ pub fn main() !void {
scales.recalculate(); scales.recalculate();
} }
if (raylib.IsKeyPressed('Z')) item.setBig(!item.big); if (raylib.IsKeyPressed('Z')) item.setBig(!item.big);
if (raylib.IsKeyPressed('S')) raylib.TakeScreenshot("screenshot.png");
raylib.BeginDrawing(); raylib.BeginDrawing();
defer raylib.EndDrawing(); defer raylib.EndDrawing();
@ -46,11 +45,6 @@ pub fn main() !void {
background.draw(); background.draw();
column.draw(); column.draw();
// {
// raylib.BeginMode3D(camera);
// defer raylib.EndMode3D();
// }
raylib.DrawFPS(1, 1); raylib.DrawFPS(1, 1);
const debug_text = try std.fmt.allocPrint(allocator, "screen size = {d}x{d}", .{ screen_width, screen_height }); const debug_text = try std.fmt.allocPrint(allocator, "screen size = {d}x{d}", .{ screen_width, screen_height });
@ -66,6 +60,7 @@ var screen_height: f32 = 272;
var scales: Scales = undefined; var scales: Scales = undefined;
/// Cached scaling and positioning values for dynamic window resizing.
pub const Scales = struct { pub const Scales = struct {
item_icon_scale: f32, item_icon_scale: f32,
item_title_font_size: f32, item_title_font_size: f32,
@ -76,6 +71,7 @@ pub const Scales = struct {
column_position_center: raylib.Vector2, column_position_center: raylib.Vector2,
column_position_spacing: f32, column_position_spacing: f32,
/// Recalculate scales after screen resize.
pub fn recalculate(self: *Scales) void { pub fn recalculate(self: *Scales) void {
self.item_icon_scale = screen_height * 0.72 / screen_height; self.item_icon_scale = screen_height * 0.72 / screen_height;
@ -272,6 +268,7 @@ pub const Background = struct {
}; };
}; };
/// Create ortho camera looking down at the XY plane, with a fovy of 1 for UV-like positioning.
fn createCamera() raylib.Camera3D { fn createCamera() raylib.Camera3D {
var camera = raylib.Camera3D{}; var camera = raylib.Camera3D{};