@richard , I think the sprite’s rendering is using the wrong rounding (Its using x|0 but I think it needs to use Math.round(x),or the opposite for collisions), and it creates that bug. On a wall facing right, the player goes through it. On the wall facing left, the player walks on the air.
(the video quality is bad bc it’s a gif)
6 Likes
YamJam
August 19, 2026, 7:05pm
2
What exactly does that mean? I know this is like galaxies too ahead of my level, but it sounds interesting and I want to know.
nope, this is intended. we don’t use round because it’s slower
2 Likes
looked at the code a little bit, and (v + 128) >> 8 rounds the number:
}
export function ceil(v: Fx8): Fx8 {
return (v as any as number) & 0xff ? Fx.floor(Fx.add(v, Fx.oneFx8)) : v;
}
export function leftShift(a: Fx8, n: number) {
return (a as any as number << n) as any as Fx8
}
export function rightShift(a: Fx8, n: number) {
return (a as any as number >> n) as any as Fx8
}
export function toInt(v: Fx8) {
return ((v as any as number) + 128) >> 8
}
export function toFloat(v: Fx8) {
return (v as any as number) / 256
}
}
@AlexK edit (forgot “rounds”):
looked at the code a little bit, and (v + 128) >> 8 rounds the number:
um @richard i think in the simulator, Math.floor is actually the tiniest bit faster (or at least on some js engines).
1 Like
(oops i accidentaly replied to YamJam)
1 Like
It needs to be faster on hardware, and bitwise ops are definitely the fastest there.
maybe use shims? That makes the most sense because you could have the js version use Math.floor, and the cpp version use bitwise ops