Fish eyeball vector

W

while_1

I made a simple animated gif of a fish whose eyeball wiggles
a few loops upon any mouseover:

< img id="ppic" src="http://xxx.yyy.com/Nice_Fish.gif"
onMouseOver="document.images.ppic.src=document.images.ppic.src" >

But what I'd really like to do is to turn the eyeball into a
floating sprite that follows the mouse....so the fish looks at
the mouse cursor, at whatever position the mouse happens to be,
upon mouseover.

You'd need to calculate a relative vector somehow, from the center
of the eyeball position to the current mouse position.
I think I remember how to do that from previous exmperiments
with OpenGL. In fact I think I know how to do the whole
thing with OpenGL, but I haven't got a clue how to do it with
javascript, in browser land.

Is this possible, with javascript?
How would I do it?
 
T

Tony

I made a simple animated gif of a fish whose eyeball wiggles
a few loops upon any mouseover:

< img id="ppic" src="http://xxx.yyy.com/Nice_Fish.gif"
onMouseOver="document.images.ppic.src=document.images.ppic.src" >

But what I'd really like to do is to turn the eyeball into a
floating sprite that follows the mouse....so the fish looks at
the mouse cursor, at whatever position the mouse happens to be,
upon mouseover.

You'd need to calculate a relative vector somehow, from the center
of the eyeball position to the current mouse position.
I think I remember how to do that from previous exmperiments
with OpenGL. In fact I think I know how to do the whole
thing with OpenGL, but I haven't got a clue how to do it with
javascript, in browser land.

Is this possible, with javascript?
How would I do it?

You can use the basic trig from these:

http://www.propix.hu

http://www.btinternet.com/~kurt.grigg/javascript/followingeyes/followingeyes.html

http://www.btinternet.com/~kurt.grigg/javascript/staticeyes/staticeyes.html

Tone.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,522
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top