Initial commit
This commit is contained in:
commit
3abb79af83
12
index.html
Normal file
12
index.html
Normal 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
16
src/game.js
Normal 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
8
src/index.js
Normal 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()
|
||||
})
|
Loading…
Reference in New Issue
Block a user