Initial commit

This commit is contained in:
Bill Rossi 2025-06-01 15:30:12 -04:00
commit 3abb79af83
3 changed files with 36 additions and 0 deletions

12
index.html Normal file
View File

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<title>Zelder</title>
<script src="src/index.js" type="module"></script>
</head>
<body>
<canvas id="game-canvas" height="600" width="800">
You need a better browser to play this game.
</canvas>
</body>
</html>

16
src/game.js Normal file
View File

@ -0,0 +1,16 @@
export default class Game {
constructor(canvas) {
this.canvas = canvas
this.ctx = canvas.getContext("2d")
}
draw() {
const { canvas, ctx } = this
ctx.clearRect(0, 0, canvas.width, canvas.height)
ctx.beginPath()
ctx.fillColor = "#FF0000"
ctx.rect(200, 100, 80, 50)
ctx.fill()
ctx.closePath()
}
}

8
src/index.js Normal file
View File

@ -0,0 +1,8 @@
import Game from "./game.js"
document.addEventListener("DOMContentLoaded", e => {
console.log("Hello, world!")
const canvas = document.getElementById("game-canvas")
const game = new Game(canvas)
game.draw()
})