Hey everyone, I’m working on a little pixel-art platformer in Canvas 2D and I’m trying to get the camera follow to feel smooth without the world “swimming” from subpixel rendering. If I round the camera to whole pixels it looks crisp but the motion feels choppy, and if I don’t round it gets blurry/jittery during slow pans.
const scale = 4;
const cam = { x: 0, y: 0 };
function render(ctx, player) {
cam.x += (player.x - cam.x - 80) * 0.12;
cam.y += (player.y - cam.y - 60) * 0.12;
const rx = Math.round(cam.x);
const ry = Math.round(cam.y);
ctx.setTransform(scale, 0, 0, scale, -rx * scale, -ry * scale);
drawTilemap(ctx);
drawSprites(ctx);
}
What’s a solid approach people use here so the camera stays crisp and stable while still feeling smooth (especially at low speeds) without introducing visible snapping artifacts?
Quelly