Skip to content

Commit

Permalink
bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Vital-Vuillaume committed Jul 7, 2024
1 parent 911fb48 commit 7133f4a
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 23 deletions.
24 changes: 24 additions & 0 deletions Site/Css/pixel-adventure-desktop.css
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion Site/Css/respensive.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@media screen and (max-height: 1150px) {
.menu {

height: 70vh;
height: 85vh;

}
}
Expand Down
34 changes: 23 additions & 11 deletions Site/Js/JsGame/heart.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
10 changes: 6 additions & 4 deletions Site/Js/JsGame/play.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}}
})
){
Expand Down Expand Up @@ -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);
}
Expand Down
10 changes: 5 additions & 5 deletions Site/Js/JsGame/sprite.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -174,7 +174,7 @@ const librarian = {
}),
};

const cartographer = {
const hylda = {
sprite: new Sprite({
position: {
x: canvas.width / 2 - 220,
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions Site/Js/JsSite/menu.js
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
2 changes: 2 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
</head>

<body>
<div class="bgHeartLess"></div>

<div class="menu">
<div class="reprendre btn">Reprendre</div>
<div class="size">
Expand Down

0 comments on commit 7133f4a

Please sign in to comment.