Vml+Js算法:完成5个小球在网页运动(碰壁返回)的游戏,详细注释 thanks very much!!!please go on!!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 稍微改了一下<html xmlns:v><head><meta http-equiv='Content-Type' content='text/html;charset=gb2312'><title>ÎK±Ø·´</title><style>v\:*{behavior:url(#default#VML);}*{font-size:12px;color:;}a{text-decoration:none;}a:hover{color:red;}</style><script>function Container(name, left, top, width, height) { this.name = name; this.left = left; this.top = top; this.width = width; this.height = height; this.obj = eval(name); this.put = function(obj) { obj.container = this; this.obj.insertAdjacentHTML("beforeEnd", obj.getCode()) obj.obj = eval(obj.name); } this.checkLeft = function(x) { return (left<=x); } this.checkRight = function(x) { return (x<=left + width); } this.checkTop = function(y) { return (top<=y); } this.checkBottom = function(y) { return (y<=top + height); }}function SHAPE(name, shape, x, y, width, height, color, zindex, xa, ya) { this.name = name; this.shape = shape; this.x = x; this.y = y; this.width = width; this.height = height; this.color = color; this.zindex = zindex; this.xa = xa; this.ya = ya; this.obj = null; this.container = null; this.move = function(xa, ya) { if (typeof(xa)!="undefined" && typeof(ya)!="undefined") { this.xa = xa; this.xa = ya; } with (this) { if (!container.checkLeft(x) || !container.checkRight(x + xa + width)) xa = -xa; x += xa; if (!container.checkTop(y + ya) || !container.checkBottom(y + ya + height)) ya = -ya; y += ya; obj.style.left = x; obj.style.top = y; } } this.getCode = function() { return "<v:" + shape + " fillcolor='" + this.color + "' style='position:absolute;left:" + this.x +";top:" + this.y + ";z-index:" + zindex + ";width:" + this.width + ";height:" + this.height + ";' id='" + this.name + "'/>"; }}</script></head><body topmargin='2' leftmargin='2'><div id=a style='table-Layout:fixed;width:100%;height:100%;border:1 solid black'></div><script>var container = new Container("a", 0, 0, a.offsetWidth, a.offsetHeight);var obj = new Array();for (var i=0; i<5; i++) { shape = Math.round(Math.random())==1?"oval":"rect"; size = Math.round(Math.random() * 70) + 20; x = Math.round(Math.random() * (a.offsetWidth - size)); y = Math.round(Math.random() * (a.offsetHeight - size)); color = "rgb(" + Math.round(Math.random()*255) + "," + Math.round(Math.random()*255) + "," + Math.round(Math.random()*255) + ")"; xa = Math.round(Math.random()*10); ya = Math.round(Math.random()*10); obj[i] = new SHAPE("SHAPE" + i, shape, x, y, size, size, color, i, xa, ya); container.put(obj[i]);}function move() { for (i=0; i<obj.length; i++) obj[i].move();}setInterval("move();",10);</script></body></html> 使用了jquery等库以后什么时候使用id javascript显示中文乱码的问题! 以下关于CISC与RISC的问题——求解 如何用JS调用数据库信息 只显示5条信息 Javascript在我的firefox以及chrome下面这些代码为什么不执行? chinaren图片的问题 while循环内和循环外得出结果一样,哪出错了吗? 请关注.. 二维数组的最大最小值求法 打开一个网页的时候怎样才可以随机播放媒体文件 有两个下拉框,在一个下拉框里选择一个项目,另一个下拉框里的选项会改变;请问用JS怎么实现?? 请教高手问题!
<html xmlns:v>
<head>
<meta http-equiv='Content-Type' content='text/html;charset=gb2312'>
<title>ÎK±Ø·´</title>
<style>
v\:*{behavior:url(#default#VML);}
*{font-size:12px;color:;}
a{text-decoration:none;}
a:hover{color:red;}
</style>
<script>
function Container(name, left, top, width, height) {
this.name = name;
this.left = left;
this.top = top;
this.width = width;
this.height = height;
this.obj = eval(name);
this.put = function(obj) {
obj.container = this;
this.obj.insertAdjacentHTML("beforeEnd", obj.getCode())
obj.obj = eval(obj.name);
}
this.checkLeft = function(x) {
return (left<=x);
}
this.checkRight = function(x) {
return (x<=left + width);
}
this.checkTop = function(y) {
return (top<=y);
}
this.checkBottom = function(y) {
return (y<=top + height);
}
}function SHAPE(name, shape, x, y, width, height, color, zindex, xa, ya) {
this.name = name;
this.shape = shape;
this.x = x;
this.y = y;
this.width = width;
this.height = height;
this.color = color;
this.zindex = zindex;
this.xa = xa;
this.ya = ya;
this.obj = null;
this.container = null;
this.move = function(xa, ya) {
if (typeof(xa)!="undefined" && typeof(ya)!="undefined") {
this.xa = xa;
this.xa = ya;
}
with (this) {
if (!container.checkLeft(x) || !container.checkRight(x + xa + width))
xa = -xa;
x += xa;
if (!container.checkTop(y + ya) || !container.checkBottom(y + ya + height))
ya = -ya;
y += ya;
obj.style.left = x;
obj.style.top = y;
}
}
this.getCode = function() {
return "<v:" + shape + " fillcolor='" + this.color + "' style='position:absolute;left:" + this.x +";top:" + this.y + ";z-index:" + zindex + ";width:" + this.width + ";height:" + this.height + ";' id='" + this.name + "'/>";
}
}
</script>
</head>
<body topmargin='2' leftmargin='2'>
<div id=a style='table-Layout:fixed;width:100%;height:100%;border:1 solid black'></div>
<script>
var container = new Container("a", 0, 0, a.offsetWidth, a.offsetHeight);
var obj = new Array();
for (var i=0; i<5; i++) {
shape = Math.round(Math.random())==1?"oval":"rect";
size = Math.round(Math.random() * 70) + 20;
x = Math.round(Math.random() * (a.offsetWidth - size));
y = Math.round(Math.random() * (a.offsetHeight - size));
color = "rgb(" + Math.round(Math.random()*255) + "," + Math.round(Math.random()*255) + "," + Math.round(Math.random()*255) + ")";
xa = Math.round(Math.random()*10);
ya = Math.round(Math.random()*10); obj[i] = new SHAPE("SHAPE" + i, shape, x, y, size, size, color, i, xa, ya);
container.put(obj[i]);
}
function move() {
for (i=0; i<obj.length; i++)
obj[i].move();
}
setInterval("move();",10);
</script>
</body>
</html>