☄️🐄 Checkpoint

./stats.json:9949330/38
./server.js:9949330/617
This commit is contained in:
Glitch (hello-express) 2020-03-17 14:51:37 +00:00
parent 3485ff4a3e
commit 7f109c05c5
2 changed files with 7 additions and 6 deletions

View File

@ -73,10 +73,9 @@ client.on("a", (msg) => {
var pos = {x: (Math.random() * 100) - 50, y: (Math.random() * 100) - 50};
var vel = {x: 2/5, y: 2/7};
var stats = {
cornerhits: 0,
edgehits: 0
}
var statsraw = fs.readFileSync('stats.json');
var stats = JSON.parse(statsraw);
console.log(stats);
var cursor = setInterval(function() {
client.sendArray([{m:'m', x: client.getOwnParticipant().x = pos.x + 50, y: client.getOwnParticipant().y = pos.y + 50}]);
@ -110,12 +109,13 @@ var cursorupdate = setInterval(function() {
} else if ((pos.x >= 50) || (pos.y >= 50) || (pos.y <= -50) || (pos.x <= -50)) {
stats.edgehits += 1;
}
break;
fs.writeFile("stats.json", JSON.stringify(stats), {
let statsjson = JSON.stringify(stats);
fs.writeFile("stats.json", statsjson, 'utf8', function (err) {
if (err) {
console.log("stats.json couldn't be saved!");
return console.log(err);
}
});
break;
}
}, 25);

1
stats.json Normal file
View File

@ -0,0 +1 @@
{"edgehits":105,"cornerhits":0}