From 539ccd2213a9ad0a3685888bd02b18c00a8cefbf Mon Sep 17 00:00:00 2001 From: Killian Marty Date: Mon, 11 Dec 2023 15:03:47 +0100 Subject: [PATCH] phone --- public_html/css/game.css | 70 +++++++++++++++++++++++++++++++++++++++ public_html/game.html | 18 ++++++++++ public_html/js/class.js | 2 +- public_html/js/global.js | 4 +-- public_html/js/network.js | 7 ++++ 5 files changed, 98 insertions(+), 3 deletions(-) diff --git a/public_html/css/game.css b/public_html/css/game.css index 223fdda..c65961b 100644 --- a/public_html/css/game.css +++ b/public_html/css/game.css @@ -10,4 +10,74 @@ html, body{ #canvas{ max-height: 100vh; max-width: 100vw; +} + +#phoneDiv{ + position: relative; +} + +#phone{ + width: 200px; +} +#phoneScreen{ + background-color: 524b4a; + position: absolute; + left: 7%; + top: 12%; + right: 7%; + bottom: 13%; +} + +#chatHeader{ + height: 10%; + width: 100%; + border-bottom: 1px solid black; + text-align: center; + color: white; + line-height: 7%; + padding: 0px; + overflow: hidden; +} + +#chatHeader > p{ + line-height: 10%; +} + +#chatMessages{ + height: 80%; + width: 100%; +} +#chatInputDiv{ + height: 10%; + width: 100%; + text-align: center; +} + +#chatInput{ + width: 90%; + box-sizing: border-box; + appearance: none; + background-color: transparent; + border-radius: 10px; + border: 1px solid black; + color: white; + padding-left: 10px; + height: 85%; + margin-bottom: 15%; + outline: none; +} + +.message{ + color: white; + font-family: sans-serif; +} + +.messageTitle{ + font-size: 75%; + margin: 0px; +} + +.messageContent{ + margin: 0px; + font-size: 60%; } \ No newline at end of file diff --git a/public_html/game.html b/public_html/game.html index f58e450..d8cadb6 100644 --- a/public_html/game.html +++ b/public_html/game.html @@ -3,6 +3,7 @@ + @@ -16,6 +17,23 @@ +
+ Phone +
+
+

Concorde

+
+
+
+

Killian

+

yo les gars

+
+
+
+ +
+
+
diff --git a/public_html/js/class.js b/public_html/js/class.js index 67d5642..a79c5b5 100644 --- a/public_html/js/class.js +++ b/public_html/js/class.js @@ -220,7 +220,7 @@ class Car Update() { - if(this.tick==0 && new Date().getSeconds()%20==this.spawn) { + if(this.tick==0 && (new Date()).getSeconds()%20==this.spawn) { this.tick=1; } diff --git a/public_html/js/global.js b/public_html/js/global.js index 56bcbd6..e3ee83f 100644 --- a/public_html/js/global.js +++ b/public_html/js/global.js @@ -6,6 +6,7 @@ let bulletSound = new Sound("./assets/sounds/shoot.mp3"); let driftSound = new Sound("./assets/sounds/drift.mp3"); let net = new Network("wss://ws.gta6.insat.fr:8080?name=" + getCookie("pseudo")); let inp = new Input("canvas"); +let phone = new Phone(); let bullets = []; let circles = []; let squares = []; @@ -16,12 +17,11 @@ let PNJS = [new PNJ(500, 100), let cars = [new Car(renderer, 0, 0), new Car(renderer, 0, 7), - new Car(renderer, 1, 7), + new Car(renderer, 1, 3), new Car(renderer, 1, 13), new Car(renderer, 1, 14), new Car(renderer, 0, 15)]; - function updatePlayer(data) { if(data.id==player.id) diff --git a/public_html/js/network.js b/public_html/js/network.js index 0faf7df..fcd9b10 100644 --- a/public_html/js/network.js +++ b/public_html/js/network.js @@ -39,6 +39,9 @@ class Network{ addKill(data.data.id,data.data.killerId); break; + case "message": + phone.addMessage(data.data); + default: console.log("received unknown data:",data); break; @@ -70,4 +73,8 @@ class Network{ { this.socket.send(JSON.stringify({type:"newBullet",data:{x: x,y: y,dx: dx,dy: dy,id:parentId}})); } + + sendMessage(title, content){ + this.socket.send(JSON.stringify({type: "sendMessage", data: {title: title, content: content}})); + } } \ No newline at end of file