diff --git a/public_html/assets/sounds/9mm-pistol-shot-6349.mp3 b/public_html/assets/sounds/9mm-pistol-shot-6349.mp3 deleted file mode 100644 index ce7c13c..0000000 Binary files a/public_html/assets/sounds/9mm-pistol-shot-6349.mp3 and /dev/null differ diff --git a/public_html/assets/sounds/notification.mp3 b/public_html/assets/sounds/notification.mp3 new file mode 100644 index 0000000..352774a Binary files /dev/null and b/public_html/assets/sounds/notification.mp3 differ diff --git a/public_html/assets/water_background.jpg b/public_html/assets/water_background.jpg deleted file mode 100644 index d0ddfb1..0000000 Binary files a/public_html/assets/water_background.jpg and /dev/null differ diff --git a/public_html/assets/water_background2.jpg b/public_html/assets/water_background2.jpg deleted file mode 100644 index 172ef89..0000000 Binary files a/public_html/assets/water_background2.jpg and /dev/null differ diff --git a/public_html/css/game.css b/public_html/css/game.css index 2a132b4..f2e4ce5 100644 --- a/public_html/css/game.css +++ b/public_html/css/game.css @@ -28,6 +28,12 @@ html, body{ user-select: none; } +#phoneContainer.notification{ + position: absolute; + right: 20px; + top: calc(100% - 40px); +} + #phoneDiv{ position: relative; } diff --git a/public_html/js/global.js b/public_html/js/global.js index 7347171..3972c8d 100644 --- a/public_html/js/global.js +++ b/public_html/js/global.js @@ -4,6 +4,7 @@ let renderer = new Render("canvas"); let LB = new LeaderBoard("canvas"); let bulletSound = new Sound("./assets/sounds/shoot.mp3"); let driftSound = new Sound("./assets/sounds/drift.mp3"); +let notificationSound = new Sound("./assets/sounds/notification.mp3"); let net = new Network("wss://ws.gta6.insat.fr:8080?name=" + getCookie("pseudo")); let inp = new Input("canvas"); let phone = new Phone(); diff --git a/public_html/js/phone.js b/public_html/js/phone.js index cb915cd..93602de 100644 --- a/public_html/js/phone.js +++ b/public_html/js/phone.js @@ -1,6 +1,6 @@ class Phone{ constructor(){ - this.position = 0; + this.position = 0; //0: hidden 1: visible 2: notification this.messages = []; this.name = document.getElementById("TitlePage"); @@ -99,10 +99,20 @@ class Phone{ this.contentmsg.appendChild(msg); this.contentmsg.scrollTop = this.contentmsg.scrollHeight; + + //notification + if(message.playerId!=player.id){ + notificationSound.play(); + if(this.position == 0){ + this.position = 2; + document.getElementById("phoneContainer").className = "notification"; + } + } } sendMessage(title, content){ let message = { + playerId: player.id, title: player.name, content: content } @@ -122,7 +132,7 @@ class Phone{ changePosition(){ if(!document.getElementById("phoneContainer").contains(document.activeElement)){ - if(this.position == 0){ + if(this.position == 0 || this.position == 2){ document.getElementById("phoneContainer").className = "visible"; this.position = 1; }else{