GreyFaerie
09-10-2003, 01:36 PM
I went to this site that had a javascript where when you clicked your mouse on the screen little stars flew from one corner of the screen to the next. Does anyone know where I can find this?
|
Click to See Complete Forum and Search --> : Does anyone know where I can find this script? GreyFaerie 09-10-2003, 01:36 PM I went to this site that had a javascript where when you clicked your mouse on the screen little stars flew from one corner of the screen to the next. Does anyone know where I can find this? 96turnerri 09-10-2003, 03:44 PM these dont follow the mouse but its a start <BODY> <SCRIPT LANGUAGE="JavaScript1.2"> var no = 12; // number of hearts var speed = 10; // smaller number moves the hearts faster var heart = "http://www.your-web-site-address-here.com/where/you/put/it/heart.gif"; var flag; var ns4up = (document.layers) ? 1 : 0; // browser sniffer var ie4up = (document.all) ? 1 : 0; var dx, xp, yp; // coordinate and position variables var am, stx, sty; // amplitude and step variables var i, doc_width = 800, doc_height = 600; if (ns4up) { doc_width = self.innerWidth; doc_height = self.innerHeight; } else if (ie4up) { doc_width = document.body.clientWidth; doc_height = document.body.clientHeight; } dx = new Array(); xp = new Array(); yp = new Array(); amx = new Array(); amy = new Array(); stx = new Array(); sty = new Array(); flag = new Array(); for (i = 0; i < no; ++ i) { dx[i] = 0; // set coordinate variables xp[i] = Math.random()*(doc_width-30)+10; // set position variables yp[i] = Math.random()*doc_height; amy[i] = 12+ Math.random()*20; // set amplitude variables amx[i] = 10+ Math.random()*40; stx[i] = 0.02 + Math.random()/10; // set step variables sty[i] = 0.7 + Math.random(); // set step variables flag[i] = (Math.random()>0.5)?1:0; if (ns4up) { // set layers if (i == 0) { document.write("<layer name=\"dot"+ i +"\" left=\"15\" "); document.write("top=\"15\" visibility=\"show\"><img src=\""); document.write(heart+ "\" border=\"0\"></layer>"); } else { document.write("<layer name=\"dot"+ i +"\" left=\"15\" "); document.write("top=\"15\" visibility=\"show\"><img src=\""); document.write(heart+ "\" border=\"0\"></layer>"); } } else if (ie4up) { if (i == 0) { document.write("<div id=\"dot"+ i +"\" style=\"POSITION: "); document.write("absolute; Z-INDEX: "+ i +"; VISIBILITY: "); document.write("visible; TOP: 15px; LEFT: 15px;\"><img src=\""); document.write(heart+ "\" border=\"0\"></div>"); } else { document.write("<div id=\"dot"+ i +"\" style=\"POSITION: "); document.write("absolute; Z-INDEX: "+ i +"; VISIBILITY: "); document.write("visible; TOP: 15px; LEFT: 15px;\"><img src=\""); document.write(heart+ "\" border=\"0\"></div>"); } } } function snowNS() { // Netscape main animation function for (i = 0; i < no; ++ i) { // iterate for every dot if (yp[i] > doc_height-50) { xp[i] = 10+ Math.random()*(doc_width-amx[i]-30); yp[i] = 0; flag[i]=(Math.random()<0.5)?1:0; stx[i] = 0.02 + Math.random()/10; sty[i] = 0.7 + Math.random(); doc_width = self.innerWidth; doc_height = self.innerHeight; } if (flag[i]) dx[i] += stx[i]; else dx[i] -= stx[i]; if (Math.abs(dx[i]) > Math.PI) { yp[i]+=Math.abs(amy[i]*dx[i]); xp[i]+=amx[i]*dx[i]; dx[i]=0; flag[i]=!flag[i]; } document.layers["dot"+i].top = yp[i] + amy[i]*(Math.abs(Math.sin(dx[i])+dx[i])); document.layers["dot"+i].left = xp[i] + amx[i]*dx[i]; } setTimeout("snowNS()", speed); } function snowIE() { // IE main animation function for (i = 0; i < no; ++ i) { // iterate for every dot if (yp[i] > doc_height-50) { xp[i] = 10+ Math.random()*(doc_width-amx[i]-30); yp[i] = 0; stx[i] = 0.02 + Math.random()/10; sty[i] = 0.7 + Math.random(); flag[i]=(Math.random()<0.5)?1:0; doc_width = document.body.clientWidth; doc_height = document.body.clientHeight; } if (flag[i]) dx[i] += stx[i]; else dx[i] -= stx[i]; if (Math.abs(dx[i]) > Math.PI) { yp[i]+=Math.abs(amy[i]*dx[i]); xp[i]+=amx[i]*dx[i]; dx[i]=0; flag[i]=!flag[i]; } document.all["dot"+i].style.pixelTop = yp[i] + amy[i]*(Math.abs(Math.sin(dx[i])+dx[i])); document.all["dot"+i].style.pixelLeft = xp[i] + amx[i]*dx[i]; } setTimeout("snowIE()", speed); } if (ns4up) { snowNS(); } else if (ie4up) { snowIE(); } </script> dont forget to change the image to an actual image David Harrison 09-10-2003, 04:11 PM Did you go away and write all that??? I had a look at it but I got lost in the arrays. 96turnerri 09-10-2003, 04:16 PM no i didnt write it i had it saved on my comp from some1 else, where did you get lost and ill help you out David Harrison 09-10-2003, 04:21 PM No no, I understand arrays perfectly and I use them a lot myself. It's just that now I've seen that script I'll have to redifine my definition of a lot. The sheer quantity overwhelms me. 96turnerri 09-10-2003, 04:29 PM ok lol i realised that it wasnt you that started the thread after silly me o well best of luck m8 David Harrison 09-10-2003, 04:33 PM That's OK, so long as GreyFaerie is happy. :) 96turnerri 09-10-2003, 04:39 PM hope so :D GreyFaerie 09-10-2003, 06:55 PM thats not exactly it... I guess what I am looking for could be considered a mouse trail but isnt really... I wish the page I saw this on was still up. thanks for your help though! 96turnerri 09-10-2003, 07:03 PM well i tried sorry but i couldnt find what u were after thought that mite do or you could edit it to become a mouse trail? GreyFaerie 09-10-2003, 07:30 PM aww dont be sorry... i really do appreciate it. ill figure it out 96turnerri 09-10-2003, 07:35 PM ok ty well if i come accross one ill post it, i know exactly what your after i just cant think what sites ive seen it on 96turnerri 09-10-2003, 07:38 PM <HTML> <HEAD><TITLE>Free Scripts And Tools For Webmasters @ www.AceJS.com</TITLE> </HEAD> <BODY TEXT="#000000" onLoad="init()"> <div id="dot0" style="position: absolute; visibility: hidden; height: 11; width: 11;"><img src="bullet1.gif" height=11 width=11></div> <div id="dot1" style="position: absolute; height: 11; width: 11;"><img src="bullet1.gif" height=11 width=11></div> <div id="dot2" style="position: absolute; height: 11; width: 11;"><img src="bullet1.gif" height=11 width=11></div> <div id="dot3" style="position: absolute; height: 11; width: 11;"><img src="bullet1.gif" height=11 width=11></div> <div id="dot4" style="position: absolute; height: 11; width: 11;"><img src="bullet1.gif" height=11 width=11></div> <div id="dot5" style="position: absolute; height: 11; width: 11;"><img src="bullet1.gif" height=11 width=11></div> <div id="dot6" style="position: absolute; height: 11; width: 11;"><img src="bullet1.gif" height=11 width=11></div> <SCRIPT LANGUAGE="JavaScript"> var nDots = 7; var Xpos = 0; var Ypos = 0; var DELTAT = .01; var SEGLEN = 10; var SPRINGK = 10; var MASS = 1; var GRAVITY = 50; var RESISTANCE = 10; var STOPVEL = 0.1; var STOPACC = 0.1; var DOTSIZE = 11; var BOUNCE = 0.75; var isNetscape = navigator.appName=="Netscape"; var followmouse = true; var dots = new Array(); init(); function init() { var i = 0; for (i = 0; i < nDots; i++) { dots[i] = new dot(i); } if (!isNetscape) { } for (i = 0; i < nDots; i++) { dots[i].obj.left = dots[i].X; dots[i].obj.top = dots[i].Y; } if (isNetscape) { startanimate(); } else { setTimeout("startanimate()", 1000); } } function dot(i) { this.X = Xpos; this.Y = Ypos; this.dx = 0; this.dy = 0; if (isNetscape) { this.obj = eval("document.dot" + i); } else { this.obj = eval("dot" + i + ".style"); } } function startanimate() { setInterval("animate()", 20); } function setInitPositions(dots) { var startloc = document.all.tags("LI"); var i = 0; for (i = 0; i < startloc.length && i < (nDots - 1); i++) { dots[i+1].X = startloc[i].offsetLeft startloc[i].offsetParent.offsetLeft - DOTSIZE; dots[i+1].Y = startloc[i].offsetTop + startloc[i].offsetParent.offsetTop + 2*DOTSIZE; } dots[0].X = dots[1].X; dots[0].Y = dots[1].Y - SEGLEN; } function MoveHandler(e) { Xpos = e.pageX; Ypos = e.pageY; return true; } function MoveHandlerIE() { Xpos = window.event.x + document.body.scrollLeft; Ypos = window.event.y + document.body.scrollTop; } if (isNetscape) { document.captureEvents(Event.MOUSEMOVE); document.onMouseMove = MoveHandler; } else { document.onmousemove = MoveHandlerIE; } function vec(X, Y) { this.X = X; this.Y = Y; } function springForce(i, j, spring) { var dx = (dots[i].X - dots[j].X); var dy = (dots[i].Y - dots[j].Y); var len = Math.sqrt(dx*dx + dy*dy); if (len > SEGLEN) { var springF = SPRINGK * (len - SEGLEN); spring.X += (dx / len) * springF; spring.Y += (dy / len) * springF; } } function animate() { var start = 0; if (followmouse) { dots[0].X = Xpos; dots[0].Y = Ypos; start = 1; } for (i = start ; i < nDots; i++ ) { var spring = new vec(0, 0); if (i > 0) { springForce(i-1, i, spring); } if (i < (nDots - 1)) { springForce(i+1, i, spring); } var resist = new vec(-dots[i].dx * RESISTANCE, -dots[i].dy * RESISTANCE); var accel = new vec((spring.X + resist.X)/ MASS, (spring.Y + resist.Y)/ MASS + GRAVITY); dots[i].dx += (DELTAT * accel.X); dots[i].dy += (DELTAT * accel.Y); if (Math.abs(dots[i].dx) < STOPVEL && Math.abs(dots[i].dy) < STOPVEL && Math.abs(accel.X) < STOPACC && Math.abs(accel.Y) < STOPACC) { dots[i].dx = 0; dots[i].dy = 0; } dots[i].X += dots[i].dx; dots[i].Y += dots[i].dy; var height, width; if (isNetscape) { height = window.innerHeight + document.scrollTop; width = window.innerWidth + document.scrollLeft; } else { height = document.body.clientHeight + document.body.scrollTop; width = document.body.clientWidth + document.body.scrollLeft; } if (dots[i].Y >= height - DOTSIZE - 1) { if (dots[i].dy > 0) { dots[i].dy = BOUNCE * -dots[i].dy; } dots[i].Y = height - DOTSIZE - 1; } if (dots[i].X >= width - DOTSIZE) { if (dots[i].dx > 0) { dots[i].dx = BOUNCE * -dots[i].dx; } dots[i].X = width - DOTSIZE - 1; } if (dots[i].X < 0) { if (dots[i].dx < 0) { dots[i].dx = BOUNCE * -dots[i].dx; } dots[i].X = 0; } dots[i].obj.left = dots[i].X; dots[i].obj.top = dots[i].Y; } } // End --> </script> picture is attached ravynfaire 10-10-2003, 12:30 PM I am posting a link to a site that I love to go to. You can run the script to see if this is what you are thinking of before looking at the script. Its called fairy dust and it follows your mouse. http://webdeveloper.earthweb.com/webjs/jsform/item.php/71651 I like this script a lot. Let me know if this helps, if not I will continue to look. webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |