-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmoleday.html
199 lines (191 loc) · 8.37 KB
/
moleday.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
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
<!DOCTYPE html>
<html>
<head>
<title>Tap-A-Mol</title>
<script src="copyrighter.js"></script>
<meta name="viewport" content="user-scalable=no">
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-150841251-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-150841251-1');
</script>
<link rel='icon' href='https://goldprogrammer.github.io/genuisgames/grumole.png' type='image/x-icon'/ >
</head>
<body id="bod">
<canvas id="canv"></canvas>
<img height="0px" width="0px" id="circ1" src="https://saurabh-sharma.com/images/brown-cliparts-png-circle-2.png">
<img height="0px" width="0px" id="circ2" src="https://saurabh-sharma.com/images/brown-cliparts-png-circle-2.png">
<img height="0px" width="0px" id="circ3" src="https://saurabh-sharma.com/images/brown-cliparts-png-circle-2.png">
<img height="0px" width="0px" id="circ4" src="https://saurabh-sharma.com/images/brown-cliparts-png-circle-2.png">
<img height="0px" width="0px" id="circ5" src="https://saurabh-sharma.com/images/brown-cliparts-png-circle-2.png">
<img height="0px" width="0px" id="circ6" src="https://saurabh-sharma.com/images/brown-cliparts-png-circle-2.png">
<img height="0px" width="0px" id="hammer" src="https://studio.code.org/media?u=http%3A%2F%2Fwww.clker.com%2Fcliparts%2F5%2F9%2F2%2F1%2F119498479391699263wooden_mallot_benji_park_.svg.hi.png">
<style>body{margin:0px;}html, body {
overflow-y: hidden;
}
body {
position: relative;
width:100%;
}</style>
<script>
var time = 10
var score = 0
var k=0;
var p=true;
var n=0;
var actmole=[]
var l=false;
var X;
var Y;
function countTime(){
if(l){location.reload()}
time = (time-.1).toFixed(2)
peekaboo()
if(n<=0){n=0}
if(time <= 0){clearInterval(countbeg); actmole=[]; alert("You got " + score + "point(s)");l=true}
};
var height = window.innerHeight
var width = window.innerWidth
document.getElementById('bod').style.height=String(height)+"px"
document.getElementById('bod').style.width=String(width)+"px"
//height=1436
//width=980
var countbeg;
var canvas = document.getElementById("canv");
var c = canvas.getContext("2d");
function drawCanv(){
document.getElementById('canv').style.height = String(height)+"px"
document.getElementById('canv').style.width = String(width)+"px"
c.fillStyle = "#00CCFF";
c.fillRect(0, 0, width, height);
c.moveTo(0, height*.01)
c.lineTo(width,height*.01)
c.lineWidth = 2.5
c.strokeStyle = "#FF781F"
c.stroke()
c.font = "14px Ubuntu"
c.fillStyle = "#FF781F"
c.fillText("Start", width*(10/980), height*(6/718))
c.moveTo(width*(60/980), height*(.01))
c.lineTo(width*(60/980),0)
//c.lineWidth = 7.5
c.strokeStyle = "#FF781F"
c.stroke()
c.font = "14px Ubuntu"
c.fillStyle = "#FF781F"
c.fillText("Points: "+score, width*(65/980), height*(12/1436))
c.font = "14px Ubuntu"
c.fillStyle = "#FF781F"
c.fillText("Time: "+time, width*(170/980), height*(12/1436))
c.drawImage(document.getElementById('circ1'),width*(25/width),height*(30/height),width*(100/width),height*(25/height));
c.drawImage(document.getElementById('circ2'),width*(25/width),height*(70/height),width*(100/width),height*(25/height));
c.drawImage(document.getElementById('circ3'),width*(25/width),height*(110/height),width*(100/width),height*(25/height));
c.drawImage(document.getElementById('circ4'),width*(175/width),height*(30/height),width*(100/width),height*(25/height));
c.drawImage(document.getElementById('circ5'),width*(175/width),height*(70/height),width*(100/width),height*(25/height));
c.drawImage(document.getElementById('circ6'),width*(175/width),height*(110/height),width*(100/width),height*(25/height));
console.log((X-(height*(25/1436))*.5)+", "+(Y-(height*(25/1436)*.5)))
c.drawImage(document.getElementById('hammer'),X*(300/980),Y*(150/1436),height*(25/1436),height*(25/1436));
window.requestAnimationFrame(drawCanv)
}
window.requestAnimationFrame(drawCanv)
document.addEventListener("touchstart", touchHandler);
document.addEventListener("touchmove", touchHandler);
function touchHandler(e) {
if(e.touches) {
X = e.touches[0].pageX;
Y = e.touches[0].pageY;
X=X
Y=Y
if(Y <= height*(200/1436) && X <= width*(176/980)){
var yaynay = confirm("start")
if(yaynay == true){
if(yaynay){countbeg = setInterval(countTime, 100);}
}
}if(Y <= height*(592/1436) && Y >= height*(180/1436) && X <= width*(442/980)){
if(actmole.indexOf(1)==1 || actmole.indexOf(1)==0 || actmole.indexOf(1)==2 || actmole.indexOf(1)==3 || actmole.indexOf(1)==4 || actmole.indexOf(1)==5){
actmole.splice(actmole.indexOf(1), 1)
n-=1
score+=1
document.getElementById('circ1').src="https://saurabh-sharma.com/images/brown-cliparts-png-circle-2.png"
}
}if(Y <= height*(992/1436) && Y >= height*(648/1436) && X <= width*(442/980)){
if(actmole.indexOf(2)==1 || actmole.indexOf(2)==0 || actmole.indexOf(2)==2 || actmole.indexOf(2)==3 || actmole.indexOf(2)==4 || actmole.indexOf(2)==5){
actmole.splice(actmole.indexOf(2), 1)
n-=1
score+=1
document.getElementById('circ2').src="https://saurabh-sharma.com/images/brown-cliparts-png-circle-2.png"
}
}if(Y >= height*(990/1436) && X <= width*(442/980)){
if(actmole.indexOf(3)==1 || actmole.indexOf(3)==0 || actmole.indexOf(3)==2 || actmole.indexOf(3)==3 || actmole.indexOf(3)==4 || actmole.indexOf(3)==5){
actmole.splice(actmole.indexOf(3), 1)
n-=1
score+=1
document.getElementById('circ3').src="https://saurabh-sharma.com/images/brown-cliparts-png-circle-2.png"
}
}if(Y <= height*(582/1436) && Y >= height*(180/1436) && X >= width*(450/980)){
if(actmole.indexOf(4)==1 || actmole.indexOf(4)==0 || actmole.indexOf(4)==2 || actmole.indexOf(4)==3 || actmole.indexOf(4)==4 || actmole.indexOf(4)==5){
actmole.splice(actmole.indexOf(4), 1)
n-=1
score+=1
document.getElementById('circ4').src="https://saurabh-sharma.com/images/brown-cliparts-png-circle-2.png"
}
}if(Y <= height*(992/1436) && Y >= height*(648/1436) && X>= width*(450/980)){
if(actmole.indexOf(5)==1 || actmole.indexOf(5)==0 || actmole.indexOf(5)==2 || actmole.indexOf(5)==3 || actmole.indexOf(5)==4 || actmole.indexOf(5)==5){
actmole.splice(actmole.indexOf(5), 1)
n-=1
score+=1
document.getElementById('circ5').src="https://saurabh-sharma.com/images/brown-cliparts-png-circle-2.png"
}
}console.log("yay");if(Y >= height*(993/height) && X >= width*(450/980)){
if(actmole.indexOf(6)==1 || actmole.indexOf(6)==0 || actmole.indexOf(6)==2 || actmole.indexOf(6)==3 || actmole.indexOf(6)==4 || actmole.indexOf(6)==5){
actmole.splice(actmole.indexOf(6), 1)
n-=1
score+=1
document.getElementById('circ6').src="https://saurabh-sharma.com/images/brown-cliparts-png-circle-2.png"
}
}
}
}function shuffle(array) {
var currentIndex = array.length, temporaryValue, randomIndex;
// While there remain elements to shuffle...
while (0 !== currentIndex) {
// Pick a remaining element...
randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex -= 1;
// And swap it with the current element.
temporaryValue = array[currentIndex];
array[currentIndex] = array[randomIndex];
array[randomIndex] = temporaryValue;
}
return array;
}function peekaboo(){
var moles = [0, 0, 0, 0, 0, 0]
if(p){
p=false
var initmole=Math.floor(Math.random()*6)+1
actmole.push(initmole)
document.getElementById("circ"+String(initmole)).src = "https://goldprogrammer.github.io/genuisgames/grumole.png"
n=1
}
if(n==0){
var mole=0;
var array = [1,2,3,4,5,6]
n = Math.floor(Math.random()*9)+1
if(n==1||n==1||n==3||n==4){n=1}
if(n==5||n==6||n==7){n=2}
if(n==8||n==9){n=3}
for (var i = n-1; i >= 0; i--) {
shuffle(array)
mole=array[array.length-1]
array.pop()
actmole.push(mole)
document.getElementById("circ"+String(mole)).src = "https://goldprogrammer.github.io/genuisgames/grumole.png"
}
}
}
</script>
</body>
</html>