mirror of
https://github.com/Noratrieb/game-wip-dontplay.git
synced 2026-01-16 04:25:00 +01:00
Display player speed in km/h
This commit is contained in:
parent
9b4d0c8cf7
commit
05c516e210
3 changed files with 26 additions and 4 deletions
12
src/math.rs
12
src/math.rs
|
|
@ -9,6 +9,18 @@ pub struct WorldPos {
|
|||
}
|
||||
|
||||
pub const TILE_SIZE: u8 = 32;
|
||||
/// Pixels per meter. One meter = one tile, so this is the same as `TILE_SIZE`.
|
||||
pub const PX_PER_M: u8 = TILE_SIZE;
|
||||
pub const FPS_TARGET: u8 = 60;
|
||||
|
||||
pub fn px_per_frame_to_m_per_s(px_per_frame: f32) -> f32 {
|
||||
let m_per_frame = px_per_frame / PX_PER_M as f32;
|
||||
m_per_frame * FPS_TARGET as f32
|
||||
}
|
||||
|
||||
pub fn px_per_frame_to_km_h(px_per_frame: f32) -> f32 {
|
||||
px_per_frame_to_m_per_s(px_per_frame) * 3.6
|
||||
}
|
||||
|
||||
impl WorldPos {
|
||||
pub fn tile_pos(&self) -> TilePos {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue