From eec1013c6c5f3886d3660c5c6d9afe6fda6e484a Mon Sep 17 00:00:00 2001 From: Victor Date: Fri, 8 Dec 2023 20:02:04 +0100 Subject: [PATCH] actually working Date + leaderBoard --- public_html/js/class.js | 9 +++++---- public_html/js/leaderboard.js | 9 ++++----- public_html/js/render.js | 3 +++ 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/public_html/js/class.js b/public_html/js/class.js index 76316bd..c73ea70 100644 --- a/public_html/js/class.js +++ b/public_html/js/class.js @@ -218,9 +218,13 @@ class Car Update() { - if(this.tick==0 && new Date.getSeconds()%20==this.spawn) { + if(this.tick==0 && new Date().getSeconds()%20==this.spawn) { this.tick=1; } + + if(this.tick==0) + return; + this.ChangeDirection(); switch (this.dir) { @@ -238,10 +242,7 @@ class Car break; } if(this.drift > 0) { - renderer.RenderCar(this.x,this.y, this.angle+2.1) this.drift-- - } else { - renderer.RenderCar(this.x,this.y, this.angle) } } diff --git a/public_html/js/leaderboard.js b/public_html/js/leaderboard.js index b6747bb..3940447 100644 --- a/public_html/js/leaderboard.js +++ b/public_html/js/leaderboard.js @@ -3,11 +3,11 @@ class LeaderBoard { this.canvas = document.getElementById(idCanvas); this.ctx = this.canvas.getContext("2d"); this.nbjoueur=0 + this.px=10; + this.py=10; } ReloadAff() { - let px=10; - let py=10; let LBplayers=[]; players.forEach((p) => { if(p != null) { @@ -19,10 +19,9 @@ class LeaderBoard { LBplayers.sort(function (a, b) { return b.kill - a.kill; }); - // tableau du leaderboard (le fonc "blanc") this.ctx.fillStyle = 'rgba(255, 255, 255, 0.7)'; - this.ctx.fillRect(this.px, this.py, this.px+240, this.py+100+this.nbjoueur*20); + this.ctx.fillRect(this.px, this.py, this.px+240, this.py+100+LBplayers.length*20); this.nbjoueur=0; this.ctx.font = '20px Arial'; this.ctx.fillStyle = '#000000'; @@ -38,7 +37,7 @@ class LeaderBoard { this.ctx.lineTo(this.px+250, this.py+100); this.ctx.stroke(); - //donné user + //donnee user this.ctx.fillStyle = '#000000'; this.ctx.font = '15px Arial'; this.ctx.fillText('#', this.px+10, this.py+80); diff --git a/public_html/js/render.js b/public_html/js/render.js index 27c1736..aabfe66 100644 --- a/public_html/js/render.js +++ b/public_html/js/render.js @@ -91,6 +91,9 @@ class Render { this.ctx.canvas.height = mapHeight; this.ctx.drawImage(fond, 0, 0, mapWidth, mapHeight); this.RenderPlayer(player,true); + cars.forEach((car) => { + this.RenderCar(car.x,car.y,car.angle+(car.drift>0?2.1:0)); + }); players.forEach((player) => { this.RenderPlayer(player,false); })