Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
638 B
1
Indexable
Never

<html>
  <head>
    <style>
      canvas {
        border: 1px solid #d3d3d3;
        background-color: #f1f1f1;
      }
    </style>
  </head>
  <body>
    <canvas id="gameCanvas" width="480" height="320"></canvas>
    <script>
      var canvas = document.getElementById("gameCanvas");
      var ctx = canvas.getContext("2d");
      var x = canvas.width / 2;
      var y = canvas.height - 30;
      var dx = 2;
      var dy = -2;
      function draw() {
        ctx.clearRect(0, 0, canvas.width, canvas.height);
        // draw the game elements
        requestAnimationFrame(draw);
      }
      draw();
    </script>
  </body>
</html>
Leave a Comment