Ajout du renderer

This commit is contained in:
Baptiste 2023-11-14 16:58:06 +01:00
parent 33f9086c43
commit 262e07b286
3 changed files with 34 additions and 2 deletions

View file

@ -0,0 +1,7 @@
setInterval(game);
function game() {
Renderer = new Render("canvas")
Renderer.AddPlayer(3, 5, )
}

View file

@ -1,10 +1,11 @@
<html>
<head>
<link rel="stylesheet" href="./style.css">
<script type="text/javascipt" src="./game.js" defer></script>
<script type="text/javascript" src="render.js" defer></script>
<script type="text/javascript" src="game.js" defer></script>
</head>
<body>
<canvas width="800" height="800" id="Canvas" style="border: 1px;"></canvas>
<canvas width="800" height="800" id="canvas" style="border: 1px;"></canvas>
</body>
</html>

24
render.js Normal file
View file

@ -0,0 +1,24 @@
class Render {
constructor(id) {
this.canvas = document.getElementById(id)
this.ctx = canvas.getContext("2d")
this.ReloadAff()
}
ReloadAff() {
this.ctx.fillStyle = "red"
this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height);
/*this.ctx.stokeStyle = "black"
this.ctx.lineWidth = 1;
ctx.beginPath();
ctx.moveTo(point1[0], point1[1]);
ctx.lineTo(point2[0], point2[1]);
ctx.lineTo(point3[0], point3[1]);
ctx.lineTo(point1[0], point1[1]);
ctx.stroke()
ctx.fill();*/
this.ctx.closePath();
this.ctx
}
}