finished ch 9

This commit is contained in:
2024-10-23 11:14:14 -05:00
parent 1e756f4f72
commit e48567fa30
11 changed files with 163 additions and 0 deletions

10
10/index.html Normal file
View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<title>Tennjs</title>
</head>
<body>
<canvas id="canvas" width="300" height="300"></canvas>
<script src="script.js"></script>
</body>
</html>

12
10/script.js Normal file
View File

@ -0,0 +1,12 @@
let canvas = document.querySelector("#canvas");
let ctx = canvas.getContext("2d");
let width = canvas.width;
let height = canvas.height;
const BALL_SIZE = 5;
let ballPosition = {x: 20, y: 30};
function draw() {
ctx.fillStyle = "black"; ctx.fillRect(0, 0, width, height);
ctx.fillStyle = "white";
ctx.fillRect(ballPosition.x, ballPosition.y, BALL_SIZE, BALL_SIZE);
}
draw();