mirror of
https://github.com/MrEidam/PetPet.git
synced 2026-04-17 15:43:31 +00:00
Added tiglet smoll
This commit is contained in:
BIN
img/tiger0.png
Normal file
BIN
img/tiger0.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 168 KiB |
BIN
img/tiglet.png
Normal file
BIN
img/tiglet.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 526 KiB |
BIN
img/tiglet_small.png
Normal file
BIN
img/tiglet_small.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 413 KiB |
24
index.html
24
index.html
@@ -10,19 +10,25 @@
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
<img src="">
|
||||
<h1><span>Junior</span>-<span>BOY</span></h1>
|
||||
<p>Age: <span>0</span></p>
|
||||
<img src="./img/tiglet_small.png" style="width:200px;">
|
||||
</div>
|
||||
<div class="activ">
|
||||
<article>
|
||||
<p>Joy: <span>0</span></p>
|
||||
<button>Play</button>
|
||||
<article class="item">
|
||||
<p>Joy: <span id="joyN">10</span></p>
|
||||
<button onclick="play()">Play</button>
|
||||
</article>
|
||||
<article>
|
||||
<p>Food: <span>0</span></p>
|
||||
<button>Feed</button>
|
||||
<article class="item">
|
||||
<p>Food: <span id="fooN">30</span></p>
|
||||
<button onclick="feed()">Feed</button>
|
||||
</article>
|
||||
<article>
|
||||
<p>Health: <span>0</span></p>
|
||||
<article class="item">
|
||||
<p>Clean: <span id="cleN">50</span></p>
|
||||
<button onclick="clearBoy()">Clean</button>
|
||||
</article>
|
||||
<article class="item">
|
||||
<p>Health: <span id="heaN">100</span></p>
|
||||
<button>Heal</button>
|
||||
</article>
|
||||
</div>
|
||||
|
||||
48
main.js
48
main.js
@@ -0,0 +1,48 @@
|
||||
const Djoy = document.querySelector('#joyN');
|
||||
const Dfood = document.querySelector('#fooN');
|
||||
const Dclean = document.querySelector('#cleN');
|
||||
const Dhealth = document.querySelector('#heaN');
|
||||
|
||||
let joy=10, hunger=30, clean=50, hp=100;
|
||||
|
||||
function display(){
|
||||
Djoy.innerHTML = joy;
|
||||
Dfood.innerHTML = hunger;
|
||||
Dclean.innerHTML = clean;
|
||||
Dhealth.innerHTML = hp;
|
||||
}
|
||||
|
||||
function play(){
|
||||
if(joy<98){
|
||||
joy += Math.floor(Math.random()*10);
|
||||
clean -= Math.floor(Math.random()*5);
|
||||
}else{
|
||||
clean -= Math.floor(Math.random()*5);
|
||||
}
|
||||
display();
|
||||
}
|
||||
|
||||
function feed(){
|
||||
if(hunger<150){
|
||||
if(hunger<100){
|
||||
hunger += Math.floor(Math.random()*15);
|
||||
clean -= Math.floor(Math.random()*5);
|
||||
}else{
|
||||
hunger += Math.floor(Math.random()*5);
|
||||
clean -= Math.floor(Math.random()*5);
|
||||
hp -= Math.floor(Math.random()*14);
|
||||
}
|
||||
}else{
|
||||
return;
|
||||
}
|
||||
display();
|
||||
}
|
||||
|
||||
function clearBoy(){
|
||||
console.log('sup');
|
||||
if(clean<100){
|
||||
clean += Math.floor(Math.random()*20);
|
||||
joy -= Math.floor(Math.random()*11);
|
||||
}
|
||||
display();
|
||||
}
|
||||
Reference in New Issue
Block a user