Define world center

This commit is contained in:
crumblingstatue 2023-04-03 10:50:07 +02:00
parent f69d05bed0
commit 2480c48cbf
2 changed files with 9 additions and 1 deletions

View file

@ -43,7 +43,7 @@ fn for_each_tile_on_screen(camera_offset: WorldPos, mut f: impl FnMut(TilePos, S
impl Default for GameState { impl Default for GameState {
fn default() -> Self { fn default() -> Self {
Self { Self {
camera_offset: WorldPos { x: 0, y: 0 }, camera_offset: WorldPos::SURFACE_CENTER,
world: Default::default(), world: Default::default(),
} }
} }

View file

@ -17,6 +17,14 @@ impl WorldPos {
y: wp_to_tp(self.y), y: wp_to_tp(self.y),
} }
} }
/// Horizontal center of the world
pub const CENTER: WorldPosScalar = WorldPosScalar::MAX / 2;
/// Vertical surface level
pub const SURFACE: WorldPosScalar = WorldPosScalar::MAX / 3;
pub const SURFACE_CENTER: Self = Self {
x: Self::CENTER,
y: Self::SURFACE,
};
} }
pub fn wp_to_tp(wp: WorldPosScalar) -> TilePosScalar { pub fn wp_to_tp(wp: WorldPosScalar) -> TilePosScalar {