View Full Version : flight404 "sperm" effect ?
mmacc
01-31-2005, 08:44 PM
hehehe , yes .
check this
http://www.flight404.com
when you click an option , there's a little drops or lights or whatever ,that moves from left to right in random directions .
how they do that ?
any samples ? .
thank you very much ! .
M
emergency_pants
02-01-2005, 05:07 PM
Lovely effect!!
It looks like a bunch of sperms are attached. Each one is given a random speed, angle and a wave height property. If you follow one, you can see it has a uniform speed, direction and wave. If I get time, I might try and make a test... it's nice.
emergency_pants
02-01-2005, 06:10 PM
It still needs lots of work, but its a start.
for (i=0; i<10; i++) {
_root.attachMovie("thingy", "thingy"+i, i);
var thisClip:MovieClip = this["thingy"+i];
thisClip._x = 15;
thisClip._y = 180;
thisClip._rotation = 90;
thisClip.speed = Math.round(Math.random()*8)+3;
thisClip.range = Math.round(Math.random()*90);
thisClip.turnDirection = Math.floor(Math.random()*2);
trace(thisClip.turnDirection);
thisClip.onEnterFrame = function() {
this._alpha -=1;
if (this.turnDirection == 0) {
this._rotation += 10;
if (this._rotation>this.range+90) {
this.turnDirection = 1;
}
}
if (this.turnDirection == 1) {
this._rotation -= 10;
if (this._rotation<-this.range+90) {
this.turnDirection = 0;
}
}
this._x += Math.sin(this._rotation*(Math.PI/180))*this.speed;
this._y += Math.cos(this._rotation*(Math.PI/180))*this.speed*-1;
};
}
emergency_pants
02-04-2005, 02:29 PM
heheheh... a new improved, slightly disturbing but altogether more hypnotic version, with tails rather than noses.
Actually, the tails do not wiggle, but the rotation of the clip gives the illusion that they do. Nice.
Re-coded and saved for Flash MX.
The flight404 version has scripted tails... you can tell because they are longer when the sperms move faster. Anyone got a script for the tail? I guess it'll be a bit like a mouse follow script or something.
That is amazing.
I understand math very well, but how did you go about doing the calculations, Simon?
Did it take a lot of trial and error?
emergency_pants
02-07-2005, 01:08 AM
A little bit of trial and error to get the random value ranges correct so it looked right.
The main calculation is this one:
this._x += Math.sin(this._rotation*(Math.PI/180))*this.speed;
this._y += Math.cos(this._rotation*(Math.PI/180))*this.speed*-1;
What that does is move a clip in the direction the clip._rotation and at a given speed. So, all you need to do is work out a system which rotates the clip cwise and ccwise, give the clip a speed property and it moves!
The calc comes from a top down driving game I made some time ago. It's a handy calc for driving cos you can set _rotation and speed with keypresses!
right. i understood the sin and cosine calculations. you converted angles to radians and then multiplied by speed, to make it move faster. but also made the -1 so that it didn't make a full circle.
thanks. :)
these are the best actionscript forums on the net.
rubenred
02-11-2005, 03:00 PM
thankyou all
nice of you to give code
vBulletin® v3.7.1, Copyright ©2000-2009, Jelsoft Enterprises Ltd.