From b7e546c67f60b055b4885bd4cdd0fe865d36ece6 Mon Sep 17 00:00:00 2001 From: Killian Marty Date: Sat, 9 Dec 2023 14:57:46 +0100 Subject: [PATCH] pnj --- public_html/js/game.js | 28 ---------------------------- public_html/js/global.js | 28 ++++++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 30 deletions(-) diff --git a/public_html/js/game.js b/public_html/js/game.js index d02f256..ce3672a 100644 --- a/public_html/js/game.js +++ b/public_html/js/game.js @@ -1,31 +1,3 @@ -let cars = [new Car(renderer, 0, 0), - new Car(renderer, 0, 7), - new Car(renderer, 1, 7), - new Car(renderer, 1, 13), - new Car(renderer, 1, 14), - new Car(renderer, 0, 15)]; - - - - -PNJS.push(new PNJ(500, 100)); -PNJS.push(new PNJ(700, 100)); -PNJS.push(new PNJ(500, 600)); -PNJS.push(new PNJ(200, 700)); - -function updateBullets(dt) -{ - for(let i = bullets.length-1;i>=0;i--) - { - bullets[i].update(dt); - bullets[i].checkCollisions(squares,circles); - if(bullets[i].deleted) - { - bullets.splice(i,1); - } - } -} - let dt = 1.; let currentTime = new Date(); function game() { diff --git a/public_html/js/global.js b/public_html/js/global.js index 39d0137..56bcbd6 100644 --- a/public_html/js/global.js +++ b/public_html/js/global.js @@ -9,7 +9,18 @@ let inp = new Input("canvas"); let bullets = []; let circles = []; let squares = []; -let PNJS = []; +let PNJS = [new PNJ(500, 100), + new PNJ(700, 100), + new PNJ(500, 600), + new PNJ(200, 700)]; + +let cars = [new Car(renderer, 0, 0), + new Car(renderer, 0, 7), + new Car(renderer, 1, 7), + new Car(renderer, 1, 13), + new Car(renderer, 1, 14), + new Car(renderer, 0, 15)]; + function updatePlayer(data) { @@ -62,4 +73,17 @@ function addKill(idKilled,idKiller) if(p.id==idKiller) p.kill++; }); -} \ No newline at end of file +} + +function updateBullets(dt) +{ + for(let i = bullets.length-1;i>=0;i--) + { + bullets[i].update(dt); + bullets[i].checkCollisions(squares,circles); + if(bullets[i].deleted) + { + bullets.splice(i,1); + } + } +}