mirror of
https://github.com/zyllian/zyllian.github.io.git
synced 2025-01-18 03:32:30 -08:00
add the grayscale filter to the pet when unhappy
This commit is contained in:
parent
f1c25ec896
commit
8f0a925a33
1 changed files with 12 additions and 0 deletions
|
@ -291,6 +291,18 @@
|
||||||
thePet.style.setProperty("--width", `${width}px`);
|
thePet.style.setProperty("--width", `${width}px`);
|
||||||
thePet.style.setProperty("--height", `${height}px`);
|
thePet.style.setProperty("--height", `${height}px`);
|
||||||
thePet.style.setProperty("--color", this.color);
|
thePet.style.setProperty("--color", this.color);
|
||||||
|
let happinessFilter = 1 - this.happiness / MAX_HAPPINESS;
|
||||||
|
if (happinessFilter < 0.6) {
|
||||||
|
happinessFilter = 0;
|
||||||
|
}
|
||||||
|
happinessFilter = (happinessFilter - 0.6) * 2.5;
|
||||||
|
if (happinessFilter < 0) {
|
||||||
|
happinessFilter = 0;
|
||||||
|
}
|
||||||
|
thePet.style.setProperty(
|
||||||
|
"filter",
|
||||||
|
`grayscale(${happinessFilter * 100}%)`
|
||||||
|
);
|
||||||
|
|
||||||
if (!this.alive) {
|
if (!this.alive) {
|
||||||
thePet.classList.add("dead");
|
thePet.classList.add("dead");
|
||||||
|
|
Loading…
Add table
Reference in a new issue