diff --git a/main.js b/main.js index 9e7bfe8..fc273ca 100644 --- a/main.js +++ b/main.js @@ -8,6 +8,10 @@ const Orientation = { RIGHT: 'right' } +function bound(low, x, high) { + return Math.max(low, Math.min(x, high)); +} + class Input { constructor() { this.up = false; @@ -524,7 +528,7 @@ function setCanvasScale(scale) { function setAutoCanvasScale() { const widthAspect = Math.floor(window.innerWidth / SNES_WIDTH); const heightAspect = Math.floor(window.innerHeight / SNES_HEIGHT); - const scale = Math.min(widthAspect, heightAspect) + const scale = bound(1, Math.min(widthAspect, heightAspect), 8); setCanvasScale(scale); }