Added tiglet smoll

This commit is contained in:
2024-06-04 00:30:52 +02:00
parent 733ac71368
commit d85587fdd5
6 changed files with 72 additions and 9 deletions

BIN
img/tiger0.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 168 KiB

BIN
img/tiglet.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 526 KiB

BIN
img/tiglet_small.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 413 KiB

View File

@@ -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
View File

@@ -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();
}

View File

@@ -0,0 +1,9 @@
*{
padding: 0;
margin: 0;
box-sizing: border-box;
}
body{
background: #333;
color: #fff;
}