From 17446bf1f01d59095f747b8edb8d0df931445b5d Mon Sep 17 00:00:00 2001 From: Baptiste Date: Thu, 7 Dec 2023 10:03:55 +0100 Subject: [PATCH] car --- js/class.js | 2 +- js/game.js | 3 +++ js/render.js | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/js/class.js b/js/class.js index 14f682f..6e157bb 100644 --- a/js/class.js +++ b/js/class.js @@ -1,7 +1,7 @@ let mapWidth = 210.; let mapHeith = 100.; const playerSize = 50.; -const carSize = 50.; +const carSize = 40.; const playerSpeed=.2; const bulletSpeed=playerSpeed*2; const halfSqrtTwo=0.70710678118; diff --git a/js/game.js b/js/game.js index 6e59f05..72c3c1f 100644 --- a/js/game.js +++ b/js/game.js @@ -108,6 +108,7 @@ function updateBullets(dt) } let currentTime = new Date(); +let carx=0 function game() { if(playerId==null) { @@ -146,12 +147,14 @@ function game() { } Renderer.ReloadAff(); updateBullets(dt); + Renderer.RenderCar(200+carx,75, 0); LB.ReloadAff(players, player); } let newTime = new Date(); dt=newTime - currentTime; currentTime=newTime; + carx=carx+3 } Net.connect(); //connect to server, create a player, and retrieve all players info diff --git a/js/render.js b/js/render.js index 0ee1067..8301540 100644 --- a/js/render.js +++ b/js/render.js @@ -69,7 +69,7 @@ class Render { this.ctx.save(); this.ctx.translate(x, y); this.ctx.rotate(angle); - this.ctx.drawImage(imgCar, -carSize / 2, -carSize / 2, carSize, carSize); + this.ctx.drawImage(imgCar, -carSize*1513/750 / 2, -carSize / 2, carSize*1513/750, carSize); this.ctx.restore(); }