fix right edge grid rendering

This commit is contained in:
Crispy 2025-04-20 20:45:57 +02:00
parent 80ab3b676e
commit 2c7e844d00
4 changed files with 10 additions and 8 deletions

View file

@ -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

View file

@ -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

View file

@ -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);
}

View file

@ -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()) {