mirror of
https://github.com/zyllian/webdog.git
synced 2025-05-09 18:16:40 -07:00
add pet colors and scales
This commit is contained in:
parent
742bf6d3e8
commit
478ab7520d
1 changed files with 22 additions and 3 deletions
|
@ -151,6 +151,12 @@
|
||||||
hatched = Date.now();
|
hatched = Date.now();
|
||||||
/** the pet's type */
|
/** the pet's type */
|
||||||
type = PET_TYPES[Math.floor(rand(0, PET_TYPES.length))];
|
type = PET_TYPES[Math.floor(rand(0, PET_TYPES.length))];
|
||||||
|
/** the pet's color */
|
||||||
|
color = `rgb(${rand(0, 255)}, ${rand(0, 255)}, ${rand(0, 255)})`;
|
||||||
|
/** the pet's scaled width */
|
||||||
|
scaleWidth = rand(0.6, 1.4);
|
||||||
|
/** the pet's scaled height */
|
||||||
|
scaleHeight = rand(0.6, 1.4);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* updates a pet
|
* updates a pet
|
||||||
|
@ -225,6 +231,9 @@
|
||||||
thePet.classList.remove("elder");
|
thePet.classList.remove("elder");
|
||||||
thePet.classList.remove("dead");
|
thePet.classList.remove("dead");
|
||||||
|
|
||||||
|
let width = 0;
|
||||||
|
let height = 0;
|
||||||
|
|
||||||
if (this.lifeStage === LIFE_STAGE_EGG) {
|
if (this.lifeStage === LIFE_STAGE_EGG) {
|
||||||
eggDiv.classList.remove("hidden");
|
eggDiv.classList.remove("hidden");
|
||||||
hatchedActions.classList.add("hidden");
|
hatchedActions.classList.add("hidden");
|
||||||
|
@ -236,14 +245,16 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
thePet.classList.add("pup");
|
thePet.classList.add("pup");
|
||||||
thePet.style = `--width: ${WIDTH_PUP}px; --height: ${HEIGHT_PUP}px;`;
|
width = WIDTH_PUP;
|
||||||
|
height = HEIGHT_PUP;
|
||||||
} else if (this.lifeStage === LIFE_STAGE_ADULT) {
|
} else if (this.lifeStage === LIFE_STAGE_ADULT) {
|
||||||
if (this.needsAdvancement) {
|
if (this.needsAdvancement) {
|
||||||
adultInfo.classList.remove("hidden");
|
adultInfo.classList.remove("hidden");
|
||||||
}
|
}
|
||||||
|
|
||||||
thePet.classList.add("adult");
|
thePet.classList.add("adult");
|
||||||
thePet.style = `--width: ${WIDTH_ADULT}px; --height: ${HEIGHT_ADULT}px;`;
|
width = WIDTH_ADULT;
|
||||||
|
height = HEIGHT_ADULT;
|
||||||
} else if (this.lifeStage === LIFE_STAGE_ELDER) {
|
} else if (this.lifeStage === LIFE_STAGE_ELDER) {
|
||||||
if (this.needsAdvancement) {
|
if (this.needsAdvancement) {
|
||||||
if (this.alive) {
|
if (this.alive) {
|
||||||
|
@ -252,11 +263,19 @@
|
||||||
passedAwayInfo.classList.remove("hidden");
|
passedAwayInfo.classList.remove("hidden");
|
||||||
|
|
||||||
thePet.classList.add("elder");
|
thePet.classList.add("elder");
|
||||||
thePet.style = `--width: ${WIDTH_ELDER}px; --height: ${HEIGHT_ELDER}px;`;
|
width = WIDTH_ELDER;
|
||||||
|
height = HEIGHT_ELDER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
width *= this.scaleWidth;
|
||||||
|
height *= this.scaleHeight;
|
||||||
|
|
||||||
|
thePet.style.setProperty("--width", `${width}px`);
|
||||||
|
thePet.style.setProperty("--height", `${height}px`);
|
||||||
|
thePet.style.setProperty("--color", this.color);
|
||||||
|
|
||||||
if (!this.alive) {
|
if (!this.alive) {
|
||||||
thePet.classList.add("dead");
|
thePet.classList.add("dead");
|
||||||
} else if (this.lifeStage !== LIFE_STAGE_EGG) {
|
} else if (this.lifeStage !== LIFE_STAGE_EGG) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue