-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkonami.html
More file actions
152 lines (125 loc) · 3.42 KB
/
konami.html
File metadata and controls
152 lines (125 loc) · 3.42 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Konami Code Firework Effect</title>
<style>
body {
margin: 0;
overflow: hidden;
}
#smoke {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.5);
display: none;
}
#konamiCodeText {
color: white;
font-size: 24px;
text-align: center;
margin-top: 40vh;
display: none;
}
#fireworks-container {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
}
.firework {
position: absolute;
width: 10px;
height: 10px;
background-color: #ffcc00;
border-radius: 50%;
animation: explode 1s ease-out;
}
@keyframes explode {
0% {
transform: scale(1);
opacity: 1;
}
100% {
transform: scale(10);
opacity: 0;
}
}
.key-press-animation {
animation: keyPressAnimation 0.3s ease-in-out;
}
@keyframes keyPressAnimation {
0% { transform: scale(1); }
50% { transform: scale(1.2); }
100% { transform: scale(1); }
}
</style>
</head>
<body>
<div id="smoke"></div>
<div id="konamiCodeText">Konami Code Activated!</div>
<div id="fireworks-container"></div>
<script>
// Konami Code
const konamiCode = [
'ArrowUp', 'ArrowUp',
'ArrowDown', 'ArrowDown',
'ArrowLeft', 'ArrowRight',
'ArrowLeft', 'ArrowRight',
'b', 'a'
];
let enteredCode = [];
function checkKonamiCode() {
if (enteredCode.toString() === konamiCode.toString()) {
activateFireworkEffect();
}
}
function activateFireworkEffect() {
const smoke = document.getElementById('smoke');
const konamiCodeText = document.getElementById('konamiCodeText');
const fireworksContainer = document.getElementById('fireworks-container');
smoke.style.display = 'block';
konamiCodeText.style.display = 'block';
// Create more fireworks
for (let i = 0; i < 20; i++) {
createFirework();
}
setTimeout(() => {
smoke.style.display = 'none';
konamiCodeText.style.display = 'none';
fireworksContainer.innerHTML = ''; // Clear fireworks
enteredCode = []; // Reset entered code
}, 5000); // Adjust the duration of the smoke and fireworks effect
}
function createFirework() {
const fireworksContainer = document.getElementById('fireworks-container');
const firework = document.createElement('div');
firework.classList.add('firework');
// Set random position
const x = Math.random() * window.innerWidth;
const y = Math.random() * window.innerHeight;
firework.style.left = `${x}px`;
firework.style.top = `${y}px`;
fireworksContainer.appendChild(firework);
}
window.addEventListener('keydown', (event) => {
enteredCode.push(event.key);
// Ensure entered code does not exceed the length of the Konami Code
enteredCode = enteredCode.slice(-konamiCode.length);
// Add animation class to the body for key press animation
document.body.classList.add('key-press-animation');
// Remove animation class after the animation is complete
setTimeout(() => {
document.body.classList.remove('key-press-animation');
}, 300);
checkKonamiCode();
});
</script>
</body>
</html>