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;
}
.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{
width: 90%;
box-sizing: border-box;
@ -103,6 +120,7 @@ html, body{
color: white;
font-family: sans-serif;
margin: 3%;
position: relative;
}
.messageTitle{

View file

@ -35,6 +35,11 @@
<div id="chatMessages">
</div>
<div id="chatInputDiv">
<input type="text" placeholder="Ecrivez un message ici" id="chatInput" onkeydown="phone.keyPress(this)">
</div>
<div id="content">
<img src="./assets/phone/concord.png" class="icon" id="appli-concord">
<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">
</div>
<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>

View file

@ -394,19 +394,20 @@ class PNJ{
}
checkCollisions(){
let colliding = false;
map0Squares.forEach((square) => {
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))
{
return true;
colliding = true;
}
});
return false;
return colliding;
}
changeDirection(){

View file

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

View file

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

View file

@ -1,6 +1,6 @@
class Input {
constructor(idCanvas) {
this.keysDown = new Set()
this.keysDown = new Set();
this.dir = 0;
this.canvas = document.getElementById(idCanvas);
@ -33,20 +33,19 @@ class Input {
});
window.addEventListener("keydown", (e)=>{
//blocks the action of the key (cf. Killian)
if(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(e.code)) {
e.preventDefault();
}
this.keysDown.add(e.key.toLowerCase())
this.keysDown.add(e.key.toLowerCase());
this.updateDir();
})
document.getElementById("retour_menu").addEventListener("click", (e) => {
phone.changeWindow(1)
phone.changeWindow(1);
});
window.addEventListener("keyup", (e)=>{
this.keysDown.delete(e.key.toLowerCase())
this.keysDown.delete(e.key.toLowerCase());
this.updateDir();
})
@ -97,10 +96,4 @@ class Input {
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.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){
alert("Vous avez essayé de tricher, vous jouez maintenant en solo.");
}else{
console.log("Player " + data.data.player_id.toString() + " caught cheating.")
console.log("Player " + data.data.player_id.toString() + " caught cheating.");
}
break;

View file

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

View file

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