GrandTabernacleAutoVI/public_html/js/game.js

39 lines
678 B
JavaScript
Raw Normal View History

2023-12-09 15:03:48 +01:00
let dt = 0;
2023-11-29 19:03:50 +01:00
let currentTime = new Date();
2023-11-15 09:09:13 +01:00
function game() {
2023-12-08 18:41:57 +01:00
if(player==null)
2023-12-08 18:02:42 +01:00
return;
player.update(squares, circles, dt);
for (let i = 0;i<players.length; i++) {
players[i].update(squares, circles, dt);
2023-11-29 17:25:40 +01:00
}
2023-12-09 10:58:00 +01:00
2023-12-08 18:02:42 +01:00
cars.forEach((c) => {
2023-12-12 13:53:41 +01:00
c.Update(dt);
2023-12-08 18:02:42 +01:00
if(c.collide(player.x,player.y))
{
net.died(player.id,-1);
player.x=-50;
player.deaths++;
player.health=10;
2023-11-29 17:25:40 +01:00
}
2023-12-08 18:02:42 +01:00
});
2023-12-09 14:53:07 +01:00
PNJS.forEach((pnj)=>{
pnj.update(dt);
})
2023-12-08 18:02:42 +01:00
updateBullets(dt);
2023-12-08 18:41:57 +01:00
renderer.ReloadAff();
2023-12-08 18:02:42 +01:00
LB.ReloadAff();
2023-11-29 19:03:50 +01:00
let newTime = new Date();
dt=newTime - currentTime;
2023-12-06 09:50:34 +01:00
currentTime=newTime;
2023-11-19 19:20:02 +01:00
}
2023-12-08 18:02:42 +01:00
net.connect(); //connect to server, create a player, and retrieve all players info
2023-11-29 17:06:30 +01:00
2023-12-06 09:50:34 +01:00
setInterval(game);