diff options
Diffstat (limited to 'js/canvas/game.js')
-rw-r--r-- | js/canvas/game.js | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/js/canvas/game.js b/js/canvas/game.js index 569cc4c..7b02bde 100644 --- a/js/canvas/game.js +++ b/js/canvas/game.js @@ -12,7 +12,6 @@ const ctx = canvas.getContext("2d"); ctx.fillStyle = "#e0f8cf"; ctx.fillRect(0, 0, canvas.width, canvas.height); - // create a rectangle const rect = { x: 50, @@ -21,14 +20,13 @@ const rect = { height: 16, step: 12, color: "#65ff00", - colorAlt: "pink", + colorAlt: "pink" }; // draw the rectangle ctx.fillStyle = rect.color; ctx.fillRect(rect.x, rect.y, rect.width, rect.height); - // move the rectangle rect.x += 5; @@ -39,7 +37,6 @@ ctx.clearRect(0, 0, canvas.width, canvas.height); ctx.fillStyle = rect.color; ctx.fillRect(rect.x, rect.y, rect.width, rect.height); - // add keyboard input document.addEventListener("keydown", (event) => { switch (event.code) { @@ -88,4 +85,4 @@ function gameLoop() { } // start the game loop -requestAnimationFrame(gameLoop); \ No newline at end of file +requestAnimationFrame(gameLoop); |