-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample.html
93 lines (84 loc) · 3.22 KB
/
example.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>wordpet example</title>
<link href="https://fonts.googleapis.com/css?family=Lato:400,900" rel="stylesheet">
<style type="text/css">
body {
color: aliceblue;
font-family: 'Lato', sans-serif;
background-color: #7d77a8;
}
h1 { font-size: 400%; }
button {
color: aliceblue;
background-color: rgba(255, 255, 255, 0.3);
font-family: 'Lato', sans-serif;
font-weight: 900;
font-size: 24px;
padding: 2px 8px;
border: none;
border-radius: 5px;
}
button:hover {
background-color: rgba(255, 255, 255, 0.4);
cursor: pointer;
}
#container {
/* width: 800px; */
margin: auto;
text-align: center;
}
.layers {
display: inline-flex;
width: 300px;
height: 240px;
margin: auto;
}
div.layer {
background-size: 100%;
image-rendering: pixelated;
width: 300px;
height: 240px;
position: absolute;
}
.shadow {
opacity: 0.75;
}
.whenhappy, .happy>.notwhenhappy { visibility: hidden; }
.happy>.whenhappy { visibility: visible; }
div.hover { animation: upDown 0.8s alternate infinite steps(2, end); }
@keyframes upDown { to { transform: translatey(-4px);} }
</style>
<script type="text/javascript">
happyTimeout = null;
function pet() {
new Audio('assets/sfx/' + (Math.random()*100|0) +'.mp3').play();
var x = document.getElementsByClassName('layers')[0];
x.classList.add('happy');
if (happyTimeout !== null) clearTimeout(happyTimeout);
happyTimeout = setTimeout(function() { x.classList.remove('happy'); }, 1000);
console.log(x.classList);
}
</script>
</head>
<body>
<div id="container">
<h1>wordpet</h1>
<div class="layers">
<div style="background-image: url('assets/critter/palette6/shadow0.png')" class="layer shadow"></div>
<div style="background-image: url('assets/critter/palette6/tail0.png')" class="layer hover"></div>
<div style="background-image: url('assets/critter/palette6/tailtip0.png')" class="layer hover"></div>
<div style="background-image: url('assets/critter/palette6/wings1.png')" class="layer hover"></div>
<div style="background-image: url('assets/critter/palette6/legs1.png')" class="layer"></div>
<div style="background-image: url('assets/critter/palette6/body3.png')" class="layer hover"></div>
<div style="background-image: url('assets/critter/palette6/eyes1.png')" class="layer hover notwhenhappy"></div>
<div style="background-image: url('assets/critter/palette6/eyes4.png')" class="layer hover whenhappy"></div>
</div>
<button onclick="pet()">pet this lil baby!!!</button>
</div>
</body>
</html>