Skip to content

Commit

Permalink
finish version 0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
pdvonzoo committed Dec 27, 2018
1 parent f7a13c7 commit 84a933c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
23 changes: 16 additions & 7 deletions Character.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const Character = class {
bob.setAttribute('src', './images/eat.png')
bob.setAttribute('class', 'bob')
document.body.appendChild(bob)
bob.style.right = `${Math.random()*100}%`;
bob.style.right = `${Math.random()*10}rem`;
this.eating(bob)
}
setFullSeti(){
Expand All @@ -62,7 +62,7 @@ const Character = class {
let opacity = 1;
const eatingBob = ()=>{
bob.style.opacity = opacity;
opacity -=0.003;
opacity -=0.03;
if(opacity>0){
requestAnimationFrame(eatingBob);
}
Expand Down Expand Up @@ -113,7 +113,7 @@ const Character = class {
let opacity = 1;
const cleaningShit = ()=>{
shit.style.opacity = opacity;
opacity -=0.01;
opacity -=0.1;
if(opacity>0){
requestAnimationFrame(cleaningShit);
}
Expand All @@ -128,18 +128,27 @@ const Character = class {
}
die(){
this.timerIDList.forEach(timerId=>clearInterval(timerId))
console.log('die')
document.querySelector('html').innerHTML = "Game over";
document.querySelector('html').style.fontSize = "3rem";
document.querySelector('html').style.fontWeight = "bold";
document.querySelector('html').style.color = "#fff";
document.querySelector('html').style.backgroundColor = "#000";
document.querySelector('html').style.width = "20rem";
document.querySelector('html').style.height = "25rem";
document.querySelector('html').style.lineHeight = "25rem";
document.querySelector('html').style.textAlign = "center";

}

}

const eatBtn = document.querySelector('#eat')

const playgroundCopy = document.querySelector(".playgroundCopy");
const happyEl = document.querySelector('#happy');
window.addEventListener('load', ()=>{
const deer = new Character();
const sleepBtn = document.querySelector("#sleep");
const playgroundCopy = document.querySelector(".playgroundCopy");
const happyEl = document.querySelector('#happy');

eatBtn.addEventListener('click', ()=>deer.eat())
const Broom = document.querySelector('#cleanSheet');
Broom.addEventListener('click', () => {
Expand Down
9 changes: 9 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,12 @@ body {
bottom: 4rem;
margin-left: 2rem;
}
.gameover{
width: 20rem;
height: 25rem;
font-size: 3rem;
color: #fff;
background-color: #000;
line-height: 25rem;
text-align: center;
}

0 comments on commit 84a933c

Please sign in to comment.