868 B
868 B
| id | name | category | kind | tokens | sig | tip | order | ns | member |
|---|---|---|---|---|---|---|---|---|---|
| math-floor | Math.floor | math | namespace-method | Math.floor | Math.floor(x) -> int | Round a fixed value down to the nearest whole int. | 5 | Math | floor |
Takes a fixed value and returns the largest int not greater than it — rounding toward negative infinity, so Math.floor(2.7) is 2 and Math.floor(-0.2) is -1. This is the fixed-to-int conversion you reach for when turning a smooth position into a whole tile or pixel index. It is the same operation as the bare floor(x).
Parameters:
x— thefixedvalue to round down
program TileIndex {
const TILE_SIZE: fixed = 16.0
let world_x: fixed = 40.5
handler Locate phase Update {
let column = Math.floor(world_x / TILE_SIZE) # 2
}
}