some work on team assignment

This commit is contained in:
Geir Okkenhaug Jerstad 2024-08-28 14:12:05 +02:00
parent 39ce4b550c
commit 48069b01c7
5 changed files with 58 additions and 25 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View file

@ -1,23 +1,29 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sir Quacksalot</title>
<title>Sir Quacksalot</title>
<link rel="stylesheet" href="style.css">
</head>
<style>
</style>
<body>
<div id="app">
<div id="foodId"></div>
<div id="petId"></div>
<div id="TTL"></div>
</div>
<button onclick="feed()" id="foodBtn">Feed</button>
<button onclick="pet()" id="petBtn">Pet</button>
<img id="tamaFrog">
<button onclick="reset()" id="resetBtn">Resurection/reset</button>
<div class="FrogFace"><img id="tamaFrog"> </div>
<script src="script.js"></script>
</body>
</html>

View file

@ -1,5 +1,4 @@
// Model
let lifeTimer = 100;
let foodTime = 10;
let petTime = 10;
let foodElement = document.getElementById("foodId");
@ -7,31 +6,36 @@ let petElement = document.getElementById('petId');
let frogImage = document.getElementById('tamaFrog').src = "img/default.jpg";
setInterval(foodFunction, 1000)
setInterval(foodFunction, 1000);
setInterval(petFunction, 1000);
// View
// function reset() {
// if (foodTime < 0){
// foodTime += 50;
// petTime += 10;
// defaultImg();
// }
// }
function foodFunction() {
if (foodTime < 0) {
//game over???
document.getElementById('tamaFrog').src = "img/dead.jpg";
document.getElementById('tamaFrog').style.backgroundColor = 'red';
setInterval(afterLife, 1000);
// setTimeout(afterLife, 1000);
} else {
foodElement.innerHTML = foodTime + " seconds remaining"
foodTime--
if (foodTime < 5) {
if (foodTime < 15) {
document.getElementById('tamaFrog').src = "img/need_food.jpg";
}
}
}
// Controller
function feed() {
if (foodTime > 0) {
if (foodTime > 0 && petTime > 5) {
foodTime += 10;
document.getElementById('tamaFrog').src = "img/eating.jpg";
setTimeout(defaultImg, 500)
}
}
@ -41,24 +45,24 @@ function defaultImg() {
}
function petFunction() {
if (petTime < 0) {
document.getElementById('petFrog').src = "img/need_petting.jpg";
} else {
petElement.innerHTML = petTime + "seconds remaining"
foodTime--
if (petTime < 3) {
document.getElementById('petFrog').src = "img/need_love.jpg";
}
if (petTime < 5) {
document.getElementById('tamaFrog').src = "img/angry.jpg";
}
else {
petElement.innerHTML = petTime + " seconds remaining"
petTime--
}
}
function pet() {
if (petTime > 0) {
if (foodTime > 0) {
petTime += 10;
document.getElementById('petFrog').src = "img/need_love.jpg";
document.getElementById('tamaFrog').src = "img/need_love.jpg";
setTimeout(defaultImg, 500)
}
}
function defaultImg() {

View file

@ -0,0 +1,23 @@
.FrogFace {
user-select: none;
padding: 2px;
border: solid, 5px rgb(19, 204, 19);
max-width: 650px;
}
img{
max-width: 100%;
max-height: 100%;
}
.square {
height: 75px;
width: 75px;
}
/* #app{
display: grid;
padding: 2px;
border: solid, yellow, 2px;
} */