diff --git a/team/oppgave1/uke4/img/angry.jpg b/team/oppgave1/uke4/img/angry.jpg
new file mode 100644
index 0000000..aecad55
Binary files /dev/null and b/team/oppgave1/uke4/img/angry.jpg differ
diff --git a/team/oppgave1/uke4/img/style.css b/team/oppgave1/uke4/img/style.css
deleted file mode 100644
index e69de29..0000000
diff --git a/team/oppgave1/uke4/index.html b/team/oppgave1/uke4/index.html
index b22f063..340943a 100644
--- a/team/oppgave1/uke4/index.html
+++ b/team/oppgave1/uke4/index.html
@@ -1,23 +1,29 @@
+
- Sir Quacksalot
+ Sir Quacksalot
+
-
+
-
-
+
+
+
+
\ No newline at end of file
diff --git a/team/oppgave1/uke4/script.js b/team/oppgave1/uke4/script.js
index 5747a49..4ce7934 100644
--- a/team/oppgave1/uke4/script.js
+++ b/team/oppgave1/uke4/script.js
@@ -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() {
diff --git a/team/oppgave1/uke4/style.css b/team/oppgave1/uke4/style.css
new file mode 100644
index 0000000..df9746e
--- /dev/null
+++ b/team/oppgave1/uke4/style.css
@@ -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;
+} */
+
+