From 88e852c9e05b72f20a70b8a6d096c0d6f6401ac6 Mon Sep 17 00:00:00 2001 From: vvandenb Date: Mon, 13 Mar 2023 16:18:43 +0100 Subject: [PATCH] * Pong: Added separation line --- front/volume/src/components/Pong/Game.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/front/volume/src/components/Pong/Game.ts b/front/volume/src/components/Pong/Game.ts index 4088ea9..8a99c3a 100644 --- a/front/volume/src/components/Pong/Game.ts +++ b/front/volume/src/components/Pong/Game.ts @@ -130,13 +130,25 @@ export class Game { } draw() { + //Background this.context.fillStyle = this.backgroundColor; this.context.fillRect(0, 0, this.canvas.width, this.canvas.height); + //Draw lines in middle of game + this.context.beginPath(); + this.context.setLineDash([10, 20]); + this.context.moveTo(this.canvas.width / 2, 0); + this.context.lineTo(this.canvas.width / 2, this.canvas.height); + this.context.strokeStyle = this.elementsColor; + this.context.lineWidth = 5; + this.context.stroke(); + + //Elements this.walls.forEach((w) => w.draw(this.context, this.elementsColor)); this.players.forEach((p) => p.draw(this.context, this.elementsColor)); this.ball.draw(this.context, this.elementsColor); + //Score const max_width = 50; this.context.font = "50px Arial"; const text_width = this.context.measureText("0").width;