About "Mouse Bubbles" Script PLEASE HELP

admin

Administrator
Staff member
I have a problem. I am currently doing a site for a water park. I came across this script and like it alot. One problem, I want it to be in one place and still have the same effect but the code was written to go when the mouse moves. So it follows the mouse. Here is the script....

<SCRIPT LANGUAGE="JavaScript">
<!-- Original: Kurt Grigg (<!-- e --><a href="mailto:[email protected]">[email protected]</a><!-- e -->) -->
<!-- Web Site: <!-- m --><a class="postlink" href="http://website.lineone.net/~kurt.grigg/javascript">http://website.lineone.net/~kurt.grigg/javascript</a><!-- m --> -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! <!-- m --><a class="postlink" href="http://javascript.internet.com">http://javascript.internet.com</a><!-- m --> -->

<!-- Begin
Image0 = new Image();
Image0.src = "BubBlack.gif";
Amount = 20;
Ymouse = -50;
Xmouse = -50;
Ypos = new Array();
Xpos = new Array();
Speed = new Array();
rate = new Array();
grow = new Array();
Step = new Array();
Cstep = new Array();
nsSize = new Array();
ns = (document.layers)?1:0;
(document.layers)?window.captureEvents(Event.MOUSEMOVE):0;
function Mouse(evnt) {
Ymouse=(document.layers)?evnt.pageY-20:event.y-20;
Xmouse=(document.layers)?evnt.pageX:event.x;
}
(document.layers)?window.onMouseMove=Mouse:document.onmousemove=Mouse;
for (i = 0; i < Amount; i++) {
Ypos = Ymouse;
Xpos = Xmouse;
Speed = Math.random()*4+1;
Cstep = 0;
Step = Math.random()*0.1+0.05;
grow = 8;
nsSize = Math.random()*15+5;
rate = Math.random()*0.5+0.1;
}
if (ns) {
for (i = 0; i < Amount; i++) {
document.write("<LAYER NAME='sn"+i+"' LEFT=0 TOP=0><img src=http://www.webdeveloper.com/forum/archive/index.php/"+Image0.src+" name='N' width="+nsSize+" height="+nsSize+"></LAYER>");
}
}
else {
document.write('<div style="position:absolute;top:0px;left:0px"><div style="position:relative">');
for (i = 0; i < Amount; i++) {
document.write('<img id="si" src=http://www.webdeveloper.com/forum/archive/index.php/"'+Image0.src+'" style="position:absolute;top:0px;left:0px;filter:alpha(opacity=90)">');
}
document.write('</div></div>');
}
function MouseBubbles() {
var hscrll = (document.layers)?window.pageYOffset:document.body.scrollTop;
var wscrll = (document.layers)?window.pageXOffset:document.body.scrollLeft;
for (i = 0; i < Amount; i++){
sy = Speed * Math.sin(270 * Math.PI / 180);
sx = Speed * Math.cos(Cstep * 4);
Ypos += sy;
Xpos += sx;
if (Ypos < -40) {
Ypos = Ymouse;
Xpos = Xmouse;
Speed = Math.random() * 6 + 4;
grow = 8;
nsSize = Math.random() * 15 + 5;
}
if (ns) {
document.layers['sn'+i].left = Xpos + wscrll;
document.layers['sn'+i].top = Ypos + hscrll;
}
else {
si.style.pixelLeft = Xpos + wscrll;
si.style.pixelTop = Ypos + hscrll;
si.style.width = grow;
si.style.height = grow;
}
grow += rate;
Cstep += Step;
if (grow > 24) grow = 25;
}
setTimeout('MouseBubbles()', 10);
}
MouseBubbles();
// End -->
</script>


If any one could alter this for me, so it stays in one place and still has the same effect that would be greatly appreciated. Thanks
 
Back
Top