From 52254e20fbdcb69640c62610badb6ad37a0ac39c Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 2 Jan 2024 03:40:42 +0100 Subject: [PATCH] Add Senddata function to send name and score to server --- web/game.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/web/game.js b/web/game.js index d5c46c5..271d1d0 100644 --- a/web/game.js +++ b/web/game.js @@ -163,6 +163,7 @@ async function keyPressed() { nameHS += letters[currentIndex[0]]; nameHS += letters[currentIndex[1]]; nameHS += letters[currentIndex[2]]; + Senddata(nameHS, int(time)); console.log(nameHS + ": " + int(time)); nameHS = ''; keyReleasedFlag = false; @@ -592,4 +593,15 @@ function game() { bullets = bullets.filter(bullet => !bullet.hit); } +} + +function Senddata(naam, score) { + const request = ( url, params = {}) => { + url += '?' + ( new URLSearchParams( params ) ).toString(); + fetch( url ); +}; + const get = ( url, params ) => request( url, params); + + get('https://oege.ie.hva.nl/~hossan/GetData.php', { name: naam, score: score } ); + } \ No newline at end of file