Home | Join! | Help | Browse | Forums | NuWorld | NWF | PoPo   
Crazy like a bedbug!
Recently Added
ikimashokie's Reading Room


Bouncing Image Script!
by:

this script makes things bounce up and down at random, like i had on my page a while ago. scroll down to change the picture.

-------------------------------- copy after here ---------------------------------------------



<script>
function getScale(c, height) {
var t = Math.sqrt(2 * height / c.gravity);
var scale = 4 * height / sqr(t);
return scale;
}
function sqr(x) {
return x * x;
}
function updateBounce(c) {
var bottom = getViewYOffset() + getViewHeight() - c.imageHeight;
for (var i = 0; i < c.imageCount; i++) {
var name = c.prefix + i;

var scale = c.pScale[name];
var x = getLayerX(name) + c.xSpeed[name];
var y = -scale * sqr(c.pIndex[name]) + c.pHeight[name];
if (y > 0)
y = bottom - y;
else
y = bottom;
var bounds = outOfBounds(c, x, y, c.imageWidth, c.imageHeight);
if (bounds & 1) { // left
x = 2 * getViewXOffset() - x;
c.xSpeed[name] = -c.xSpeed[name] * c.elasticity;
}
if (bounds & 2) { // right
x = 2 * (getViewXOffset() + getViewWidth() - c.imageWidth) - x;
c.xSpeed[name] = -c.xSpeed[name] * c.elasticity;
}
moveLayer(name, x, y);
if ((c.pIndex[name] += 0.5) > c.pLimit[name]) {
c.xSpeed[name] *= 1 - c.friction;
c.pIndex[name] -= Math.sqrt(c.pHeight[name] / scale);
c.pHeight[name] = Math.max(0.25, c.pHeight[name] * c.elasticity);
c.pIndex[name] = -(c.pLimit[name] = Math.sqrt(c.pHeight[name] / scale));
if (c.pHeight[name] < c.kickThreshold) {
if (c.kickOpt == 1) { // kick
c.pHeight[name] = 100 + random(getViewHeight());
c.xSpeed[name] = random(41) - 20;
scale = (c.pScale[name] = getScale(c, c.pHeight[name]));
c.pIndex[name] = -(c.pLimit[name] = Math.sqrt(c.pHeight[name] / scale));
}
else if (c.kickOpt == 2) { // drop
c.pHeight[name] = getViewHeight() + c.imageHeight + 100 + random(500);
c.pScale[name] = getScale(c, c.pHeight[name]);
c.xSpeed[name] = random(41) - 20;
c.pIndex[name] = 0;
c.pLimit[name] = Math.sqrt(c.pHeight[name] / scale);
}
}
}
}
setTimeout('updateBounce(c' + c.uid + ')', c.updateInterval);
}
</script>
<script src="http://geocities.yahoo.com/js_source/layers.js"></script>
</head>
<body bgcolor="#FFFFFF" link="#0000FF" vlink="#FF0000" text="#000000"
onLoad="window.onresize=new Function('if (navigator.appVersion=='Netscape') history.go(0);');">
<script>
if (layerSupport()) {
c14 = new config();
c14.uid = 14;
c14.prefix = "y_bounce14";
c14.image = "PICTURE FILE/PATH GOES HERE";
// You can play with these numbers to make the picture bounce differently.
c14.imageWidth = 95;
c14.imageHeight = 106;
c14.imageCount = 6;
c14.gravity = 1;
c14.friction = 1;
c14.elasticity = .5;
c14.topWall = 0;
// ^^^^^^^^^^^^^^^^
c14.xSpeed = new Array();
c14.pHeight = new Array();
c14.pIndex = new Array();
c14.pScale = new Array();
c14.pLimit = new Array();
c14.kickThreshold = 5;
c14.kickOpt = 1;
for (var i = 0; i < c14.imageCount; i++) {
var name = c14.prefix + i;
c14.xSpeed[name] = random(41) - 20;
c14.pHeight[name] = -1 == -1 ? randomY(c14) : -1 + random(50);
c14.pScale[name] = getScale(c14, c14.pHeight[name]);
c14.pLimit[name] = Math.sqrt(c14.pHeight[name] / c14.pScale[name]);
c14.pIndex[name] = 0;
writeImage(c14.image, name, randomX(c14), c14.pHeight[name]);
}

setTimeout('updateBounce(c14)', c14.updateInterval);
}
</script>

lor=colours[count2];
if (ie) E[count1].style.background=colours[count2];
}

function MouseFollow(){
ay = ny+=(ypos-ny)*delay;
ax = nx+=(xpos-nx)*delay;
TwistnSpin();
colourStep();
setTimeout('MouseFollow()',10);
}
if (ns||ie)MouseFollow();
//-->
</script>



ikimashokie's Weblog Site • NuTang.com

NuTang is the first web site to implement PPGY Technology. This page was generated in 0.115seconds.

  Send to a friend on AIM | Set as Homepage | Bookmark Home | NuTang Collage | Terms of Service & Privacy Policy | Link to Us | Monthly Top 10s
All content Copyright 2003-2047 NuTang.com and respective members. Contact us at NuTang[AT]gmail.com.