Skip to content

Commit 5e84c12

Browse files
jobo3208marijnh
authored andcommitted
Ch. 16: Allow smaller canvas for smaller level
1 parent 648ae8d commit 5e84c12

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

16_canvas.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -835,8 +835,8 @@ standing still, it keeps facing the direction it last moved in.
835835
----
836836
function CanvasDisplay(parent, level) {
837837
this.canvas = document.createElement("canvas");
838-
this.canvas.width = 600;
839-
this.canvas.height = 450;
838+
this.canvas.width = Math.min(600, level.width * scale);
839+
this.canvas.height = Math.min(450, level.height * scale);
840840
parent.appendChild(this.canvas);
841841
this.cx = this.canvas.getContext("2d");
842842

0 commit comments

Comments
 (0)