Jump to content

Follow mouse


Fire Dragon

Recommended Posts

Okay,I need this kind pictures:1.Picture what replaces mouse cursor.How I can make?Or picture follows mouse veeeery near.2.Picture,what follows mouse,but it moves itself,and when you don't move cursor,image moves near, and near.Until it touches mousecursor.I made example with Game Maker,what I mean.It is exe file,so you can load and open it.If you want,check it first with virus scanner.Here is LINKLittle strange way to tell what means :)

Link to comment
Share on other sites

Post what you have for code and I can debug it for you...I just solved the same problem (getting the mouse position in FireFox) that is most likely the cause of your trouble.

I used just that code,what was on the website,so it is like this:
<script>/*Cross browser cursor trailer scriptBy Brian Caputo (bcaputo@icdc.com)Written permission granted to lissaexplains.comto distribute the script for personal use. (DO NOT REMOVE THIS)*/B=document.all;C=document.layers;T1=new Array("peli_link.gif",38,35)nos=parseInt(T1.length/3)rate=50ie5fix1=0;ie5fix2=0;for (i=0;i<nos;i++){createContainer("CUR"+i,i*10,i*10,i*3+1,i*3+2,"","<img src='"+T1[i*3]+"' width="+T1[(i*3+1)]+" height="+T1[(i*3+2)]+" border=0>")}function createContainer(N,Xp,Yp,W,H,At,HT,Op,St){with (document){write((! ? "<layer id='"+N+"' left="+Xp+" top="+Yp+" width="+W+" height="+H : "<div id='"+N+"'"+" style='position:absolute;left:"+Xp+"; top:"+Yp+"; width:"+W+"; height:"+H+"; ");if(St){if ©write(" style='");write(St+";' ")}else write((?"'":"");write((At)? At+">" : ">");write((HT) ? HT : "");if (!Op)closeContainer(N)}}function closeContainer(){document.write((?"</div>":"</layer>")}function getXpos(N){return ( ? parseInt(B[N].style.left) : C[N].left}function getYpos(N){return ( ? parseInt(B[N].style.top) : C[N].top}function moveContainer(N,DX,DY){c=( ? B[N].style :C[N];c.left=DX;c.top=DY}function cycle(){//if (IE5)if (document.all&&window.print){ie5fix1=document.body.scrollLeft;ie5fix2=document.body.scrollTop;}for (i=0;i<(nos-1);i++){moveContainer("CUR"+i,getXpos("CUR"+(i+1)),getYpos("CUR"+(i+1)))}}function newPos(e){moveContainer("CUR"+(nos-1),(?event.clientX+ie5fix1:e.pageX+2,(?event.clientY+ie5fix2:e.pageY+2)}if(document.layers)document.captureEvents(Event.MOUSEMOVE)document.onmousemove=newPossetInterval("cycle()",rate)</script>

Or do you have another samekind code,because looks like that I must ask permission before I can use this code?

Edited by Jonas
Link to comment
Share on other sites

use this, it works in IE, Opera, and FF

<html><head></head><body><!-- Original script by Philip Winston (pwinston@yahoo.com) --><div id="dot0" style="position: absolute; visibility: hidden; height: 2; width: 2;"> <img src="trailtrans.gif" height=20 width=20> </div><div id="dot1" style="position: absolute; height:2; width: 2;"> <img src="trail6c.gif" height=10 width=10> </div><div id="dot2" style="position: absolute; height: 10; width: 10;"> <img src="trail5c.gif" height=15 width=15> </div><div id="dot3" style="position: absolute; height: 18; width: 18;"> <img src="trail4c.gif" height=20 width=20> </div><div id="dot4" style="position: absolute; height: 26; width: 26;"> <img src="trail3c.gif" height=30 width=30> </div><div id="dot5" style="position: absolute; height: 34; width: 34;"> <img src="trail2c.gif" height=35 width=35> </div><div id="dot6" style="position: absolute; height: 42; width: 42;"> <img src="trail1c.gif" height=40 width=40> </div><div id="dot7" style="position: absolute; height: 66; width: 66;"> <img src="trailtrans.gif" height=20 width=20> </div><script language="JavaScript" type="text/javascript"><!--var nDots = 8;var Xpos = 0;var Ypos = 0;var DELTAT = .01;var SEGLEN = 10;var SPRINGK = 10;var MASS = 1;var XGRAVITY = 0;var YGRAVITY = 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 isNetscape = (navigator.appName.indexOf('Gecko') != -1);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()", 100);}}function dot(i) {this.X = Xpos;this.Y = Ypos;this.dx = 0;this.dy = 0;if (isNetscape) {	//original code that did not work in FireFox//this.obj = eval("document.dot" + i);//fix for FireFoxthis.obj = eval(document.getElementById("dot"+i).style);} 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].offsetLeftstartloc[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 + XGRAVITY,(spring.Y + resist.Y)/ MASS + YGRAVITY);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 + window.pageYOffset;width = window.innerWidth + window.pageXOffset;} 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;  }}//--></script></body></html>

download the zip file of images (put them in the same folder as the html page).Needed Images

Edited by Jonas
Link to comment
Share on other sites

Thanks,but it don't "replace" mouse cursor,like that first one,what needs permission.Well,it looks like,I must ask permission so I can use that first code.Thanks anyway.BTW,I just noticed that you can use it for personally use :) I'm sorry that I caused so much writing to you. :) Soorryyy!But it gave new idea,so thanks!

Link to comment
Share on other sites

When posting long blocks of code, please try and use the BBcode set

 instead of just [code], as that will display a div with a scrollbar, so we won't have to scroll so far in the main window.[codebox]Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.

will output

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.

Thank you. :)

Link to comment
Share on other sites

why don't you make that an option button when posting? It would make more sense then expecting people to know it is there....which I didn't. Sorry :)Also why does the codebox stretch the page so much...I would rather scroll down then over!!!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...