-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
134 lines (68 loc) · 2.38 KB
/
script.js
File metadata and controls
134 lines (68 loc) · 2.38 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
function m(event) {
var key = event.which;
if (key == 32) {
setInterval(f, 700);
}
// alert(key);
if (event.which === 65) { ////left
var d1 = document.getElementById("d1");
var c = window.getComputedStyle(d1).marginLeft;
var move = parseInt(c) - 50; // move = move + 10;
d1.style.marginLeft = move + ("px");
}
if (event.which === 68) { ////Rait
var d1 = document.getElementById("d1");
var c = window.getComputedStyle(d1).marginLeft;
var move = parseInt(c) + 50; // move = move + 10;
d1.style.marginLeft = move + ("px");
}
if (event.which === 87) { ////uda
var d1 = document.getElementById("d1");
var c = window.getComputedStyle(d1).marginTop;
var move = parseInt(c) - 50; // move = move + 10;
d1.style.marginTop = move + ("px");
}
if (event.which === 83) { ////yata
var d1 = document.getElementById("d1");
var c = window.getComputedStyle(d1).marginTop;
var move = parseInt(c) + 50; // move = move + 10;
d1.style.marginTop = move + ("px");
}
}
var s = 0;
function n(i) {
var d = document.getElementById(i);
var c = window.getComputedStyle(d).marginLeft;
var x = parseInt(c) - 10;
d.style.marginLeft = x + "px";
if (x < 0) {
if (d.style.visibility = "hidden") {
window.location = "index.html";
alert("Game Over !");
}
}
s = s + 1;
document.getElementById("h").innerHTML = s;
}
var q = 0;
function f() {
var x = Math.floor(Math.random() * 2000) + 500;
var y = Math.floor(Math.random() * 500);
var b = document.body;
var d = document.createElement("div");
d.className = "d1";
d.id = "di" + q;
d.onclick = function() {
d.style.visibility = "hidden";
};
d.style.marginLeft = x + "px";
d.style.marginTop = y + "px";
b.appendChild(d);
var r = Math.floor(Math.random() * 256);
var g = Math.floor(Math.random() * 256);
var b = Math.floor(Math.random() * 256);
// var d = document.getElementById("div");
d.style.backgroundColor = "rgb(" + r + "," + g + "," + b + ")";
setInterval(n, 100, "di" + q);
q = q + 1;
}