diff --git a/intro_js/clickerv2.html b/intro_js/clickerv2.html new file mode 100644 index 0000000..d7c54f4 --- /dev/null +++ b/intro_js/clickerv2.html @@ -0,0 +1,49 @@ + + + + + + Document + + + +
+ + + + \ No newline at end of file diff --git a/team/oppgave1/uke4/img/dead.jpg b/team/oppgave1/uke4/img/dead.jpg new file mode 100644 index 0000000..322859d Binary files /dev/null and b/team/oppgave1/uke4/img/dead.jpg differ diff --git a/team/oppgave1/uke4/img/default.jpg b/team/oppgave1/uke4/img/default.jpg new file mode 100644 index 0000000..25e13ac Binary files /dev/null and b/team/oppgave1/uke4/img/default.jpg differ diff --git a/team/oppgave1/uke4/img/eating.jpg b/team/oppgave1/uke4/img/eating.jpg new file mode 100644 index 0000000..ebf90fa Binary files /dev/null and b/team/oppgave1/uke4/img/eating.jpg differ diff --git a/team/oppgave1/uke4/img/ghost.jpg b/team/oppgave1/uke4/img/ghost.jpg new file mode 100644 index 0000000..f04a595 Binary files /dev/null and b/team/oppgave1/uke4/img/ghost.jpg differ diff --git a/team/oppgave1/uke4/img/need_food.jpg b/team/oppgave1/uke4/img/need_food.jpg new file mode 100644 index 0000000..a978f25 Binary files /dev/null and b/team/oppgave1/uke4/img/need_food.jpg differ diff --git a/team/oppgave1/uke4/img/need_love.jpg b/team/oppgave1/uke4/img/need_love.jpg new file mode 100644 index 0000000..71c35a7 Binary files /dev/null and b/team/oppgave1/uke4/img/need_love.jpg differ diff --git a/team/oppgave1/uke4/img/need_petting.jpg b/team/oppgave1/uke4/img/need_petting.jpg new file mode 100644 index 0000000..893e323 Binary files /dev/null and b/team/oppgave1/uke4/img/need_petting.jpg differ diff --git a/team/oppgave1/uke4/img/style.css b/team/oppgave1/uke4/img/style.css new file mode 100644 index 0000000..e69de29 diff --git a/team/oppgave1/uke4/index.html b/team/oppgave1/uke4/index.html index 1a2a8e0..b22f063 100644 --- a/team/oppgave1/uke4/index.html +++ b/team/oppgave1/uke4/index.html @@ -1,12 +1,23 @@ + - Document + Sir Quacksalot + + -
Thus spake the Master Programmer:
- "After three days without programming, life becomes meaningless." - The Tao of Programming
+
+
+ + + + + + \ No newline at end of file diff --git a/team/oppgave1/uke4/script.js b/team/oppgave1/uke4/script.js new file mode 100644 index 0000000..5747a49 --- /dev/null +++ b/team/oppgave1/uke4/script.js @@ -0,0 +1,69 @@ +// Model +let lifeTimer = 100; +let foodTime = 10; +let petTime = 10; +let foodElement = document.getElementById("foodId"); +let petElement = document.getElementById('petId'); +let frogImage = document.getElementById('tamaFrog').src = "img/default.jpg"; + + +setInterval(foodFunction, 1000) + +// View +function foodFunction() { + + if (foodTime < 0) { + //game over??? + document.getElementById('tamaFrog').src = "img/dead.jpg"; + document.getElementById('tamaFrog').style.backgroundColor = 'red'; + setInterval(afterLife, 1000); + } else { + foodElement.innerHTML = foodTime + " seconds remaining" + foodTime-- + if (foodTime < 5) { + document.getElementById('tamaFrog').src = "img/need_food.jpg"; + } + } +} +// Controller +function feed() { + if (foodTime > 0) { + foodTime += 10; + document.getElementById('tamaFrog').src = "img/eating.jpg"; + setTimeout(defaultImg, 500) + + } + +} + +function defaultImg() { + document.getElementById('tamaFrog').src = "img/default.jpg"; +} + +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"; + } + } +} +function pet() { + if (petTime > 0) { + petTime += 10; + document.getElementById('petFrog').src = "img/need_love.jpg"; + setTimeout(defaultImg, 500) + + } + +} +function defaultImg() { + document.getElementById('tamaFrog').src = "img/default.jpg"; +} +function afterLife() { + document.getElementById('tamaFrog').src = "img/ghost.jpg"; +} \ No newline at end of file