-
Notifications
You must be signed in to change notification settings - Fork 0
/
konami.html
74 lines (71 loc) · 2.41 KB
/
konami.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
<!DOCTYPE html>
<html>
<head>
<title>Konami Code</title>
<style>
body {
background-color: orange;
}
#gexImg {
display: block;
margin-left: auto;
margin-right: auto;
width: 50%;
}
</style>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container">
<a class="navbar-brand" href="index.html">
<img id="victor-pena-logo" src="css/images/victor_pena_logo_small.png" alt="victor pena logo">
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="#">Portfolio</a>
</li>
<li class="nav-item">
<a class="nav-link" target="_blank" href="https://github.com/victorpena13">
github
</a>
</li>
</ul>
</div>
</div>
</nav>
<h1>Konami Code</h1>
<p>enter cheat code</p>
<p>['up', 'up', 'down', 'down', 'left', 'right', 'left', 'right', 'b', 'a'];</p>
<span id="image"></span>
<script src="js/jQuery.js"></script>
<script>
(function() {
"use strict";
var allowedKeys = {38 : 'up', 40 : 'down', 39 : 'right', 37 : 'left', 66 : 'b', 65 : 'a'};
var konamiCode = ['up', 'up', 'down', 'down', 'left', 'right', 'left', 'right', 'b', 'a'];
function activateCheat(){
$('body').css('background-color', "orange");
$('#image').html("<img src='css/images/gex.jpg' id='gexImg'>");
alert("30 Lives Added!");
var audio = new Audio('css/audio/cem.mp3');
audio.play();
}
var codePosition = 0;
$('body').keydown(function(e){
var userInput = allowedKeys[e.keyCode];
var cheatCode = konamiCode[codePosition];
if (userInput == cheatCode) {
codePosition++;
if(codePosition == konamiCode.length) {
activateCheat();
}
}
});
})();
</script>
</body>
</html>