| Пашет правда только в ИЕ5.5 и выше, но потом переделаю.
Помогите отследить столкновение кубика с мячом.
Пытался втавить этот код
if (d.all("xc").style.pixelLeft+6 >= w && d.all("xc").style.pixelLeft <= w+35 && d.all("xc").style.pixelTop+6 >= h && d.all("xc").style.pixelTop <= h+15){
alert('col');
}
|
в цикл, но ничего невыходит.
cам арканоид:
<html>
<title></title>
<head>
<script language = javascript>
var d = document;
var xdir = 2;
var ydir = 2;
function aaa(){
d.all("xc").style.pixelLeft += (xdir);
d.all("xc").style.pixelTop += (ydir);
if ((d.all("xc").style.pixelLeft<=6)){
xdir=-xdir;
}
if (d.all("xc").style.pixelLeft>=d.body.clientWidth-60){
xdir=-xdir;
}
if ((d.all("xc").style.pixelTop<=6)){
ydir=-ydir;
}
if ((d.all("xc").style.pixelTop>=400)){
ydir=-ydir;
}
setTimeout ("aaa()");
}
s = "#ff0000";
y = "#ffff00";
f = "#ee33de";
l = "#33ff00";
b = "#0066ff";
n = "#000000";
a = [
[l, b, s, y, n],
[f, l, b, s, y],
[f, l, b, b, s],
[f, l, b, b, s],
[f, l, l, b, s],
[f, f, l, b, s],
[f, l, l, b, s],
[f, l, b, b, s],
[f, l, b, b, s],
[f, l, b, s, y],
[l, b, s, y, n]
];
for(i = 0; i < 12; i ++){
for(j = 0; j < 5; j ++){
w = 100+37*i
h = 45+18*j
document.write("<div style='position: absolute; background-color: "+a[i][j]+"; width: 35px; height: 15px; top: "+h+"px; left: "+w+"px; font-size: 8px'></div>");
}
}
</script>
</head>
<body bgColor=#000000 onload=aaa()>
<div id="xc" style="background-color: orangered; height: 6px; left: 200px; position: absolute; top: 150px; width: 6px; font-size: 6px"></div>
</body>
</html>
|
| |