Merge branch 'dev' of rebillar/GrandTabernacleAutoVI into master

This commit is contained in:
Baptiste Rebillard 2024-01-01 18:38:52 +01:00 committed by Gitea
commit 91da027e8e
10 changed files with 95 additions and 69 deletions

View file

@ -85,6 +85,23 @@ html, body{
text-align: center; text-align: center;
} }
.concordRemoveBtn{
width: 15px;
height: 15px;
padding: 0px;
line-height: 0px;
cursor: pointer;
color: white;
background-color: transparent;
border-radius: 7.5px;
font-size: 10px;
border: 2px solid white;
box-sizing: border-box;
position: absolute;
top: 2px;
right: 2px;
}
#chatInput{ #chatInput{
width: 90%; width: 90%;
box-sizing: border-box; box-sizing: border-box;
@ -103,6 +120,7 @@ html, body{
color: white; color: white;
font-family: sans-serif; font-family: sans-serif;
margin: 3%; margin: 3%;
position: relative;
} }
.messageTitle{ .messageTitle{

View file

@ -35,6 +35,11 @@
<div id="chatMessages"> <div id="chatMessages">
</div> </div>
<div id="chatInputDiv">
<input type="text" placeholder="Ecrivez un message ici" id="chatInput" onkeydown="phone.keyPress(this)">
</div>
<div id="content"> <div id="content">
<img src="./assets/phone/concord.png" class="icon" id="appli-concord"> <img src="./assets/phone/concord.png" class="icon" id="appli-concord">
<img src="./assets/logo.png" class="icon" id="appli-gta6"> <img src="./assets/logo.png" class="icon" id="appli-gta6">
@ -45,9 +50,7 @@
<img src="./assets/phone/lester.jpeg" class="icon" id="appli-lest" style="display:none"> <img src="./assets/phone/lester.jpeg" class="icon" id="appli-lest" style="display:none">
</div> </div>
<iframe id="webview" style="overflow: hidden;"></iframe> <iframe id="webview" style="overflow: hidden;"></iframe>
<div id="chatInputDiv">
<input type="text" placeholder="Ecrivez un message ici" id="chatInput" onkeydown="phone.keyPress(this)">
</div>
</div> </div>
</div> </div>
</div> </div>

View file

@ -394,19 +394,20 @@ class PNJ{
} }
checkCollisions(){ checkCollisions(){
let colliding = false;
map0Squares.forEach((square) => { map0Squares.forEach((square) => {
if(square.collide(this.x,this.y,this.z)) if(square.collide(this.x,this.y,this.z))
{ {
return true; colliding = true;
} }
}); });
circles.forEach((circle) => { map0Circles.forEach((circle) => {
if(circle.collide(this.x,this.y,this.z)) if(circle.collide(this.x,this.y,this.z))
{ {
return true; colliding = true;
} }
}); });
return false; return colliding;
} }
changeDirection(){ changeDirection(){

View file

@ -1,4 +1,4 @@
function getCookie(name) {//Code from OpenClassroom function getCookie(name) {
nom = name + "="; nom = name + "=";
var liste = document.cookie.split (';'); var liste = document.cookie.split (';');
for (var i = 0; i < liste.length; i++) { for (var i = 0; i < liste.length; i++) {

View file

@ -175,15 +175,15 @@ let lastbulletdonjon=[0,0]
function Donjon() { function Donjon() {
if(player.z==10) { if(player.z==10) {
if(lastbulletdonjon[1]>=7) { if(lastbulletdonjon[1]>=7) {
lastbulletdonjon[1]=0 lastbulletdonjon[1]=0;
bullets.push(new Bullet(107,95+(Date.now()*0.1)%365,10,1,0,-2, true)); bullets.push(new Bullet(107,95+(Date.now()*0.1)%365,10,1,0,-2, true));
bullets.push(new Bullet(107,460-(Date.now()*0.1)%365,10,1,0,-2, true)); bullets.push(new Bullet(107,460-(Date.now()*0.1)%365,10,1,0,-2, true));
} else { } else {
lastbulletdonjon[1]++ lastbulletdonjon[1]++;
} }
if(lastbulletdonjon[0]==59 && Math.floor(Date.now()/1000)%60 !=59) { lastbulletdonjon[0]=0 } if(lastbulletdonjon[0]==59 && Math.floor(Date.now()/1000)%60 !=59) { lastbulletdonjon[0]=0 }
if(Math.floor(Date.now()/1000)%60 > lastbulletdonjon[0]) { if(Math.floor(Date.now()/1000)%60 > lastbulletdonjon[0]) {
lastbulletdonjon[0]=Math.floor(Date.now()/1000)%60 lastbulletdonjon[0]=Math.floor(Date.now()/1000)%60;
for(let i=0;i<5;i++){ for(let i=0;i<5;i++){
bullets.push(new Bullet(235,65,10,0,2,-2, true)); bullets.push(new Bullet(235,65,10,0,2,-2, true));
bullets.push(new Bullet(235,491,10,0,-2,-2, true)); bullets.push(new Bullet(235,491,10,0,-2,-2, true));
@ -199,32 +199,32 @@ function Donjon() {
function Lester(type, data) { function Lester(type, data) {
switch(type) { switch(type) {
case 1: case 1:
player.x=data[0] player.x=data[0];
player.y=data[1] player.y=data[1];
player.z=data[2] player.z=data[2];
net.update(player); net.update(player);
break; break;
case 2: case 2:
player.health=defaulthealth player.health=defaulthealth;
break; break;
case 3: case 3:
addKill(data, player.id) addKill(data, player.id);
net.died(data, player.id) net.died(data, player.id);
break; break;
case 4: case 4:
players.forEach((p) => { players.forEach((p) => {
if(p.id>0) { if(p.id>0) {
net.died(p.id, player.id) net.died(p.id, player.id);
addKill(data, player.id) addKill(data, player.id);
p.death++ p.death++;
} }
}); });
break; break;
case 5: case 5:
if(drawCollisions) { if(drawCollisions) {
drawCollisions=false drawCollisions=false;
} else { } else {
drawCollisions=true drawCollisions=true;
} }
break; break;
} }

View file

@ -1,6 +1,6 @@
class Input { class Input {
constructor(idCanvas) { constructor(idCanvas) {
this.keysDown = new Set() this.keysDown = new Set();
this.dir = 0; this.dir = 0;
this.canvas = document.getElementById(idCanvas); this.canvas = document.getElementById(idCanvas);
@ -33,20 +33,19 @@ class Input {
}); });
window.addEventListener("keydown", (e)=>{ window.addEventListener("keydown", (e)=>{
//blocks the action of the key (cf. Killian)
if(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(e.code)) { if(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(e.code)) {
e.preventDefault(); e.preventDefault();
} }
this.keysDown.add(e.key.toLowerCase()) this.keysDown.add(e.key.toLowerCase());
this.updateDir(); this.updateDir();
}) })
document.getElementById("retour_menu").addEventListener("click", (e) => { document.getElementById("retour_menu").addEventListener("click", (e) => {
phone.changeWindow(1) phone.changeWindow(1);
}); });
window.addEventListener("keyup", (e)=>{ window.addEventListener("keyup", (e)=>{
this.keysDown.delete(e.key.toLowerCase()) this.keysDown.delete(e.key.toLowerCase());
this.updateDir(); this.updateDir();
}) })
@ -97,10 +96,4 @@ class Input {
net.update(player); net.update(player);
} }
} }
/*
calculateAngle(playerX, playerY) {
return Math.atan2(this.mouseY - playerY, this.mouseX - playerX);
}
*/
} }

View file

@ -58,14 +58,5 @@ class LeaderBoard {
this.nbjoueur++; this.nbjoueur++;
} }
}); });
/*this.ctx.fillText('1', this.px+20, this.py+120);
this.ctx.fillText('Player1', this.px+50, this.py+120);
this.ctx.fillText('10/20', this.px+180, this.py+120);
this.ctx.fillText('2', this.px+20, this.py+120+20);
this.ctx.fillText('Player2', this.px+50, this.py+120+20);
this.ctx.fillText('10/2', this.px+180, this.py+120+20);
*/
} }
} }

View file

@ -47,7 +47,7 @@ class Network{
if(data.data.player_id == player.id){ if(data.data.player_id == player.id){
alert("Vous avez essayé de tricher, vous jouez maintenant en solo."); alert("Vous avez essayé de tricher, vous jouez maintenant en solo.");
}else{ }else{
console.log("Player " + data.data.player_id.toString() + " caught cheating.") console.log("Player " + data.data.player_id.toString() + " caught cheating.");
} }
break; break;

View file

@ -9,39 +9,39 @@ class Phone{
this.inputDiv = document.getElementById("chatInputDiv"); this.inputDiv = document.getElementById("chatInputDiv");
this.webview = document.getElementById("webview"); this.webview = document.getElementById("webview");
this.webviewName = "Erreur" this.webviewName = "Erreur";
this.chargeMainPage(); this.chargeMainPage();
this.changeWindow(1) this.changeWindow(1);
} }
chargeMainPage() { chargeMainPage() {
document.getElementById("appli-concord").addEventListener("click", (e) => { document.getElementById("appli-concord").addEventListener("click", (e) => {
this.changeWindow(2) this.changeWindow(2);
}); });
document.getElementById("appli-gta6").addEventListener("click", (e) => { document.getElementById("appli-gta6").addEventListener("click", (e) => {
this.webviewName = "GTA 6" this.webviewName = "GTA 6";
this.changeWindow("game.html") this.changeWindow("game.html");
}); });
document.getElementById("appli-vbuks").addEventListener("click", (e) => { document.getElementById("appli-vbuks").addEventListener("click", (e) => {
this.webviewName = "Free Vbucks" this.webviewName = "Free Vbucks";
this.changeWindow("assets/phone/webview/vbucks.html") this.changeWindow("assets/phone/webview/vbucks.html");
}); });
document.getElementById("appli-fb").addEventListener("click", (e) => { document.getElementById("appli-fb").addEventListener("click", (e) => {
this.webviewName = "FakeBook" this.webviewName = "FakeBook";
this.changeWindow("assets/phone/webview/fb.html") this.changeWindow("assets/phone/webview/fb.html");
}); });
document.getElementById("appli-utube").addEventListener("click", (e) => { document.getElementById("appli-utube").addEventListener("click", (e) => {
this.webviewName = "uTube" this.webviewName = "uTube";
this.changeWindow("assets/phone/webview/utube.html") this.changeWindow("assets/phone/webview/utube.html");
}); });
document.getElementById("appli-goo").addEventListener("click", (e) => { document.getElementById("appli-goo").addEventListener("click", (e) => {
this.webviewName = "Gogole" this.webviewName = "Gogole";
this.changeWindow("https://mrdoob.com/projects/chromeexperiments/google-space/") this.changeWindow("https://mrdoob.com/projects/chromeexperiments/google-space/");
}); });
document.getElementById("appli-lest").addEventListener("click", (e) => { document.getElementById("appli-lest").addEventListener("click", (e) => {
this.webviewName = "Lester" this.webviewName = "Lester";
this.changeWindow("assets/phone/webview/lester.html") this.changeWindow("assets/phone/webview/lester.html");
}); });
} }
@ -57,11 +57,11 @@ class Phone{
switch (window) { switch (window) {
case 1: case 1:
this.name.innerText = "Pear phone" this.name.innerText = "Pear phone";
this.content.style.display="block"; this.content.style.display="block";
break; break;
case 2: case 2:
this.name.innerText = "Concord" this.name.innerText = "Concord";
this.contentmsg.style.display="block"; this.contentmsg.style.display="block";
this.inputDiv.style.display="block"; this.inputDiv.style.display="block";
break; break;
@ -86,6 +86,13 @@ class Phone{
h2.className = "messageTitle"; h2.className = "messageTitle";
h2.innerText = message.title; h2.innerText = message.title;
let btn = document.createElement("button");
btn.className = "concordRemoveBtn"
btn.innerText = "X"
btn.onclick = ()=>{
msg.remove();
}
let p; let p;
let match = message.content.match(/:(\w+):/); let match = message.content.match(/:(\w+):/);
if(match){ if(match){
@ -100,6 +107,7 @@ class Phone{
msg.appendChild(h2); msg.appendChild(h2);
msg.appendChild(p); msg.appendChild(p);
msg.appendChild(btn)
this.contentmsg.appendChild(msg); this.contentmsg.appendChild(msg);
this.contentmsg.scrollTop = this.contentmsg.scrollHeight; this.contentmsg.scrollTop = this.contentmsg.scrollHeight;
@ -114,7 +122,15 @@ class Phone{
} }
} }
clearMessages(){
let messages = document.getElementsByClassName("message");
for (var i = messages.length - 1; i >= 0; i--) {
messages[i].remove();
}
}
sendMessage(title, content){ sendMessage(title, content){
if(content.toLowerCase() != "clear"){
let message = { let message = {
playerId: player.id, playerId: player.id,
title: player.name, title: player.name,
@ -122,6 +138,10 @@ class Phone{
} }
this.addMessage(message); this.addMessage(message);
net.sendMessage(title, content); net.sendMessage(title, content);
}else{
this.clearMessages();
}
} }
keyPress(input){ keyPress(input){
@ -129,7 +149,7 @@ class Phone{
if(input.value!=''){ if(input.value!=''){
this.sendMessage(player.name, input.value); this.sendMessage(player.name, input.value);
input.value = ''; input.value = '';
input.blur() input.blur();
} }
} }
} }

View file

@ -8,6 +8,6 @@ class Sound{
play(){ play(){
//this.sound.pause() //this.sound.pause()
this.sound.currentTime=0; this.sound.currentTime=0;
this.sound.play() this.sound.play();
} }
} }