-
Notifications
You must be signed in to change notification settings - Fork 0
/
shootyarrow.html
202 lines (200 loc) · 5.08 KB
/
shootyarrow.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
200
201
202
<!DOCTYPE html>
<html>
<head><meta name="viewport" content="width=device-width" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="apple-mobile-web-app-capable"
content="yes">
<script type="text/javascript" src='posfunc.js'></script>
<script type="text/javascript" src='movefunc.js'></script>
<title>Shooty Arrow</title>
</head>
<body>
<p id="countdown"></p>
<div id="hero"></div>
<div id="aleft"></div>
<div id="fire"><div onclick="fire()" id="text">Fire</div></div>
<input type="range" min="0" max="180" value="90" class="slider" id="slider">
<style type="text/css">
#slider{
position:fixed;
-webkit-appearance: none;
width:50%;
height:50px;
background-color: blue;
left:25%;
top:93%;
}
#slider::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
border-radius:25px;
width: 50px;
height: 50px;
background: grey;
}body{z-index:0;
background-image:url("ground.png");
}#hero{z-index:2;
position:fixed;
top:70%;
left:42.5%;
height:160px;
width:12.5%;
background-image:url("hero.png");
}#fire{position:fixed;
height:160px;
width:160px;
top:33%;
left:5%;
background-color:green;
color:grey;
border-radius:80px;
}#text{
position:fixed;
top:40%;
left:10%;
font-size:28pt;
}#countdown{position:fixed;
font-size: 40pt;
}#aleft{position: fixed;
left:95%;
font-size: 40pt;
}
</style>
<script type="text/javascript">
function getCookie(cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
for(var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
}
if(typeof(getCookie('level'))==="undefined"){var level = 1;}
else{var level=parseFloat(getCookie("level"));
}
var jj;
var g;
var atop;
var aleft;
var aright;
var abot;
var btop;
var bleft;
var bright;
var bbot;
function leftwall(b) {var f = f
if(leftFunNum(b)<=0){b.style.left = 1024}
}function rightwall(b) {var f = f
if(leftFunNum(b)>=1024){b.style.left = -50}
}
var f = 0;
var c = -1;
var m = -1;
var dninjacount = 0;
var n_left = level*2;
var width = screen.width;
var d = Math.floor(Math.random()*45);
var dninja = function () {
document.getElementById(String(c)).style.top = "1000px";
dninjacount+=1
//document.getElementById(String(a)).style.opacity=0;
document.getElementById(String(c)).style.opacity=0;
if(dninjacount>=level){
document.cookie="level = "+String(level+1)+";expires=Wed, 18 Dec 2023 12:00:00 GMT"
alert("You won! The next level will load.")
location.reload()
}return;
}
function createninjias(){
c--
v = Math.floor(Math.random()*568)
g = Math.ceil(Math.random()*2)+1
var img= document.createElement("img")
img.src="ninja.png"
img.id = String(c)
img.style.position = "fixed";
img.style.left = String(v)+"px";
img.style.top = String(v)+"px"
img.style.height ="50px"
if(g == 2){img.style.left = '1024px'};
if(g == 1){img.style.left = '-50px'};
img.style.width = "50px"
img.style.zIndex = "6"
document.body.appendChild(img)
function ninjamovement(){var b = img
if(g == 2){moveSetX(b,-s);leftwall(b)}
if(g == 1){moveSetX(b,s);rightwall(b)}
}setInterval(ninjamovement, 20)
}
function slidecount() {
document.getElementById("hero").style.transform = "rotate("+String(document.getElementById("slider").value)+"deg)";
requestAnimationFrame(slidecount)
}requestAnimationFrame(slidecount)
var a = 0;
var e = 1;
function fire() {if(f==0){for (var i = 0; i < level; i++) {
createninjias();
}
countDown();
f++
return;
}
if (n_left <= 0) {
alert("You ran out of arrows")
e--
}
if(e==1){a++
n_left--
var img= document.createElement("img")
img.src="arrow.png"
img.id = String(a)
img.style.position = "fixed";
img.style.left = "485.2px"
img.style.top = "577.6px"
img.style.height ="75px"
img.style.width = "25px"
img.style.zIndex = "5"
document.body.appendChild(img)
document.getElementById(String(a)).style.transform = "rotate("+String(parseFloat(document.getElementById("slider").value)+270)+"deg)";
moveDiag(document.getElementById(String(a)),parseFloat(document.getElementById("slider").value) , -4, (parseFloat(String(s)+"."+String(hs)+String(ms)))*1000)
for (var i = 0; i < level; i++) {
m--
rectCollide(document.getElementById(String(a)),document.getElementById(String(m)), dninja)
}m= -1
}
}var s = (10+(4*level))/2;
var ts = 0;
var hs=0;
var ms = 0;
var k=0;
var p;
function countDown() {
function tick() {
if(k==0){
document.getElementById('countdown').innerHTML = String(s)+"."+String(hs)+String(ms);
document.getElementById('aleft').innerHTML = n_left;
}
if(s<0){
alert('You are done. You ran out of time');
clearInterval(p)
e--
location.reload()
}
if(ms<0){
ms=9
hs-=1
};if(hs<0){
hs=9
s-=1
};
ms-=1
} p = setInterval(tick, 1)
}
</script>
</body>
</html>