This commit is contained in:
girault
2022-04-12 12:34:07 +02:00
parent d41feeffe8
commit e3c07b83d4
11 changed files with 333 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<title>Cookie clicker</title>
<link rel="stylesheet" href="./css/style.css">
</head>
<body>
<div class="container">
<h1>Cookie clicker</h1>
<figure>
<img src="img/cookie.png" alt="cookie">
<span>0</span>
</figure>
<button>start</button>
<p class="hidden">
<img src="img/memee.png" alt="memee" width="64" height="64">
<span></span>
</p>
</div>
<script type="text/javascript" src="./js/game.js"></script>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

View File

@@ -0,0 +1,63 @@
@import url(https://fonts.googleapis.com/css?family=Kavoon);
body {
background-image: url("img/bg.jpg");
background-repeat: repeat;
font-family: Kavoon;
font-size: 24px;
text-align: center;
color: white;
}
.container {
max-width: 320px;
margin: auto;
}
h1 {
font-size: 28px;
background-color: rgba(0, 0, 0, 0.25);
padding: 10px 40px 10px 40px;
border-radius: 10px;
}
figure {
position: relative;
margin: 0;
}
figure > span {
position: absolute;
top: 25px;
right: 50px;
border-radius: 21px;
height: 42px;
width: 56px;
background-color: #f4d03f;
box-shadow: 4px 4px 4px black;
padding-top: 9px;
}
button {
display: block;
width: 100%;
font-family: Kavoon;
font-size: 24px;
background-color: white;
padding: 9px;
border-radius: 10px;
border-width: 0;
}
p {
text-align: left;
}
img[alt="GrandMa"] {
float: left;
}
.hidden {
display: none;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

@@ -0,0 +1,47 @@
// TODO
let numberOfSecond
let id_interval
let btt = document.getElementsByTagName("button")[0]
let p = document.getElementsByTagName("p")[0]
let text_numberOfSecond = document.getElementsByTagName("p")[0].lastElementChild
let figure = document.getElementsByTagName("figure")[0]
let numberOfClick = document.getElementsByTagName("figure")[0].lastElementChild
function Timer(e4) {
numberOfSecond--;
text_numberOfSecond.innerText = numberOfSecond + " seconds left!"
}
function Ending(e3) {
figure.removeEventListener("click", ClickIMG, false)
clearInterval(id_interval)
text_numberOfSecond.innerText = 0 + " second left!"
}
function ClickIMG(e2) {
numberOfClick.innerText = Number(numberOfClick.innerText) + 1
}
function ReponseClick(e1) {
numberOfSecond = 15
btt.classList.add("hidden")
p.classList.remove("hidden")
text_numberOfSecond.innerText = numberOfSecond + " seconds left!"
text_numberOfSecond.style = "color:red"
figure.addEventListener("click", ClickIMG, false)
id_interval = setInterval(Timer, 1000)
setTimeout(Ending, 15000)
}
btt.addEventListener("click", ReponseClick, false)