diff --git a/frontend/static/js/views/PongOfflineView.js b/frontend/static/js/views/PongOfflineView.js index a07756b..f85cf61 100644 --- a/frontend/static/js/views/PongOfflineView.js +++ b/frontend/static/js/views/PongOfflineView.js @@ -181,9 +181,9 @@ export class PongOfflineView extends AbstractAuthenticatedView { this.createButton(); } - if (this.round >= 0) { + if (this.round >= 0) await this.display_tree_tournament(); - } + document.getElementById('startTournament').hidden = 1; document.getElementById('startGameButton').hidden = 1; document.getElementById('stopGameButton').hidden = 0; @@ -310,7 +310,7 @@ class Game { ]; this.ballStartSide = 0; this.ballRespawned = false; - this.ball = new Ball(this.def, this.ballStartSide); + this.ball = new Ball(this.def, this.ballStartSide, this.context); this.interval = setInterval(this.updateGame.bind(this), 10); @@ -424,10 +424,6 @@ class Game { updateGame() { //Paddle movement - /*let log = document.getElementById("log"); - console.log(log); - log.setAttribute("log", this.keys) - log.innerText = "keys: " + log.getAttribute("log");*/ if ((this.keys.includes('s') || this.keys.includes('down1')) && this.players[0].paddle.y + this.def.PADDLEHEIGHT < this.def.CANVASHEIGHT - this.def.PADDLEMARGIN) this.players[0].paddle.y += this.def.PADDLESPEED; @@ -508,7 +504,7 @@ class Game { } else { this.scoresDisplay.innerHTML = `${this.player_name1}: ${p1Score} - ${this.player_name2}: ${p2Score}`; this.ballStartSide = 1 - this.ballStartSide; - this.ball = new Ball(this.context, this.def, this.ballStartSide); + this.ball = new Ball(this.def, this.ballStartSide, this.context); this.ballRespawned = true; new Promise(r => setTimeout(r, 300)) .then(_ => this.ballRespawned = false); @@ -627,7 +623,7 @@ class Paddle { } class Ball { - constructor(def, startSide) { + constructor(def, startSide, ctx) { this.radius = def.BALLRADIUS; this.speed = def.BALLSPEED; this.x = def.CANVASWIDTH / 2; @@ -638,7 +634,7 @@ class Ball { else this.vx = this.speed; this.def = def; - this.update(); + this.update(ctx); } update(ctx) {