feat: refine screen size based sprite selection

Before this change, medium was selected even for devices that could use
the large sprites.

I also changed the metric from `framebuffer_size[1]` to `window_size[1]`.
This is pixel art with pixels that are designed to be seen. We care more
about its size on the screen.
dev
LeRoyce Pearson 2024-02-29 13:15:21 -07:00
parent dbe5a92b54
commit a14e5c3839
1 changed files with 8 additions and 8 deletions

View File

@ -405,23 +405,23 @@ pub fn main() !void {
_ = canvas.printText(.{ 0, 0 }, "History len: {}", .{history.items.len}, .{}); _ = canvas.printText(.{ 0, 0 }, "History len: {}", .{history.items.len}, .{});
switch (framebuffer_size[1]) { switch (window_size[1]) {
0...300 => if (card_tilemap_small == null) { 0...144 => if (card_tilemap_small == null) {
card_tilemap_small = try assets.loadSmallCards(gpa.allocator()); card_tilemap_small = try assets.loadSmallCards(gpa.allocator());
}, },
301...1000 => if (card_tilemap_medium == null) { 145...299 => if (card_tilemap_medium == null) {
card_tilemap_medium = try assets.loadMediumCards(gpa.allocator()); card_tilemap_medium = try assets.loadMediumCards(gpa.allocator());
}, },
1001...std.math.maxInt(c_int) => if (card_tilemap_large == null) { 300...std.math.maxInt(c_int) => if (card_tilemap_large == null) {
card_tilemap_large = try assets.loadLargeCards(gpa.allocator()); card_tilemap_large = try assets.loadLargeCards(gpa.allocator());
}, },
else => unreachable, else => unreachable,
} }
const deck_sprites = switch (framebuffer_size[1]) { const deck_sprites = switch (window_size[1]) {
0...300 => card_tilemap_small.?, 0...144 => card_tilemap_small.?,
301...1000 => card_tilemap_medium.?, 145...299 => card_tilemap_medium.?,
1001...std.math.maxInt(c_int) => card_tilemap_large.?, 300...std.math.maxInt(c_int) => card_tilemap_large.?,
else => unreachable, else => unreachable,
}; };