-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpacman.html
More file actions
111 lines (98 loc) · 2.14 KB
/
pacman.html
File metadata and controls
111 lines (98 loc) · 2.14 KB
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
@import url('https://fonts.googleapis.com/css?family=Slabo+27px&display=swap');
*, *:after, *:before {
box-sizing: border-box;
}
body {
background: #000;
color: #fff;
padding: 0;
margin: 0;
font-family: 'Slabo 27px', serif;
display: flex;
height: 100vh;
justify-content: center;
align-items: center;
}
.pacman {
width: 100px;
height: 100px;
border-radius: 50%;
background: #F2D648;
position: relative;
margin-top: 20px;
}
.pacman__eye {
position: absolute;
width: 10px;
height: 10px;
border-radius: 50%;
top: 20px;
right: 40px;
background: #333333;
}
.pacman__mouth {
background: #000;
position: absolute;
width: 100%;
height: 100%;
clip-path: polygon(100% 74%, 44% 48%, 100% 21%);
animation-name: eat;
animation-duration: 0.7s;
animation-iteration-count: infinite;
}
.pacman__food {
position: absolute;
width: 15px;
height: 15px;
background: #fff;
border-radius: 50%;
top: 40%;
left: 120px;
animation-name: food;
animation-duration: 0.7s;
animation-iteration-count: infinite;
}
@keyframes eat {
0% {
clip-path: polygon(100% 74%, 44% 48%, 100% 21%);
}
25% {
clip-path: polygon(100% 60%, 44% 48%, 100% 40%);
}
50% {
clip-path: polygon(100% 50%, 44% 48%, 100% 50%);
}
75% {
clip-path: polygon(100% 59%, 44% 48%, 100% 35%);
}
100% {
clip-path: polygon(100% 74%, 44% 48%, 100% 21%);
}
}
@keyframes food {
0% {
transform: translateX(0);
opacity: 1;
}
100% {
transform: translateX(-50px);
opacity: 0;
}
}
</style>
<title>Pac-Man Animation</title>
</head>
<body>
<div class="pacman">
<div class="pacman__eye"></div>
<div class="pacman__mouth"></div>
<div class="pacman__food">
</div>
</body>
</html>