mirror of
https://github.com/Noratrieb/game-wip-dontplay.git
synced 2026-01-16 12:25:02 +01:00
Fix world pos to tile pos calculation for negative values
This commit is contained in:
parent
62bd6b2c7c
commit
7dba1b22e3
3 changed files with 26 additions and 8 deletions
|
|
@ -2,7 +2,7 @@ use sfml::graphics::{Rect, RenderTarget, RenderWindow, Sprite, Transformable};
|
|||
|
||||
use crate::{
|
||||
graphics::{ScreenPos, NATIVE_RESOLUTION},
|
||||
math::WorldPos,
|
||||
math::{wp_to_tp, WorldPos, WorldPosScalar},
|
||||
res::Res,
|
||||
world::{TilePos, World},
|
||||
};
|
||||
|
|
@ -28,8 +28,8 @@ fn for_each_tile(camera_offset: WorldPos, mut f: impl FnMut(TilePos, ScreenPos))
|
|||
for x in (-32..NATIVE_RESOLUTION.w + 32).step_by(32) {
|
||||
f(
|
||||
TilePos {
|
||||
x: (camera_offset.x + x as i32) / 32,
|
||||
y: (camera_offset.y + y as i32) / 32,
|
||||
x: wp_to_tp(camera_offset.x + x as WorldPosScalar),
|
||||
y: wp_to_tp(camera_offset.y + y as WorldPosScalar),
|
||||
},
|
||||
ScreenPos {
|
||||
x: (x as i32 - camera_offset.x % 32) as i16,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue