-
Notifications
You must be signed in to change notification settings - Fork 0
/
dessertGame.html
53 lines (53 loc) · 1.59 KB
/
dessertGame.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<html><head>
<title>Dessert in the Desert Browser Game</title>
<style>
button {
color: blanchedalmond;
background-color: chocolate;
border-color: chocolate;
position: absolute;
font-size: 16px;
border-radius: 8px;
}
button:hover {
background-color: blue;
color: white;
}
p {
font-weight: 800;
}
body {
background-color: SandyBrown;
}
</style><script>
var score = 0;
function randomizeButtonPositions() {
var buttons = document.querySelectorAll("button");
document.querySelectorAll("#scoreOutput")[0].innerHTML = score;
buttons.forEach( (b) => {
b.style.left = (Math.random()*80+10)+"%";
b.style.top = (Math.random()*80+10)+"%";
} );
}
function handleDessertClick() {
score++;
randomizeButtonPositions();
}
function handleDesertClick(){
score--;
randomizeButtonPositions();
}
</script>
<meta name="author" content="movsessian">
</head>
<body onload="randomizeButtonPositions()">
<p>Score: <span id="scoreOutput"></span></p>
<button onClick = "handleDessertClick()">Dessert</button>
<button onClick = "handleDesertClick()">Desert</button>
<button onClick = "handleDesertClick()">Desert</button>
<button onClick = "handleDesertClick()">Desert</button>
<button onClick = "handleDesertClick()">Desert</button>
<button onClick = "handleDesertClick()">Desert</button>
<button onClick = "handleDesertClick()">Desert</button>
<button onClick = "handleDesertClick()">Desert</button>
</body></html>