From 7133f4af79d0a1774807e355477bb322ef80fe76 Mon Sep 17 00:00:00 2001 From: vuillaume Date: Sun, 7 Jul 2024 21:02:33 +0200 Subject: [PATCH] bug --- Site/Css/pixel-adventure-desktop.css | 24 ++++++++++++++++++++ Site/Css/respensive.css | 2 +- Site/Js/JsGame/heart.js | 34 +++++++++++++++++++--------- Site/Js/JsGame/play.js | 10 ++++---- Site/Js/JsGame/sprite.js | 10 ++++---- Site/Js/JsSite/menu.js | 4 ++-- index.html | 2 ++ 7 files changed, 63 insertions(+), 23 deletions(-) diff --git a/Site/Css/pixel-adventure-desktop.css b/Site/Css/pixel-adventure-desktop.css index ef6a6e1..ad9ace5 100644 --- a/Site/Css/pixel-adventure-desktop.css +++ b/Site/Css/pixel-adventure-desktop.css @@ -29,6 +29,30 @@ canvas { } +.bgHeartLess { + + background-color: red; + position: absolute; + width: 100vw; + height: 100vh; + z-index: 1; + left: 50%; + top: 50%; + transform: translate(-50%, -50%); + opacity: 0; + visibility: hidden; + transition: 1.5s; + +} + +.bgHeartLess.active { + + opacity: 0.2; + visibility: visible; + transition: 0s; + +} + /*-----Scroll bar pour webkit-----*/ ::-webkit-scrollbar { diff --git a/Site/Css/respensive.css b/Site/Css/respensive.css index 03dd1f6..f63ceab 100644 --- a/Site/Css/respensive.css +++ b/Site/Css/respensive.css @@ -1,7 +1,7 @@ @media screen and (max-height: 1150px) { .menu { - height: 70vh; + height: 85vh; } } diff --git a/Site/Js/JsGame/heart.js b/Site/Js/JsGame/heart.js index bd87864..43bbb89 100644 --- a/Site/Js/JsGame/heart.js +++ b/Site/Js/JsGame/heart.js @@ -7,32 +7,39 @@ const diedTopaze = document.querySelector(".diedTopaze"); const diedTopazeTxt = document.querySelector(".diedTopazeTxt"); const reprendreDied = document.querySelector(".reprendreDied"); +const bgHeartLess = document.querySelector(".bgHeartLess"); + let heartMax = 3; let heart = heartMax; -let couldown = 0; +let invincible = false function heartChange(heartLess) { - let currentTime = Date.now(); - if (playerSpeed === 3) { + if (invincible) { if (heartLess < 0) { heartLess = 0; } } else { if (heartLess < 0) { - if (currentTime - couldown >= 2000) { + bgHeartLess.classList.add("active"); - couldown = currentTime; + setTimeout(function() { + bgHeartLess.classList.remove("active"); + }, 500); - //player.image = player.sprites.up; + heart += heartLess; - heart += heartLess; + if (musique) { + soundDamage.play(); + } - if (musique) { - soundDamage.play(); - } + if(heart ==! 0) { + invincible = true; + setTimeout(function() { + invincible = false; + }, 2500); } } else { heart += heartLess; @@ -64,11 +71,16 @@ function potionHeartChange(PotionHeartLess) { let diedReprendre = false; -reprendreDied.onclick = function() {; +reprendreDied.onclick = function() { died.classList.remove("active"); body.style.cursor = "none"; menuKeys = false; + invincible = true; + setTimeout(function() { + invincible = false; + }, 2500); + if(!diedReprendre) { heart = heartMax; topazeChange(-2); diff --git a/Site/Js/JsGame/play.js b/Site/Js/JsGame/play.js index 997e63c..fc0bd35 100644 --- a/Site/Js/JsGame/play.js +++ b/Site/Js/JsGame/play.js @@ -428,15 +428,15 @@ function animate() { rectangularCollision({ rectangle1: player, rectangle2: {...boundary, position: { - x: boundary.position.x - 2, - y: boundary.position.y + x: boundary.position.x, + y: boundary.position.y + 2 }} }) || rectangularCollision({ rectangle1: player, rectangle2: {...spriteCollisionsHome.sprite, position: { - x: spriteCollisionsHome.sprite.position.x - 2, - y: spriteCollisionsHome.sprite.position.y + x: spriteCollisionsHome.sprite.position.x, + y: spriteCollisionsHome.sprite.position.y + 2 }} }) ){ @@ -675,8 +675,10 @@ window.addEventListener("keydown", function(e) { if(!menuKeys){ if(PotionSpeed > 0 && playerSpeed === 2) { playerSpeed = 3; + invincible = true; setTimeout(function() { playerSpeed = 2; + invincible = false; }, 10000); potionSpeedChange(-1); } diff --git a/Site/Js/JsGame/sprite.js b/Site/Js/JsGame/sprite.js index d27f8db..13ca17d 100644 --- a/Site/Js/JsGame/sprite.js +++ b/Site/Js/JsGame/sprite.js @@ -37,8 +37,8 @@ dogImage.src = './Site/ImageGame/dog.png'; const librarianImage = new Image(); librarianImage.src = './Site/ImageGame/voyageur.png'; -const cartographerImage = new Image(); -cartographerImage.src = './Site/ImageGame/voyageur.png'; +const hyldaImage = new Image(); +hyldaImage.src = './Site/ImageGame/voyageur.png'; // Map image @@ -174,7 +174,7 @@ const librarian = { }), }; -const cartographer = { +const hylda = { sprite: new Sprite({ position: { x: canvas.width / 2 - 220, @@ -183,11 +183,11 @@ const cartographer = { frames: { max: 4 }, - image: cartographerImage + image: hyldaImage }), }; -const villagersMap = [ragnerus, dog, voyageur, cartographer]; +const villagersMap = [ragnerus, dog, voyageur, hylda]; const villagersHome = [vagabond , chef, georas, librarian]; const villagers = [...villagersMap, ...villagersHome]; const villagersMovable = villagers.map(villager => villager.sprite); diff --git a/Site/Js/JsSite/menu.js b/Site/Js/JsSite/menu.js index 0ebc9f2..e5ad0bc 100644 --- a/Site/Js/JsSite/menu.js +++ b/Site/Js/JsSite/menu.js @@ -1,6 +1,6 @@ -/*if (window.location.protocol != "https:") { +if (window.location.protocol != "https:") { window.location.protocol="https:"; -}*/ +} document.addEventListener("contextmenu", function (event) { event.preventDefault(); diff --git a/index.html b/index.html index 43c7e1c..ed7ef52 100644 --- a/index.html +++ b/index.html @@ -37,6 +37,8 @@ +
+