From 2c7e844d00b7e15b9618561dccbb89279778c19d Mon Sep 17 00:00:00 2001 From: CrispyPin Date: Sun, 20 Apr 2025 20:45:57 +0200 Subject: [PATCH] fix right edge grid rendering --- CHANGELOG.md | 3 ++- README.md | 1 - src/editor.rs | 6 ++++-- src/marble_engine/grid.rs | 8 ++++---- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f91ab89..82fa303 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,8 +7,9 @@ Game store page: https://crispypin.itch.io/marble-machinations ### fixed - input bytes are consumed even if the marble can't be created because another one was taking its place -- crash when saving config if no user dir exists - keybindings activated even when typing in a text field, making especially renaming blueprints difficult +- grid rendering broken on right edge of the screen at some zoom levels and window sizes +- crash when saving config if no user dir exists - after removing a binding that was a superset of another, the remaining one did not stop being blocked by the removed ones additional modifiers until another binding was added or edited ## v0.3.2 - 2025-04-14 diff --git a/README.md b/README.md index 5114600..be7dc44 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,6 @@ logic mostly like https://git.crispypin.cc/CrispyPin/marble - blag post about marble movement logic? ### bugs - Shift+A and A+Shift conflict -- rigt side grid rendering broken ### features #### 0.3.x - more levels diff --git a/src/editor.rs b/src/editor.rs index ac41159..3dcf0ac 100644 --- a/src/editor.rs +++ b/src/editor.rs @@ -618,11 +618,13 @@ impl Editor { let tile_size = TILE_TEXTURE_SIZE * self.zoom; let grid_spill_x = (self.view_offset.x).rem(tile_size) - tile_size; let grid_spill_y = (self.view_offset.y).rem(tile_size) - tile_size; - for y in 0..=(d.get_screen_height() / tile_size as i32) { + let hlines = d.get_screen_height() / tile_size as i32 + 3; + let vlines = d.get_screen_width() / tile_size as i32 + 3; + for y in 0..hlines { let y = y * tile_size as i32 + grid_spill_y as i32; d.draw_line(0, y, d.get_screen_width(), y, FG_GRID); } - for x in 0..=(d.get_screen_width() / tile_size as i32) { + for x in 0..vlines { let x = x * tile_size as i32 + grid_spill_x as i32; d.draw_line(x, 0, x, d.get_screen_height(), FG_GRID); } diff --git a/src/marble_engine/grid.rs b/src/marble_engine/grid.rs index 63f2f64..466a3a8 100644 --- a/src/marble_engine/grid.rs +++ b/src/marble_engine/grid.rs @@ -289,12 +289,12 @@ impl Grid { let tile_size = (TILE_TEXTURE_SIZE * scale) as i32; let start_x = (-offset.x as i32) / tile_size - 1; - let tile_width = d.get_screen_width() / tile_size + 2; + let tiles_width = d.get_screen_width() / tile_size + 3; let start_y = (-offset.y as i32) / tile_size - 1; - let tile_height = d.get_screen_height() / tile_size + 2; + let tiles_height = d.get_screen_height() / tile_size + 3; - for x in start_x..(start_x + tile_width) { - for y in start_y..(start_y + tile_height) { + for x in start_x..(start_x + tiles_width) { + for y in start_y..(start_y + tiles_height) { let px = x * tile_size + offset.x as i32; let py = y * tile_size + offset.y as i32; if let Some(tile) = self.get((x, y).into()) {