View Full Version : Challenge
(eye-candy) - Water
The theme is WATER, 25 lines is the maximum.
Show me what
you got, people!
pom :)
farafiro
20-05-2003, 09:59 AM
so, where is yours??
Where is it specified that I should be the first to
post?
farafiro
20-05-2003, 02:38 PM
within the rules, Jesse says the starter should
.............
Damn it! I knew I should have taken reading lessons at some
point in my life...
I won't be able to produce anything before the
weekend, unfortunately :( so let's wait until then for this
challenge.
pom :cool:
inudor
21-05-2003, 06:25 AM
Eeeeeeeeeeeehm... uuuuuuhm... what do you understand for
"water" :p
This is the only idea I had!
/*
* Description:
waves of dots moving!
*/
wavesNum = 3; // Tested with 3 waves
phase =
new Array(index); // Different initial phase for each wave
vertOff = new
Array(index); // Vertical offset for each wave
steps = 26; // Controles the
wave's width
amplitude = 8; // Controles the waves amplitude
//
Initializations
for(index=0; index<wavesNum;
index++){
_root.createEmptyMovieClip("mc"+index, 1+index);
phase[index] =
1.5*index;
vertOff[index] = 100 + index*50;
}
// Draw
method
function draw() {
for(index=0; index<wavesNum; index++){
//
Clear the content to
repaint
_root["mc"+index].clear();
for(i=0;i<steps;i+=0.5){
xpos =
i*22; // A good distance to display the dots without overlapping
ypos =
vertOff[index] +
Math.sin(i+phase[index])*amplitude;
_root["mc"+index].moveTo(xpos,
ypos);
blue = 0x0000FF + ypos;
_root["mc"+index].lineStyle(10,
blue);
// Draw a little line to simulate a
dot
_root["mc"+index].lineTo(xpos+0.15, ypos);
}
// The next time we
draw the wave it will have a diferent phase
// to simulate the
movement
phase[index] += 0.5;
}
}
setInterval(draw,
25);
I find this challenges a funny way of sharing
code!
kimgar
21-05-2003, 07:50 AM
ooooh, nice one inudor!
love your code, reminds me of
the good old times.
GeorgeG
21-05-2003, 11:06 AM
Ok here is my effort, it's supposed to be raindrops!! My
first flash coding effort so don't be too harsh!
i = 0;
maxDrips =
100;
function startDrip(_xpos,_ypos, _index) {
if (_index < 0)
{
_root.createEmptyMovieClip("index"+i,2+i);
_index =
i++;
}
else
_root["index"+_index].clear();
_root["index"+_index]._x
= _xpos;
_root["index"+_index]._y =
_ypos;
_root["index"+_index].lineThickness =
10;
_root["index"+_index].lineStyle(10, 0x0000FF,
100);
_root["index"+_index].lineTo(0.15, 0);
}
function
updateWater() {
for (z = 0; z < i;z++)
{
_root["index"+z].clear();
_root["index"+z].lineStyle(++_root["index"+z].lineThickness,
0x0000FF, 100-_root["index"+z].lineThickness);
_root["index"+z].lineTo(0.15,
0);
if (_root["index"+z].lineThickness == 99)
startDrip(random(500),
random(500),z);
}
if (i < maxDrips)
startDrip(random(500),
random(500),-1);
}
setInterval(updateWater,
25);
Wheeeee!
Jesse
23-05-2003, 05:25 AM
Wow. I sure wish we started this forum a long time ago. Two
killer entries so far! Keep them up! I might even try my hand at this one but I
gotta think of an idea first.
McGiver
23-05-2003, 10:02 AM
this eye-candy water is no bad idea, the problem is we all
lack eye-candy ideas for projects with less than 25 lines (-->respect to
george and inudor who managed to make it within these limits). The thing with
eye candy is, that most beatiful things need time, and either premade
graphics/movies, or at least much more lines
-->My idea is a waterdrop
which keeps its hull: because i am too lazy to do that on my own (and it would
be probably bigger than 25 lines) look the actual Bit 101
(http://www.bit-101.com/lab.html) experiment of 21 und 22.05.
(he must have
stolen my idea ;) )
Inspired by the raindrops from GeorgeG :)// pom -- raindrops
-- 16 lines
function drawCircle(taille,col,pro){
var
mc=this.createEmptyMovieClip("b"+pro,pro);
mc.lineStyle(taille,col,100);
mc.lineTo(.15,.45);
return
mc;}
function
drawThing(){
cl1=drawCircle(a=30+random(50),0xffffff,(++prof)+10000);
cl2=drawCircle(a+20,0,prof);
cl1._x=cl2._x=random
(550);
cl1._y=cl2._y=random
(400);
cl1.onEnterFrame=cl2.onEnterFrame=function(){
if (120 -
this._xscale > 1) this._xscale = this._yscale += (120 -
this._xscale)/7;
else this.onEnterFrame = function(){
this._alpha -=
2;
if (this._alpha < 5)
this.removeMovieClip();}}}
setInterval(drawThing,30);
And if you think the fade looks weird: //pom --
rain2
function drawCircle(taille,col,pro){
var
mc=this.createEmptyMovieClip("b"+pro,pro);
mc.lineStyle(taille,col,100);
mc.lineTo(.15,.45);
return
mc;
}
function
drawThing(prof){
cl1=drawCircle(a=30+random(50),0xffffff,prof+10000);
cl2=drawCircle(a+20,0,prof);
cl1._x=cl2._x=random
(550);
cl1._y=cl2._y=random
(400);
cl1.onEnterFrame=cl2.onEnterFrame=function(){
if (120 -
this._xscale > 1) this._xscale = this._yscale += (120 -
this._xscale)/7;
else delete
this.onEnterFrame;
}
}
this.onEnterFrame = function(){if (i<100)
drawThing(i++);};
this.onMouseDown=function(){i=0;}You have to click when it
stops :)
ToddziLLa
24-05-2003, 11:24 AM
pom...is there any way you could create this same effect in
Flash 5? I copied to code into F5, and guess what? doesn't
work...
function drawCircle(taille,col,pro){
var
mc=this.createEmptyMovieClip("b"+pro,pro);
mc.lineStyle(taille,col,100);
mc.lineTo(.15,.45);
return
mc;}
function
drawThing(){
cl1=drawCircle(a=30+random(50),0xffffff,(++prof)+10000);
cl2=drawCircle(a+20,0,prof);
cl1._x=cl2._x=random
(550);
cl1._y=cl2._y=random
(400);
cl1.onEnterFrame=cl2.onEnterFrame=function(){
if (120 -
this._xscale > 1) this._xscale = this._yscale += (120 -
this._xscale)/7;
else this.onEnterFrame = function(){
this._alpha -=
2;
if (this._alpha < 5)
this.removeMovieClip();}}}
setInterval(drawThing,30);
Echoblade
25-05-2003, 02:30 AM
here is my idea, I tried to create a moving wave, doesn't
look great but if you squint your eyes it helps =p
x_move =
0;
onEnterFrame = function ()
{
if ( x_move < 750 )
{
x_move
+= 40;
_root.createEmptyMovieClip( "wave", 1
);
with(wave)
{
lineStyle( 1, 0x000000, 100 );
moveTo( -500, 400
);
lineTo( 0 + x_move, 400 );
curveTo ( 125 + x_move, 370, 175 + x_move,
300 );
curveTo( 250 + x_move, 200, 400 + x_move, 200 );
curveTo( 300 +
x_move, 220, 300 + x_move, 300 );
curveTo( 300 + x_move, 400, 400 + x_move,
400 );
lineTo( 700, 400 );
}
}
else
{
x_move =
-500;
}
};
Last 3 lines are only 1 line :) Inspired by something the
old Bit101 did in Flash Math Creativity.//pom -- wave -- 25
lines
xcenter=Stage.width / 2;
ycenter=200;
centrey = 5 * Stage.height
/ 7;
_root.createEmptyMovieClip("rond",-1000)._visible=0;
rond.lineStyle(5,0,100);
rond.lineTo(.15,.45);
function
oscillate(){
this.y=centrey+20*(Math.sin((this.a += .1)+this.dist/6000));
this._y=ycenter+(this.y-ycenter)*this.scale; }
function
getDist(clip){
var centre=this["r"+centerClip];
var
dx=clip.x-centre.x;
var dz=clip.z-centre.z;
return dx*dx+dz*dz;}
for
(var i=-(nClip = 7);i <= nClip;i++){
for (var j=-nClip;j <=
nClip;j++){
mc=rond.duplicateMovieClip("r"+(++prof),prof,{x:300+20*i,y:ycenter,z:20*j,i
: i,j : j,onEnterFrame : oscillate});
if (!i&&!j)
centerClip=prof;
mc.scale=(fl = 250)/(fl+mc.z);
mc.offx=mc.x-xcenter;
mc.offy=mc.y-ycenter;
mc._x=xcenter+mc.offx*mc.scale;
mc._y=ycenter+mc.offy*mc.scale;
mc._xscale=mc._yscale=100*mc.scale; }}
for (var i=-nClip;i <= nClip;i++)
for (var j=-nClip;j <=
nClip;j++)
this["r"+(++ind)].dist=getDist(this["r"+(ind)]);Toddzilla >>
No you can't, it uses the drawing API (and that's the whole point :D ). What you
can do is duplicate a symbol that's already on your stage (basically, on big
black circle and small white circle). I'll try to give you an example
:)
CyanBlue
25-05-2003, 03:48 PM
Smily problem right on pom's code...
I mean the
longest line that starts
with
mc=rond.duplicateMovieClip(...
pom... You gotta disable the
smiley for that post and have Jesse work on fixing it right away...
:D
don't know which one is causing that though...
;) :)
:(
Thanks Cyan, it's fixed. That darn : o smiley :o
inudor
25-05-2003, 05:21 PM
my favourite one
CyanBlue
25-05-2003, 05:31 PM
Nice... Real nice... :)
Thanks :)// pom -- wave color -- 25
lines
center={x:200,y:150};
origin={x:Stage.width/2,y:50};
this.createEmptyMovieClip("rond",-1000);
function oscillate(){
this.y
= center.y + 20*(Math.sin((this.a += .1)+this.dist/6000));
this._y = center.y
+ (this.y - origin.y) * this.scale;}
function getDist(clip){
return
(dx=clip.x-this["r"+centerClip].x)*dx+(dz=clip.z-this["r"+centerClip].z)*dz;}
for
(var i=-(nClip = 5);i <= nClip;i++) for (var j=-nClip;j <= nClip;j++){
mc=rond.duplicateMovieClip("r"+(++prof),prof,{x:center.x+20*i,y:center.y,z:20*j,i:i,j:j,onEnterFrame:
oscillate});
if (!i&&!j) centerClip = prof;
mc.scale = (fl =
250)/(fl+mc.z);
mc._x=center.x + 20 * i * mc.scale;
mc._xscale=mc._yscale=100*mc.scale;}
for (var i=-nClip;i <= nClip;i++)
for (var j=-nClip;j <=
nClip;j++)
this["r"+(++ind)].dist=getDist(this["r"+(ind)]);
this.onEnterFrame=function(){
this.clear();
for (b = 1 ; b < 2 * nClip + 1 ; b++) for (c = 0 ; c
< 2 * nClip ; c++){
var
dif=(this["r"+(b+1+(2*nClip+1)*(c+1))].y-this["r"+(b+(2*nClip+1)*c)].y)/2;
this.beginFill(0<<16|0<<8|dif*5+150,100);
this.moveTo(this["r"+(b+(2*nClip+1)*c)]._x,this["r"+(b+(2*nClip+1)*c)]._y);
this.lineTo(this["r"+(b+1+(2*nClip+1)*c)]._x,this["r"+(b+1+(2*nClip+1)*c)]._y);
this.lineTo(this["r"+(b+1+(2*nClip+1)*(c+1))]._x,this["r"+(b+1+(2*nClip+1)*(c+1))]._y);
this.lineTo(this["r"+(b+(2*nClip+1)*(c+1))]._x,this["r"+(b+(2*nClip+1)*(c+1))]._y);
this.endFill();}}I've submitted something related a long time ago in the
Open Source section.
freddycodes
25-05-2003, 06:19 PM
How about this dynamic
clock
MovieClip.prototype.drawCircle = function(r, x, y)
{
this.moveTo(x+r, y);
for (var angle = 45; angle<=360; angle +=
45)
this.curveTo(((r*Math.cos(angle*Math.PI/180)) + r*(Math.tan(22.5 *
Math.PI/180))*Math.cos((angle-90)*Math.PI/180))+x,
((r*Math.sin(angle*Math.PI/180)) + r*(Math.tan(22.5 *
Math.PI/180))*Math.sin((angle-90)*Math.PI/180))+y,
(r*Math.cos(angle*Math.PI/180))+x,
(r*Math.sin(angle*Math.PI/180))+y);
}
MovieClip.prototype.drawLine =
function(x, y, w, c) {
this.lineStyle(w,c,100);
this.lineTo(x,y);
}
parts = ["myClock","minHand", "secHand",
"hourHand"];
for(var i=0;i<parts.length;i++)
{
_root.createEmptyMovieClip(parts[i], i)
_root[parts[i]]._x =
_root[parts[i]]._y = (parts[i] != "myClock") ? 100 : 0;
}
minHand.drawLine(0,-70,2,0x000000);
hourHand.drawLine(0,-40,3,0x000000);
secHand.drawLine(0,-70,1,0x0000FF);
myClock.lineStyle(1,0xcccccc,100);
myClock.drawCircle(80,
100, 100);
function changeTime() {
var myDate = new
Date();
hourHand._rotation = myDate.getHours()*30;
minHand._rotation =
myDate.getMinutes()*6;
secHand._rotation =
myDate.getSeconds()*6;
}
setInterval(changeTime, 1);
drawCircle
function inspired by actionscript-toolbox, shortened by me.
ToddziLLa
25-05-2003, 11:20 PM
nice freddycodes :)
i wish i could do freelance stuff
off the top of my head like you guys...im jealous:D
ToddziLLa
25-05-2003, 11:21 PM
pom...your last code is sick bro
farafiro
26-05-2003, 02:04 AM
freddycodes
I thought this one is only for
water
magicwand
26-05-2003, 11:51 AM
my first entry.
dont laugh :)
a = b=c=1;
color1 =
0xFFFFFF;
color2 = 0x0000FF;
alpha1 = alpha2=50;
ratio1 = 20;
ratio2
= 255;
createEmptyMovieClip("drop", 1);
function loop() {
with
(_root.drop) {
_root.drop.clear();
colors = [_root.color1,
_root.color2];
alphas = [_root.alpha1, _root.alpha2];
ratios =
[_root.ratio1, _root.ratio2];
matrix = {matrixType:"box", x:-50, y:20, w:100,
h:120+c, r:0};
beginGradientFill("radial", colors, alphas, ratios,
matrix);
lineStyle(1, 0x000000, 0);
moveTo(0, 0);
curveTo(+a, c+20, 0,
c+20);
curveTo(-b, c+20, 0, 0);
endFill();
a = b=c += 1;
if
(a>80) {
clear();
a = b=c=1;
}
}
}
setInterval(loop,
100);
freddycodes
26-05-2003, 01:32 PM
Originally posted by farafiro
freddycodes
I thought
this one is only for water
Yeah okay so I didn't read the full thread.
Well the second hand is blue, do that count?
farafiro
27-05-2003, 01:59 AM
heheheeeee
it counts, but I just was hoping doing it in a
seperate thread for all of us to join ;)
Originally posted by freddycodes
Yeah okay so I didn't
read the full thread. Well the second hand is blue, do that count? :D :D :D
But seriously, that could be a cool challenge too if you want to start it
(or Fara...)
CyanBlue
27-05-2003, 06:55 AM
Just having some fun with magicwand's code before I go get
some sleep... :D
FPS is set to 30 and I like it that way... ;)
a = b = c =
1;
color1 = 0xFFFFFF;
color2 = 0x0000FF;
alpha1 = alpha2 =
50;
ratio1 = 20;
ratio2 = 255;
createEmptyMovieClip("drop",
1);
function loop()
{
with
(_root.drop)
{
_root.drop.clear();
colors = [_root.color1,
_root.color2];
alphas = [_root.alpha1, _root.alpha2];
ratios =
[_root.ratio1, _root.ratio2];
matrix = {matrixType:"box", x:-50, y:20, w:100,
h:120 + c, r:0};
beginGradientFill("radial", colors, alphas, ratios,
matrix);
lineStyle(1, 0x000000, 0);
moveTo(0, 0);
curveTo(+a, c + 20,
0, c + 20);
curveTo(-b, c + 20, 0, 0);
endFill();
a = b = c += 1;
if
(a > 47)
{
_y = 0;
clear();
clearInterval(dropit);
start =
setInterval(dropdrop, 500);
a = b = c =
1;
}
_y++;
}
}
function
dropdrop()
{
clearInterval(start);
dropit = setInterval(loop,
10);
}
dropdrop();
Jesse
27-05-2003, 08:10 AM
Hats off to Pom for a series of brilliant entries and to all
other contributors. I've gotta get in on this one but not tonight. Tired. So
very tired.
xxlm
27-05-2003, 04:54 PM
Hey pom... I really like the one you made with blue
fill.
Can you edit your post and comment a bit what you've done.
I'm
not so good with maths so... :rolleyes:
Thx
:)
tost
27-05-2003, 06:24 PM
here i go :)
// tost // water on a
window
_x=200;
_y=-50;
// make
object
this.createEmptyMovieClip("drip0",childCount);
drip0.lineStyle(15,0xDDDDFF,100);
drip0.lineTo(.30,.60);
//
make duplicates
this.onEnterFrame = function() {
childCount++;
if
(childCount < 40) {
duplicateMovieClip("drip0", "drip"+childCount,
childCount);
this["drip"+childCount]._x =
this["drip"+(childCount-1)]._x+((Math.random()*6)-3);
this["drip"+childCount]._y
= (this["drip"+(childCount-1)]._y+20);
// grow
function
this["drip"+childCount].onEnterFrame = function()
{
this.growCount++;
this._xscale +=
(Math.random()*10)+(20-this._parent.childCount);
this._yscale =
this._xscale*2;
if (this.growCount > 15) {
this.onEnterFrame =
undefined;
}
}
}
};
tost
27-05-2003, 06:36 PM
variation_
// tost // water on a window
II
_x=200;
_y=-50;
// make
object
this.createEmptyMovieClip("drip0",childCount);
drip0.lineStyle(6,0xDDDDFF,100);
drip0.lineTo(.30,.60);
//
make duplicates
this.onEnterFrame = function() {
childCount++;
if
(childCount < 30) {
duplicateMovieClip("drip0", "drip"+childCount,
childCount);
this["drip"+childCount]._x =
this["drip"+(childCount-1)]._x+((Math.random()*6)-3);
this["drip"+childCount]._y
= (this["drip"+(childCount-1)]._y+20);
//grow
function
this["drip"+childCount].onEnterFrame = function()
{
this.growCount++;
this._xscale +=
(Math.random()*10)+(20-this._parent.childCount);
this._yscale =
this._xscale*2.5;
if (this.growCount > 20) {
this.onEnterFrame =
undefined;
}
}
}
};
Esquared
27-05-2003, 06:40 PM
WHEW! Definitely took a bit of work, but this code is pretty
sweet. :D
Click to create ripples, and don't hesititate to click in multiple
locations... ;)
onMouseDown = function(){
for(i = 1; i <= k;
i++){
with(_root["Drop"+i]){
distance = Math.abs(((_x - _root._xmouse)*(_x
- _root._xmouse)
+(_y - _root._ymouse)*(_y - _root._ymouse)))/10;
time =
new Date();
ripples.push(time.getTime() + distance);}}}
for(i = 0; i <
Stage.height; i+=20){
for(j = 0; j < Stage.width; j+=20){
Drop =
this.createEmptyMovieClip("Drop"+(++k),
k);
Drop.lineStyle(20,0x002255,100);
Drop.lineTo(.1, .2);
Drop._x =
j;
Drop._y = i;
Drop.ripples = new Array();
Drop.onEnterFrame =
function(){
time = new Date();
trace(time.getTime()+" >
"+this.ripples[0])
if(this.ripples.length > 0 && (new
Date()).getTime() >
this.ripples[0]){
this.ripples.shift();
this._xscale -=
30;
this._yscale -= 30;}
this.Az = (100 - this._xscale)*.3
this.Vz =
(this.Vz + this.Az)*.9
this._xscale += this.Vz
this._yscale +=
this.Vz}}}
EXACTLY 25 lines too...*sigh of relief. Hope you like
it!
(btw: the field is created dynamically to fill the stage, so you may
need to create a smaller stage than the default...for your processors
sake.)
Esquared
27-05-2003, 06:55 PM
For anyone who's actually taking the time to read through my
code, or wishes to alter it in any way:
There is a small inconsistency in
the program that I purposefully ignored to save space. That is the following: on
each click, a time is essentially pushed into a makeshift queue for each drop in
the array based on their distance from that click. My code ONLY tests for an
event at the FIRST element in the queue, but should really test for EVERY
element.
The only time this is noticable is, for instance, if you click
at opposite corners in quick succession. The drops opposite the first corner
will be "stuck" in place, waiting for the time specified by that first click to
become active, following which the other click will also take effect.
If
anyone needs more help/comments, let me know. I certainly crowded stuff in there
in horrible coding style....
JGizmo
27-05-2003, 10:21 PM
Here is mind - waterfall:
Best view with bg=black and
can of beer :D
rodir = 2;
createline = function () {
i++;
r =
Math.floor(i*Math.PI)/180;
_root.createEmptyMovieClip("line"+i,
i);
_root["line"+i].lineStyle(2, 200 << 16 ^ 200 << 8 ^ 255,
100);
_root["line"+i].lineTo(0, 5+random(100));
_root["line"+i]._x =
_root["line"+i].x=200+random(8);
_root["line"+i]._y = 10;
rodir =
_root["line"+i].rospeed=rodir*-1;
_root["line"+i].fade =
1;
_root["line"+i].speed = 10;
_root["line"+i].onEnterFrame = function()
{
this._alpha -= this.fade;
this._y += this.speed;
if (this._y>350)
{
this.lineStyle(1, 50 << 16 ^ 50 << 8 ^ 255,
100);
this.lineTo(0, 50);
this._rotation += this.rospeed;
this.speed =
0.5;
if (this._alpha<5)
{
this.removeMovieClip();
}
}
};
};
setInterval(createline,
10);
Enjoy :D :D
JGizmo
27-05-2003, 10:29 PM
hi Esquared, I tried your code and it crash my comp :( what
happened?
Esquared
27-05-2003, 10:46 PM
Hmm....did you read the warning about the stage size? Try
decreasing it to 200 x 200 pixels or something instead. My computer can handle
it at around 300x300 and stil be ok, but larger than that the framerate suffers.
(I'm on a iMac G4, 833 MHz, 512 RAM) If that doesn't work, I don't know what to
say. :(
JGizmo
27-05-2003, 11:20 PM
Oops I got you, Esquared :rolleyes: should have read before
hand. I will give it a try again.
Here's a little mod, now I got a river
:p
rodir = 2;
createline = function () {
i++;
r =
Math.floor(this.i*Math.PI)/180;
_root.createEmptyMovieClip("line"+i,
i);
_root["line"+i].lineStyle(2, 120 << 16 ^ 120 << 8 ^
200+random(55), 100);
_root["line"+i].lineTo(0,
1+random(20));
_root["line"+i]._x =
_root["line"+i].x=10+random(8);
_root["line"+i]._y = 10;
rodir =
_root["line"+i].rospeed=rodir*-1;
_root["line"+i].fade =
0.5;
_root["line"+i].speed = 10;
_root["line"+i].onEnterFrame = function()
{
this._alpha -= this.fade;
this._y += this.speed;
if (this._y>300)
{
this.lineStyle(1, 200 << 16 ^ 100+random(155) << 8 ^ 255,
100);
this.lineTo(0, 80);
this._x +=6;
this._rotation +=
this.rospeed;
this.speed=1;
if (this._alpha<5)
{
this.removeMovieClip();
}
}
};
};
setInterval(createline,
10);
inudor
28-05-2003, 04:26 AM
Never thought so many different interpretations of water
where possible with just 25 lines.
A good creativity work form all I
think!
Great ones everyone ! :D
xxlm >> I can try :)//
pom -- wave color -- 25 lines
center={x:200,y:150}; // center of the wave
line1
origin={x:Stage.width/2,y:50}; // horizon point
line2
this.createEmptyMovieClip("rond",-1000); //line 3
function
oscillate(){ // line 4
// oscillation of the absolute position (y) around the
center position
this.y = center.y + 20*(Math.sin((this.a +=
.1)+this.dist/6000)); // line 5
// positions the clip on the scene according
to the absolute position
this._y = center.y + (this.y - origin.y) *
this.scale;} // line 6
// function that returns the distance between the
current clip and "clip"
function getDist(clip){ // line 7
return
(dx=clip.x-this["r"+centerClip].x)*dx+(dz=clip.z-this["r"+centerClip].z)*dz;} //
line 8
for (var i=-(nClip = 5);i <= nClip;i++) for (var j=-nClip;j <=
nClip;j++){ // line 9
// duplicates teh clip at the right absolute position
and with a few variables
defined
mc=rond.duplicateMovieClip("r"+(++prof),prof,{x:center.x+20*i,y:center.y,z:20*j,i:i,j:j,onEnterFrame:
oscillate}); // line 10
//centerClip references the clip at the center of the
wave
if (!i&&!j) centerClip = prof; // line 11
mc.scale = (fl =
250)/(fl+mc.z); // depends on the depth 12
mc._x=center.x + 20 * i *
mc.scale; // _x position doesn't change
13
mc._xscale=mc._yscale=100*mc.scale;} // depends on scale 14
for (var
i=-nClip;i <= nClip;i++) for (var j=-nClip;j <= nClip;j++) // line
15
this["r"+(++ind)].dist=getDist(this["r"+(ind)]); // line
16
this.onEnterFrame=function(){ // line 17
this.clear(); // line 18
//
some nice colors. I draw squares with different shades of blue dependent on the
y position of the clips
for (b = 1 ; b < 2 * nClip + 1 ; b++) for (c = 0 ;
c < 2 * nClip ; c++){ // line 19
var
dif=(this["r"+(b+1+(2*nClip+1)*(c+1))].y-this["r"+(b+(2*nClip+1)*c)].y)/2; //
line 20
this.beginFill(0<<16|0<<8|dif*5+150,100); // line
21
this.moveTo(this["r"+(b+(2*nClip+1)*c)]._x,this["r"+(b+(2*nClip+1)*c)]._y);
// line
22
this.lineTo(this["r"+(b+1+(2*nClip+1)*c)]._x,this["r"+(b+1+(2*nClip+1)*c)]._y);
// line
23
this.lineTo(this["r"+(b+1+(2*nClip+1)*(c+1))]._x,this["r"+(b+1+(2*nClip+1)*(c+1))]._y);
// line
24
this.lineTo(this["r"+(b+(2*nClip+1)*(c+1))]._x,this["r"+(b+(2*nClip+1)*(c+1))]._y);
// line 25
this.endFill();}} // line 26Oh my god!! I can't count!
:D
All right:// pom -- wave color -- 25
lines
center={x:200,y:150};
origin={x:Stage.width/2,y:50};
this.createEmptyMovieClip("rond",-1000);
function
oscillate(){
this.y = center.y + 20*(Math.sin((this.a +=
.1)+this.dist/6000));
this._y = center.y + (this.y - origin.y) *
this.scale;}
function getDist(clip){
return
(dx=clip.x-this["r"+centerClip].x)*dx+(dz=clip.z-this["r"+centerClip].z)*dz;}
for
(var i=-(nClip = 5);i <= nClip;i++) for (var j=-nClip;j <=
nClip;j++){
mc=rond.duplicateMovieClip("r"+(++prof),prof,{x:center.x+20*i,y:center.y,z:20*j,i:i,j:j,onEnterFrame:
oscillate});
if (!i&&!j) centerClip = prof;
mc.scale = (fl =
250)/(fl+mc.z);
mc._x=center.x + 20 * i *
mc.scale;
mc._xscale=mc._yscale=100*mc.scale;}
for (var i=-nClip;i <=
nClip;i++) for (var j=-nClip;j <=
nClip;j++)
this["r"+(++ind)].dist=getDist(this["r"+(ind)]);
this.onEnterFrame=function(){
this.clear();
for
(b = 1 ; b < 2 * nClip + 1 ; b++) for (c = 0 ; c < 2 * nClip ;
c++){
this.beginFill(0<<16|0<<8|(this["r"+(b+1+(2*nClip+1)*(c+1))].y-this["r"+(b+(2*nClip+1)*c)].y)*4+150,100);
this.moveTo(this["r"+(b+(2*nClip+1)*c)]._x,this["r"+(b+(2*nClip+1)*c)]._y);
this.lineTo(this["r"+(b+1+(2*nClip+1)*c)]._x,this["r"+(b+1+(2*nClip+1)*c)]._y);
this.lineTo(this["r"+(b+1+(2*nClip+1)*(c+1))]._x,this["r"+(b+1+(2*nClip+1)*(c+1))]._y);
this.lineTo(this["r"+(b+(2*nClip+1)*(c+1))]._x,this["r"+(b+(2*nClip+1)*(c+1))]._y);
this.endFill();}}It's
getting less and less readable :(
magicwand
28-05-2003, 10:30 PM
Pom
Your code is sick YES.
one question...
isnt
that 26 line?
:confused: (still not sure what constitute line)
Esquared
29-05-2003, 01:13 AM
Hey guys-
As some were having trouble with my code
previously, and I generally wasn't quite satisfied anyway, I've revamped my
earlier submission. Even if the other one worked for you, you should check this
out...many many times better:
1. Dynamically centers but remains a
predetermined size
2. MUCH faster...previous code was horrible
3. Fixed
the "one click at a time" glitch...now each click is registered
immediately
4. Included comments
5. Also made the code dynamic, so you can
play with some settings...
//RIPPLES: EBEN ELIASON, MAY, 2003
(KINETIC-THOUGHT)
//
//The following additional lines of code are given
for dynamic experimentation.
//As such, all values were initially hard coded
and therefore these lines
//do not count toward the 25 line limit, which my
code excalty hits. =)
size = 210 //the size of the "pool" (multiples of
15)
amplitude = 40 //initial wavefront amplitude (0-100)
viscocity = .1
//determines how "thick" the fluid is (0-1)
elasticity = .5 //essentially
determines freq of ripples (0-2)
//
//sets a time for each drop
indicating when the wavefront from click will reach it
onMouseDown =
function(){
for(i = 1; i <= k; i++){
with(_root["Drop"+i]){
distance
= Math.abs(((_x - _root._xmouse)*(_x - _root._xmouse)
+(_y -
_root._ymouse)*(_y - _root._ymouse)))/10;
time = new
Date();
ripples.push(time.getTime() + distance);}}}
//initializes and
centers a field of drops on the stage
for(y = Stage.height/2-size/2, i = 0; i
< size; i+=15){
for(x = Stage.width/2-size/2, j = 0; j < size;
j+=15){
Drop = this.createEmptyMovieClip("Drop"+(++k),
k);
Drop.lineStyle(10,0x002255,100);
Drop.lineTo(.1,.2);
Drop._x =
x+j;
Drop._y = y+i;
Drop.ripples = new Array();
//function for each
drop on each frame
Drop.onEnterFrame = function(){
time = new
Date();
//check EVERY wavefront time
for(i = 0; i <
this.ripples.length; i++){
//if ANY wavefront reaches it, increase its
amplitude
if(time.getTime() > this.ripples[i]){
this.ripples.splice(i,
1);
this._xscale -= amplitude;
this._yscale -=
amplitude;}}
//oscillation physics
this.Az = (100 -
this._xscale)*(elasticity)
this.Vz = (this.Vz +
this.Az)*(1-viscocity)
this._xscale += this.Vz
this._yscale +=
this.Vz}}}
GIVE ME SOME FEEDBACK! :D I love what everyone else is
doing...some excellent stuff is in this thread!
Jesse
29-05-2003, 06:05 AM
The improved version is fantastic. I had serious problems
running the other version but this new one is great :)
JGizmo
29-05-2003, 06:18 AM
Hi Esquared, second version, that is well cool. Good work.
:D
John
McGiver
29-05-2003, 08:05 AM
nice ones Esquared and pom
--> @ Pom: too stupid, that
it is 26 lines :D :D :D
Oh my God you are right... I changed the code a
bit.
Tost >> I like yours very much, I hope you don't mind (set a
high frame rate):// tost // water on a window edited by pom
drawDrop =
function (targ){
var a =
targ.createEmptyMovieClip("drip0",0);
a.lineStyle(15,0xDDDDFF,100);
a.lineTo(.15,.45);
}
function
createWater(){
count ++ ;
var water =
_root.createEmptyMovieClip("wat"+count,count);
water._x = random
(Stage.width);
water._y = random (100) - 75
;
drawDrop(water);
water.onEnterFrame = function(){
if (this.child++
< 40){
var clip = water.drip0.duplicateMovieClip("drip"+this.child,
this.child);
clip._x = this["drip"+(this.child-1)]._x+random(6)-3;
clip._y
= this["drip"+(this.child-1)]._y+20;
clip.onEnterFrame = function()
{
this._xscale += (Math.random()*10)+(20 - 4/3 *
this._parent.child);
this._yscale = this._xscale*2;
if (this.growCount++
> 10) delete
this.onEnterFrame;
}
}
}
};
setInterval(createWater,3000);pom
:)
Esquared >> The second version is the ****, man :eek:
I'm really impressed, because I tried something like that but miserably failed
:( Great one (I hope you won't mind if I modify it a bit ;) )
Esquared
29-05-2003, 11:03 AM
pom-
Yeah, I'm pretty pleased with this version. I
had the idea for it a little while back, but this challenge definitely inspired
its transition from thought to code. I've actually been working with these
interactive arrays of objects for a little while now, in combination with some
art installations I've been making.
Anyway, modify to your hearts
content. :) It would be REAL sweet if we could figure how to combine my code and
your awesome "drawing" skills like in your wave...
Lemme see whatever you
come up with!
First try: 24 lines :)//RIPPLES: EBEN ELIASON, MAY, 2003
(KINETIC-THOUGHT)
//Edited by pom
//
//The following additional lines
of code are given for dynamic experimentation.
//As such, all values were
initially hard coded and therefore these lines
//do not count toward the 25
line limit, which my code excalty hits. =)
size = 210 //the size of the
"pool" (multiples of 15)
amplitude = 40 //initial wavefront amplitude
(0-100)
viscocity = .1 //determines how "thick" the fluid is
(0-1)
elasticity = .5 //essentially determines freq of ripples
(0-2)
//sets a time for each drop indicating when the wavefront from
click will reach it
onMouseDown = function(){
for(i = 1; i <= k; i++)
with(_root["Drop"+i]){
distance = ((dx = _x - _root._xmouse)*dx + (dy = _y -
_root._ymouse)*dy)/10;
ripples.push(getTimer() + distance);}}
for(i = 0; i
< size; i+=15) for(j = 0; j < size; j+=15){
Drop =
this.createEmptyMovieClip("Drop"+(++k),
k);
Drop.lineStyle(30,0x002255,100);
Drop.lineTo(.15,.45);
Drop._x =
Stage.width/2-size/2 + j;
Drop._y = Stage.height/2-size/2 +
i;
Drop.ripples = new Array();
Drop.col = new Color
(Drop);
Drop.onEnterFrame = function(){
for(i = 0; i <
this.ripples.length; i++){
if(getTimer() >
this.ripples[i]){
this.ripples.splice(i, 1);
this._xscale -=
amplitude;
this._yscale -= amplitude;}}
this.Az = (100 -
this._xscale)*(elasticity)
this.Vz = (this.Vz +
this.Az)*(1-viscocity)
this._xscale = this._yscale += this.Vz
dif = 100 -
this._xscale
var difO =
{aa:50,rb:0,gb:0,bb:this.vc=100+1.5*dif};
this.col.setTransform(difO);}}You
can remove the last 3 lines if it lags too much (careful, keep the last 2 '}' )
but then there's not much difference... (you should change the alpha of the
lineStyle to 50).
pom :cool:
Esquared
29-05-2003, 04:13 PM
I really like what you did with it. The alpha effect is
definitely key...it almost appears to shimmer. Anyway, I'm updating again. I
didn't add anything new to the code really, although I did manage to compress it
into 18 lines...plenty more space to work with now. Also, I played around with
the colors and size little bit, and added a slight light source...the pool has a
subtly "deeper" end...
//RIPPLES: EBEN ELIASON, MAY 28, 2003
(KINETIC-THOUGHT)
//Edited by pom, May 29
//Edited by esquared, May
29
//
//The following additional lines of code are given for dynamic
experimentation.
//As such, all values were initially hard coded and
therefore these lines
//do not count toward the 25 line limit.
size = 210
//the size of the "pool" (multiples of 15)
amplitude = 50 //initial wavefront
amplitude (0-100)
viscocity = .1 //determines how "thick" the fluid is
(0-1)
elasticity = .9 //essentially determines freq of ripples
(0-2)
//
//
onMouseDown = function(){
for(i = 1; i <= k; i++)
with(_root["Drop"+i]){
ripples.push(getTimer() + (((dx = _x -
_root._xmouse)*dx + (dy = _y - _root._ymouse)*dy)/10));}}
for(i = 0; i <
size; i+=15) for(j = 0; j < size; j+=15){
Drop =
this.createEmptyMovieClip("Drop"+(++k),
k)
Drop.lineStyle(20,0x000000,100);
Drop.lineTo(.15,.45);
Drop._x =
Stage.width/2-size/2 + j;
Drop._y = Stage.height/2-size/2 +
i;
Drop.ripples = new Array();
Drop.col = new Color
(Drop);
Drop.onEnterFrame = function(){
for(i = 0; i <
this.ripples.length; i++){
if(getTimer() >
this.ripples[i]){
this.ripples.splice(i, 1);
this._yscale = this._xscale
-= amplitude;}}
this._xscale = this._yscale += this.Vz = (this.Vz + (100 -
this._xscale)*(elasticity))*(1-viscocity);
this.col.setTransform({aa:this._y/6,rb:00,gb:22-(100-this._xscale)/4,bb:99-(100-this._xscale)/2});}}
Keep
up the good work!
Jesse
29-05-2003, 05:45 PM
Wohoo. I had hoped that the challenges would encourage this
sort of interaction . Development and improvement. The lastest two vesrions are
fantastic.
Esquared
30-05-2003, 03:01 AM
I decided to take a shot at making the best of the extra
lines I freed up in my last post. I attempted to do the next most logical thing,
and that is to add a splash. I came up with the "pretty kind" that you see in
slow motion shots of water dripping...the little column rising up in the center
to form a little sphere...no cannonball stuff or anything. Anyway, I'm curious
to know if you guys think it "flows" with the image....(pardon the
pun)...
//RIPPLES: EBEN ELIASON, MAY 28, 2003
(KINETIC-THOUGHT)
//Edited by pom, May 29
//Edited by esquared, May
29
//Edited by esquared, May 30
//
//The following additional lines of
code are given for dynamic experimentation.
//As such, all values were
initially hard coded and therefore these lines
//do not count toward the 25
line limit.
size = 210 //the size of the "pool" (multiples of
15)
amplitude = 50 //initial wavefront amplitude (0-100)
viscocity = .15
//determines how "thick" the fluid is (0-1)
elasticity = 1 //essentially
determines freq of ripples (0-2)
//
//
onMouseDown =
function(){
(Splash = drawDrop(this.createEmptyMovieClip("Splash"+(s++),
1000+s), _root._xmouse, _root._ymouse, 15, 0x001166)).onEnterFrame =
function(){
if(this.falling != NULL || (this._yscale = this._xscale +=
(20/viscocity - this._xscale)*.4) > 20/viscocity - 5){
if(this.falling =
true && (this._yscale = this._xscale -= 2/viscocity) <
0){
this.removeMovieClip();}}}
Splash._alpha = 40;
Splash._xscale =
Splash._yscale = 1;
for(i = 1; i <= k; i++)
with(_root["Drop"+i]){
ripples.push(getTimer() + (((dx = _x -
_root._xmouse)*dx + (dy = _y - _root._ymouse)*dy)/10));}}
drawDrop =
function(Drop, x, y, radius,
col){
Drop.lineStyle(radius*2,col,100);
Drop.lineTo(.15,.45);
Drop._x =
x;
Drop._y = y;
Drop.col = new Color (Drop);
return Drop;}
for(i =
0; i < size; i+=15) for(j = 0; j < size; j+=15){
(Drop =
drawDrop(this.createEmptyMovieClip("Drop"+(++k), k), Stage.width/2 - size/2 + j,
Stage.height/2 - size/2 + i, 10, 0)).onEnterFrame = function(){
for(i = 0; i
< this.ripples.length; i++){
if(getTimer() >
this.ripples[i]){
this.ripples.splice(i, 1);
this._yscale = this._xscale
-= amplitude;}}
this._xscale = this._yscale += this.Vz = (this.Vz + (100 -
this._xscale)*(elasticity))*(1-viscocity);
this.col.setTransform({aa:this._y/6,rb:00,gb:22-(100-this._xscale)/4,bb:99-(100-this._xscale)/2});}
Drop.ripples
= new Array();}
The ever present technical note: I had to do some MORE
compression to fit this in there. The first thing to note is how the drawDrop()
method returns the mc, so that a single call to that function can draw the drop,
store a reference to it, AND declare a function FOR it all on the same line.
Also...check out the nested if statements under Splash. There's a fairly complex
little bit of logic going on there that allows all scaling of the splash, both
rising AND falling, to occur within the conditionals themselves, ultimately
resulting in a single line of code for its own removal.
JGizmo
30-05-2003, 09:07 AM
Esquared = beautiful code and outcome ;)
John
I don't have Flash here so I can't test that code, but
according the rules of the old Bit-101, you are doing things you're not allowed
to do (I don't know what are the rules here).
That long if statement for
instance:if(this.falling != NULL || (this._yscale = this._xscale +=
(20/viscocity ...So I say: **** the 25 lines, let's make this evolve peacefully
and let's keep the code clean and as simple as possible :)
Esquared
30-05-2003, 10:02 AM
Fair enough...I do believe we've about hit the limit for
code compression anyway. But out of curiosity, what part of the if() is invalid?
Are assignments not allowed within conditionals, or would it be legal if each of
the single if()s simply occupied its own line? If you do that, I DO hit 25
exactly, for the record. :) (I edited my post to reflect that
change)
I've never seen a Bit-101 contest before, so I've honestly never
read ANY coding "rules." I'm curious to know just what is considered legal. For
instance...I don't really see the difference between my compound if() and your
compound for() loops (which is clever, by the way), so clue me in and I'll play
fair in future challenges!
Well I'm not so sure because that code is really hard to
decypher :) There's probably something I don't understand... Like this "falling"
variable, I don't understand how it works.
Anyway, I thought you were
using if statements to stuff calculations inside so that it would only take one
line. Like this thing that DeliMIter did in the Bit contest to draw a square
(perfectly valid, of course but oh so hard to read...):beginFill(0x000066, 100);
for (var i = 0; i<5; i++) this[i == 0 ? "moveTo" : "lineTo"](i%4<2 ?
-Stage.width/2 : _x=Stage.width/2, i%4%3 == 0 ? -Stage.height/2 :
_y=Stage.height/2);
Esquared
30-05-2003, 11:35 AM
Thaat makes sense...and yes, it IS a little harder to read.
However, since I find it so clever myself, I'll take the time to briefly explain
those 3 lines.
1. The point of the code is to take this Splash mc, scale
it up for a brief amount of time, after which it then scales down to zero, at
which point it is removed.
2. Generally, think about what you'd need to
do this...you'd need something like:
some boolean = true //indicate this
mc should be growing
if(boolean && scale is still smaller than
max){
scale up;}
else{
boolean = false; //indicate this mc has already
reached max and should now be shrinking
scale down;}
if(scale is
zero){
remove the movie clip;}
3. Here's how my code
works...
if(this.falling != NULL || (this._yscale = this._xscale +=
(20/viscocity - this._xscale)*.4) > 20/viscocity - 5){
//the first part of
the conditional tests is a falling variable is NULL
//we check for NULL so we
don't waste a line initializing some boolean
//if falling is nall, we assume
rising, or getting bigger
//then we have an OR statement
//the next
conditional does an assignment to scale the mc up
//it actually tests to see
if the resulting scale is greater than our max
//this takes care of the
scaling code AND the "reach max" conditional together
//so we have: if(this
thing is already falling OR should start faling now)
then...
//
if(this.falling = true && (this._yscale = this._xscale
-= 2/viscocity) < 0){
//the first part of this conditional literally IS
just an assignment
//fortunately for us, we are assigning true, and so the
conditional will always return true
//once falling is set to true, it is no
longer NULL
//note that this means the first if statement is "short-cicuited"
once the second is reached
//this means that the second conditional in the
first if which scales up is never done again
//then we have and AND
//the
second conditional in the second if performs similarly to the second in the
first
//it simply scales down while also checking if the resulting scale is
less than zero
//so we have: if(this thing is now falling, which it is AND it
has stopped falling) then...
//
this.removeMovieClip();}}}
//yee
ha...we're done and the thing is removed properly
Hope you could follow
that...it's logical once you comprehend what's going on...to answer your
question, the falling variable is just a boolean that determines which if()
should be looked at, scaling up or scaling down, which just happens to be
entirely declared and set within the if()s themselves...
Let me know if
you still have questions!
Esquared
30-05-2003, 11:42 AM
Thaat makes sense...and yes, it IS a little harder to read.
However, since I find it so clever myself, I'll take the time to briefly explain
those 3 lines.
1. The point of the code is to take this Splash mc, scale
it up for a brief amount of time, after which it then scales down to zero, at
which point it is removed.
2. Generally, think about what you'd need to
do this...you'd need something like:
some boolean = true //indicate this
mc should be growing
if(boolean && scale is still smaller than
max){
scale up;}
else{
boolean = false; //indicate this mc has already
reached max and should now be shrinking
scale down;}
if(scale is
zero){
remove the movie clip;}
3. Here's how my code
works...
if(this.falling != NULL || (this._yscale = this._xscale +=
(20/viscocity - this._xscale)*.4) > 20/viscocity - 5){
//the first part of
the conditional tests is a falling variable is NULL
//we check for NULL so we
don't waste a line initializing some boolean
//if falling is nall, we assume
rising, or getting bigger
//then we have an OR statement
//the next
conditional does an assignment to scale the mc up
//it actually tests to see
if the resulting scale is greater than our max
//this takes care of the
scaling code AND the "reach max" conditional together
//so we have: if(this
thing is already falling OR should start faling now)
then...
//
if(this.falling = true && (this._yscale = this._xscale
-= 2/viscocity) < 0){
//the first part of this conditional literally IS
just an assignment
//fortunately for us, we are assigning true, and so the
conditional will always return true
//once falling is set to true, it is no
longer NULL
//note that this means the first if statement is "short-cicuited"
once the second is reached
//this means that the second conditional in the
first if which scales up is never done again
//then we have and AND
//the
second conditional in the second if performs similarly to the second in the
first
//it simply scales down while also checking if the resulting scale is
less than zero
//so we have: if(this thing is now falling, which it is AND it
has stopped falling) then...
//
this.removeMovieClip();}}}
//yee
ha...we're done and the thing is removed properly
Hope you could follow
that...it's logical once you comprehend what's going on...to answer your
question, the falling variable is just a boolean that determines which if()
should be looked at, scaling up or scaling down, which just happens to be
entirely declared and set within the if()s themselves...
Let me know if
you still have questions!
tost
30-05-2003, 11:51 AM
Tost >> I like yours very much, I hope you don't mind
(set a high frame rate):
not at all! :)
i had multiple of 'em
first, but in too many lines :D
great submissions and tweaks ya'all! i
like the vibe in this thread!
grtz
tost
littleRichard
30-05-2003, 01:38 PM
here's a go at some rain clouds. if you toy around with the
settings it's pretty easy to change the effects up.
function
drawCurves(t, f, v)
{
t.beginFill(f[0], f[1]);
for(var c = 0; c <
v.length; c++) t.curveTo(v[c][0], v[c][1], v[c][2],
v[c][3]);
t.endFill();
}
function
createRain()
{
this.createEmptyMovieClip("rain" + (++this.HL),
this.HL).onEnterFrame = function()
{
this._y < 300 ? this._y += 20 :
this.removeMovieClip();
};
this._parent.createDrops(this["rain" +
this.HL]);
}
function createDrops(t)
{
var x, y;
for(var c =
0; c < 100; c++)
{
t.lineStyle(2, 0x99CCFF, Math.random() * 100 -
10);
x = Math.random() * 300;
y = Math.random() * 20;
t.moveTo(x,
y);
t.lineTo(x, y + 5);
}
}
this.drawCurves(this, [0x99CCFF,
20], [[300, 0, 300, 0], [300, 325, 300, 325], [0, 325, 0, 325], [0, 0, 0,
0]]);
this.createEmptyMovieClip("rain",
++this.HL);
this.createEmptyMovieClip("clouds",
++this.HL);
this.drawCurves(this.clouds, [0xFFFFFF, 100], [[0, 0, 0, 0], [0,
40, 0, 40], [20, 70, 50, 30], [65, 50, 80, 30], [110, 80, 130, 30], [190, 100,
200, 30], [220, 50, 230, 30], [250, 80, 300, 50], [300, 0, 300,
0]]);
this.rain.onEnterFrame = createRain;
Esquared >> thanks for the info :) And the outcome is
tight!
littleRichard >> Nice one. You just gave me an idea...
:D
Jesse
30-05-2003, 08:48 PM
THis thread deserves some publicity. I'll link it in the
next mailout (which I guess should go out really soon. We've been SOO
busy)
littleRichard
31-05-2003, 03:51 AM
here's version 2. it's basically the same thing but looks
much nicer.
function drawCurves(t, f, v)
{
t.beginFill(f[0],
f[1]);
for (var c = 0; c < v.length; c++)
{
t.curveTo(v[c][0],
v[c][1], v[c][2], v[c][3]);
}
t.endFill();
}
function
createRain()
{
this.createEmptyMovieClip("rain" + (++this.HL),
this.HL).onEnterFrame = function()
{
(this._y += 20) < 400 ? this._x +=
Math.random() * 4 - 2 :
this.removeMovieClip();
};
this._parent.createDrops(this["rain" +
this.HL]);
}
function createDrops(t)
{
for (var c = 0; c < 70;
c++)
{
t.lineStyle(1, 0xFFFFFF, Math.random() * 10 + 15);
x =
Math.random() * 200;
y = Math.random() * 20;
t.moveTo(x, y);
t.lineTo(x
+ Math.random() * 4 - 2, y + 25);
}
}
this.beginGradientFill("linear",
[0x003366, 0xFFFFFF], [20, 100], [0, 255], {matrixType:"box", x: 0, y: 0, w:200,
h:400, r: (90 / 180) * Math.PI});
this.lineto(200, 0);
this.lineto(200,
400);
this.lineto(0,
400);
this.endfill();
this.createEmptyMovieClip("rain",
++this.HL);
this.createEmptyMovieClip("clouds",
++this.HL);
this.drawCurves(this.clouds, [0xFFFFFF, 100], [[0, 0, 0, 0], [0,
10, 0, 10], [50, 30, 50, 10], [100, 30, 100, 10], [150, 30, 150, 10], [200, 30,
200, 10], [200, 0, 200, 0]]);
this.rain.onEnterFrame =
createRain;
There's a smilie in the middle of the beginFill line :\ Can
you fix that?
littleRichard
31-05-2003, 12:16 PM
did you maen the beginGradientFill line? i didn't see smiles
anywhere but i changed the code a little and disabled smiles in the
post.
Thanks :)
Use a dark background for this one...// pom
-- water in a bowl -- 24 lines, I
swear
this.createEmptyMovieClip("base",-10)._x =
200;
this.createEmptyMovieClip("wave",-9);
bowl_arr =
[[[0,0],[100,-25],[100,-200],[0,-175]],[[0,0],[0,-175],[-25,-200],[-25,-25]],[[-25,-25],[75,-50],[75,-225],[-25,-200]],[[75,-50],[100,-25],[100,-200],[75,-225]]];
function
drawBowl(){
base.clear();
base.lineStyle(0);
base._y = 300;
for (var
p in bowl_arr){
base.beginFill(0xffffff,40);
// this is 1 line
for (var
n=0 ; n <= (tot = bowl_arr[p].length) ; n++)
!n
?
base.moveTo(bowl_arr[p][0][0],bowl_arr[p][0][1])
:
base.lineTo(bowl_arr[p][n%tot][0],bowl_arr[p][n%tot][1]);
// end of
block
base.endFill();
}
}
function oscillate (){
this._y =
this.mid + 20 * Math.sin((this.a += .08 + random(5)/20) + this.dec) + 10 *
Math.cos(this.a/3);
}
myC = [];
function
createEdge(x,mid,decal){
myC.push(wave.duplicateMovieClip("edge"+(++dep),dep,{_x:base._x+x,mid:base._y+mid,dec:decal,onEnterFrame:oscillate}));
}
drawBowl();
myP
= [[-25,-120],[0,-95],[100,-95],[75,-145]];
for (var m in myP)
createEdge(myP[m][0],myP[m][1],random(20)+20);
this.onEnterFrame =
function(){
this.clear();
this.lineStyle(0);
this.beginFill(0xffffff,20);
//
this is 1 line
for (var l=0 ; l <= (to = myC.length) ; l++)
!l
?
this.moveTo(myC[0]._x,myC[0]._y)
:
this.lineTo(myC[l%to]._x,myC[l%to]._y);
// end of block
}I can't
remember where I've seen that kind of effect but credits goes to that
site...
farafiro
02-06-2003, 02:43 AM
POM
I can see u started to use that Russian guy from
Bit's contest (demetri I think), with this style of code
I do remember
thisDon?t abuse the line limit by using really long infix IF-ELSE statements or
anything like that, it?s there to encourage you to think outside the box! from
here
http://www.actionscript.org/forums/showthread.php3?s=&threadid=28070
magicwand
02-06-2003, 04:53 PM
My second effort:
Jesse should love them pick rain
:)
only 13lines
this.onEnterFrame = function()
{
createEmptyMovieClip("drop"+k, k++);
_root["drop"+k]._x =
_root._xmouse+Math.ceil(Math.random()*400)-200;
_root["drop"+k]._y =
_root._ymouse+Math.ceil(Math.random()*400)-200;
for (i=k-20; i<=k; i++)
{
if (i>0) {
with (_root["drop"+i]) {
beginGradientFill("radial",
[0xFFFFFF, 0xff00ff], [50, 20], [100, 255], {matrixType:"box", x:-50, y:0,
w:100, h:110+c, r:0});
curveTo(+_root["drop"+i].a, _root["drop"+i].c+20, 0,
_root["drop"+i].c+20);
curveTo(-_root["drop"+i].b, _root["drop"+i].c+20, 0,
0);
_root["drop"+i].a = _root["drop"+i].b=_root["drop"+i].c += 1;
if
(_root["drop"+i].a==20)
{
clear(_root["drop"+i].a=_root["drop"+i].b=_root["drop"+i].c=0);}}}}}
Jesse
04-06-2003, 12:05 AM
I'm starting to get suspicious. Some of these entries are
just too good to have been thought up on the fly!
Great work everyone. Go
PINK! :)
webguy
08-07-2003, 04:33 PM
Extreme props to everyone who could keep within the line
count, I did a couple of them but none stayed within the line count. These
things are excellent ways to learn code, and hopefully I can figure out just
what the heck you guys are doing :). Anyway scold me for exceeding the line
count, but here is my skipAstone, please only throw one stone at a time
:)
makeRipple = function (x, y) {
newCirc =
_root.createEmptyMovieClip("newClip"+levelCount,
levelCount++);
newCirc.lineStyle(2, 0x336677, 100);
newCirc.moveTo(10,
0);
newCirc.curveTo(10, 10, 0, 10);
newCirc.curveTo(-10, 10, -10,
0);
newCirc.curveTo(-10, -10, 0, -10);
newCirc.curveTo(10, -10, 10,
0);
newCirc._x = x;
newCirc._y = y;
newCirc.onEnterFrame = function()
{
this._width+=2;
this._height+=2;
this._alpha -= 4;};};
throwStone
= function (sp) {
speed = sp;
slowSpeed = speed;
stone =
_root.createEmptyMovieClip("stone"+levelCount,
levelCount++);
stone.lineStyle(10, 0x000000, 100);
stone.lineTo(.1,
.2);
stone._y = Stage.height+10;
stone._x =
_root._xmouse;
stone.onEnterFrame = function() {
speed *= .9;
this._y
-= speed;
trace(slowSpeed);
if (speed<6) {
speed =
slowSpeed;
clearInterval(rippleID);
rippleID = setInterval(makeRipple,
250, this._x, this._y);
slowSpeed-=4;
} else if (this._y < 0)
{
clearInterval(rippleID);
this.removeMovieClip();}};};
_root.onMouseDown
= function() {
throwStone(20);};
Jesse
11-07-2003, 10:23 PM
I had an idea for this comp when it started but promptly
forgot it. Rememberred it again today. The effect isn't that great but I think
the concept is cool and someone more graphically gifted than I (and without a 25
line limiation) could probably do somethign cool with it. Basically, it
simulates rain revealing an image in the background. Whereever a drop falls, you
can see the bg image. A good application woudl be for simulating rain 'washing
off' dirt on a backdrop image or something.
// Jesse, Rain Mask, v1, 25 lines
including demo
_root.createEmptyMovieClip("bg",
levelCount++);
bg.beginGradientFill("radial", [0x0099FF, 0xFF99FF], [100,
100], [0, 0xFF], {a:200, b:0, c:0, d:0, e:200, f:0, g:200, h:200,
i:1});
bg.lineTo(400, 0);
bg.lineTo(400, 400);
bg.lineTo(0,
400);
bg.lineTo(0,
0);
bg.endFill();
_root.createEmptyMovieClip("container",
levelCount++);
function newDrop() {
for (var a = 0; a<5; a++)
{
newCirc = _root.container.createEmptyMovieClip("newClip"+levelCount,
levelCount++);
newCirc.lineStyle(2, 0x336677, 100);
newCirc.moveTo(10,
0);
newCirc.beginFill(0xFF33FF);
newCirc.curveTo(10, 10, 0,
10);
newCirc.curveTo(-10, 10, -10, 0);
newCirc.curveTo(-10, -10, 0,
-10);
newCirc.curveTo(10, -10, 10, 0);
newCirc.endFill();
newCirc._x =
random(400);
newCirc._y =
random(400);
bg.setMask(container);
}
}
this.onEnterFrame =
newDrop;
To Jesse: // Jesse, Rain Mask, v1, 25 lines including
demo
// Edited by pom 13/07/2003
_root.createEmptyMovieClip(
"container",-5 );
newCirc = _root.container.createEmptyMovieClip( "circ",-10
);
newCirc.lineStyle(2, 0x336677, 100);
newCirc.moveTo(10,
0);
newCirc.beginFill(0xFF33FF);
newCirc.curveTo(10, 10, 0,
10);
newCirc.curveTo(-10, 10, -10, 0);
newCirc.curveTo(-10, -10, 0,
-10);
newCirc.curveTo(10, -10, 10,
0);
_root.createEmptyMovieClip("bg", levelCount++);
myPoints_arr = [
[400,0],[400,400],[0,400],[0,0] ] ;
bg.beginGradientFill("radial", [0x0099FF,
0xFF99FF], [100, 100], [0, 0xFF], {a:200, b:0, c:0, d:0, e:200, f:0, g:200,
h:200, i:1});
for ( var j in myPoints_arr ) bg.lineTo ( myPoints_arr[j][0] ,
myPoints_arr[j][1] ) ;
bg.setMask(container);
function grow ()
{
var dS = 150 - this._xscale ;
if ( dS > 2 ) {this._xscale =
this._yscale += dS / 5 ; }
else delete this.onEnterFrame ;}
function
newDrop() {
for (var a = 0; a<5; a++)
var clip =
newCirc.duplicateMovieClip( "cl" + count, count++,
{_x:random(400),_y:random(400),onEnterFrame:grow} ) ; }
this.onEnterFrame
= newDrop;pom
I was trying to recreate one of Bit's effects, and came to
that this (absolutely no connection to what was intended of course :D). 25 real
lines:// pom trying to be like Bit
function drawDot (x,y,col){
p++;
var
clip =
this.createEmptyMovieClip("d"+p,p);
clip.lineStyle(5,col);
clip.lineTo(.45,.15);
clip._x
= x;
clip._y = y;
}
incr = 8 ;
steps_x = Math.floor( Stage.width
/ incr ) ;
steps_y = Math.floor( Stage.height / incr ) ;
dy = 15;
exc =
8;
this.lineStyle(0,0x666666) ;
clip._visible = 0
;
this.onEnterFrame = function(){
if ( y > Stage.height ) delete
this.onEnterFrame;
else {
y += incr ;
a = b = x = 0 ;
inc_b += .02
;
this.moveTo( x,y ) ;
for ( var i = 0 ; i < steps_x ; i++ ){
x +=
incr ;
ry = y - 30 * Math.sin( a += .03 ) + 5 * Math.cos( b += inc_b ) + exc
* ( Math.random() - .5 ) ;
this.lineTo( x,ry ) ;
}
}
}pom
:)
Jesse
13-07-2003, 02:38 AM
I like the changes you made to mine. That's on benefit I
didn't forsee in these challenges; people improving other perople's code. It's
great to see.
MagiWand,
I had to add this :-) Rain is supposed to
fall so now it does :-)
thanks!
MovieClip.prototype.drop=function(mc,t,r){
mc.onEnterFrame=function(){
this._y-=(this._y-t)*r}}
this.onEnterFrame
= function() {
createEmptyMovieClip("drop"+k, k++);
_root["drop"+k]._x =
_root._xmouse+Math.ceil(Math.random()*400)-200;
_root["drop"+k]._y =
_root._ymouse+Math.ceil(Math.random()*400)-200;
_root["drop"+k].drop(_root["drop"+k],800,.2)
for
(i=k-20; i<=k; i++) {
if (i>0) {
with (_root["drop"+i])
{
beginGradientFill("radial", [0xFFFFFF, 0xff00ff], [50, 20], [100, 255],
{matrixType:"box", x:-50, y:0, w:100, h:110+c,
r:0});
curveTo(+_root["drop"+i].a, _root["drop"+i].c+20, 0,
_root["drop"+i].c+20);
curveTo(-_root["drop"+i].b, _root["drop"+i].c+20, 0,
0);
_root["drop"+i].a = _root["drop"+i].b=_root["drop"+i].c += 1;
if
(_root["drop"+i].a==20)
{
clear(_root["drop"+i].a=_root["drop"+i].b=_root["drop"+i].c=0);}}}}}
retrotron
14-07-2003, 12:38 PM
I'm surprised nobody's posted something like this yet.
It needs to be pared down to 25 lines, so anybody feel free to pare.
;)
Needs a black background.
//
-----------------------------------------------------
// the oval and circle
methods
// -----------------------------------------------------
//
**************************************************************************
//
// MovieClip.drawOval //
MovieClip.prototype.drawOval =
function(obj) {
// obj is an object containing the following
properties:
// rx: the x radius
// ry: the y radius
// line: contains
"lineColor" and "lineAlpha"
// bg: contains "bgColor" and "bgAlpha"
//
initialize parameters
if (obj == undefined) { var obj = new Object(); }
if
(obj.rx == undefined) { obj.rx = 10; }
if (obj.ry == undefined) { obj.ry =
10; }
if (obj.line == undefined) { obj.line = new Object(); }
if
(obj.line.width == undesfined) { obj.line.width = 1; }
if (obj.line.color ==
undefined) { obj.line.color = 0x000000; }
if (obj.line.alpha == undefined) {
obj.line.alpha = 100; }
if (obj.bg == undefined) { obj.bg = new Object();
}
if (obj.bg.color == undefined) { obj.bg.color = "noFill"; }
if
(obj.bg.alpha == undefined) { obj.bg.alpha = 100; }
// initialize colors
and fill info
with (this) {
lineStyle(obj.line.width, obj.line.color,
obj.line.alpha);
moveTo(0 + obj.rx, 0);
if (obj.bg.color != "noFill")
{
beginFill(obj.bg.color, obj.bg.alpha);
} // end "if (obj.bg.color !=
noFill)"
// draw the oval
curveTo(obj.rx, 0.4142 * obj.ry, 0.7071 *
obj.rx, 0.7071 * obj.ry);
curveTo(0.4142 * obj.rx, obj.ry, 0,
obj.ry);
curveTo(-0.4142 * obj.rx, obj.ry, -0.7071 * obj.rx, 0.7071 *
obj.ry);
curveTo(-obj.rx, 0.4142 * obj.ry, -obj.rx, 0);
curveTo(-obj.rx,
-0.4142 * obj.ry, -0.7071 * obj.rx, -0.7071 * obj.ry);
curveTo(-0.4142 *
obj.rx, -obj.ry, 0, -obj.ry);
curveTo(0.4142 * obj.rx, -obj.ry, 0.7071 *
obj.rx, -0.7071 * obj.ry);
curveTo(obj.rx, -0.4142 * obj.ry, obj.rx,
0);
if (obj.bg.color != "noFill") {
endFill();
} // end "if
(obj.bg.color != noFill)"
} // end "with (this)"
} // end
MovieClip.drawOval() method definition
// end MovieClip.drawOval //
//
**************************************************************************
//
//
**************************************************************************
//
// MovieClip.drawCircle //
MovieClip.prototype.drawCircle =
function(obj) {
// obj is an object with the following properties:
//
radius: the radius of the circle,
// line: an object with width, color, and
alpha properties
// bg: an object with color and alpha
properties
this.drawOval({rx: obj.radius, ry: obj.radius, line: obj.line, bg:
obj.bg});
} // end MovieClip.drawCircle() method definition
// end
MovieClip.drawCircle //
//
**************************************************************************
//
// -----------------------------------------------------
// the
rain/snow
//
-----------------------------------------------------
function
waterDrip(count, x, y) {
_root.createEmptyMovieClip("spot" + count,
theDepth++);
_root["spot" + count].x = x;
_root["spot" + count].y =
y;
_root["spot" + count].createEmptyMovieClip("drop_mc", theDepth++);
with
(_root["spot" + count].drop_mc) {
_x = x;
_y = y - 150;
_alpha =
0;
drawCircle({radius: 1, line: {width: 0, color: 0xFFFFFF, alpha: 80}, bg:
{color: 0xFFFFFF, alpha: 80}});
} // end with (_root["spot" +
count])
_root["spot" + count].drop_mc.onEnterFrame = function() {
if
(this._y < (y - 4)) {
this._x += Math.random();
this._x -=
Math.random();
this._y += 7;
(y > 200) ? this._alpha += 10 :
this._alpha += 2;
} else {
waterSpot(count);
_root["dripInterval" +
count] = setInterval(waterSpot, 400, count);
this.clear();
delete
this.onEnterFrame;
} // end if (this._y < (y-4))
} // end
onEnterFrame()
} // end waterDrip()
function waterSpot(count) {
if
(_root["spot" + count].num < 2) {
_root["spot" +
count].createEmptyMovieClip("drip" + _root["spot" + count].num,
theDepth++);
with (_root["spot" + count]["drip" + _root["spot" + count].num])
{
_x = _root["spot" + count].x;
_y = _root["spot" +
count].y;
drawOval({rx: 80, ry: 10, line: {width: 1, color: 0xAAAAAA, alpha:
80}, bg: {color: "noFill"}});
_xscale = 0;
_yscale = 0;
} // end with
(_root["drip" + count])
_root["spot" + count]["drip" + _root["spot" +
count].num].onEnterFrame = function() {
this._xscale += 4;
this._yscale +=
4;
this._alpha -= 2;
(this._y > 200) ? this._alpha -=2 : this._alpha -=
4;
} // end onEnterFrame()
_root["spot" + count].num += 1;
} else
{
clearInterval(_root["dripInterval" + count]);
} // end if (_root["spot"
+ count].num < 2)
} // end waterSpot()
function startDripping()
{
clearInterval(drippingInterval);
waterDrip(i++, (Math.random() * 600) -
25, (Math.random() * 200) + 150);
drippingInterval =
setInterval(startDripping, Math.random() * 2000);
} // end
startDripping()
drippingInterval = setInterval(startDripping,
Math.random() * 500);
retrotron
14-07-2003, 05:13 PM
Well, if I cheat and put the drawCircle command in an
external file, then it gets down to about 35 lines.
I'm too tired now to try
and get rid of 10 more lines.
Sigh . . . I guess I'll have to chock this one
up as a failed attempt.
An example
(http://www.cfhosting.it/jt/extras/waterSnow_small.swf).
#include
"drawCircle.as"
function waterDrip(count, x, y)
{
_root.createEmptyMovieClip("spot"+count,
theDepth++);
_root["spot"+count].createEmptyMovieClip("drop_mc",
theDepth++);
with (_root["spot"+count].drop_mc) {
_x = x;
_y =
y-150;
_alpha = 0;
drawCircle({radius:1, line:{width:0, color:0xFFFFFF,
alpha:80}, bg:{color:0xFFFFFF, alpha:80}});
} // end with (_root["spot" +
count])
_root["spot"+count].drop_mc.onEnterFrame = function() {
if
(this._y < (y-4)) {
this._y += 7;
(y > 250) ? this._alpha += 10 :
this._alpha += 2;
} else {
waterSpot(count, x,
y);
_root["dripInterval"+count] = setInterval(waterSpot, 400, count, x,
y);
this.clear();
delete this.onEnterFrame;
} // end if (this._y <
(y-4))
} // end onEnterFrame()
} // end waterDrip()
function
waterSpot(count, x, y) {
clearInterval(_root["dripInterval" +
count]);
_root["spot" + count].createEmptyMovieClip("drip" + _root["spot" +
count].num, theDepth++);
with (_root["spot" + count]["drip" + _root["spot" +
count].num]) {
_x = x;
_y = y;
drawOval({rx:80, ry:10, line:{width:1,
color:0xAAAAAA, alpha:80}, bg:{color:"noFill"}});
_xscale = _yscale = 0;
}
// end with (_root["drip" + count])
_root["spot" + count]["drip" +
((_root["spot" + count].num)++)].onEnterFrame = function() {
this._xscale =
this._yscale += 4;
(this._y > 200) ? this._alpha -= 2 : this._alpha -=
4;
} // end onEnterFrame()
} // end waterSpot()
function
startDripping() {
clearInterval(drippingInterval);
waterDrip(i++,
(Math.random() * 500) - 25, (Math.random() * 300) + 150);
drippingInterval =
setInterval(startDripping, Math.random() * 2000);
} // end
startDripping()
drippingInterval = setInterval(startDripping, Math.random() *
500);
Jesse
14-07-2003, 09:23 PM
Very nice. I like it :)
littleRichard
14-07-2003, 09:30 PM
my original idea was to do something like that. but somehow
i ended up doing the rain thing instead. anyway i second Jesse, it looks perty
nice:)
senocular
15-07-2003, 11:26 AM
heres one
not too much in terms of eye candy :rolleyes:
and the code is barely readable since I used small variable names all starting
with v :o but it can be fun to play with
vP=[];
for(vI=0;vI<29;vI++)vP[vP.length]={vX:vI*10+10,vY:150,vS:0,vN:vI,vQ:[],vR:[]};
fA=function(vN,vM){
vP[vN].vS+=(vP[vN-1].vQ[vP[vN-1].vQ.length]=[vM,-1])[0];
vP[vN+1].vQ[vP[vN+1].vQ.length]=[vM,1];};
onMouseMove=function(){
vL=vP[vT=Math.round(Math.min(Math.max((_xmouse-10)/10,0),29))].vY;
if
(_ymouse<vL&&vL<vO||vL<_ymouse&&vO<vL)fA(vT,Math.min(Math.max(-1,_ymouse-vO),1));
vO=_ymouse;};
onEnterFrame=function(){
vD=(vF++)%3;
for(vI=0;vI<29;vI++){
vP[vI].vY+=(vP[vI].vS=(vP[vI].vS+(150-vP[vI].vY)*.02)*.98);
if(vD==(i=0))while(i<vP[vI].vQ.length){
vP[vI].vS+=vP[vI].vQ[i][0];
vP[vI+vP[vI].vQ[i][1]].vR[vP[vI+vP[vI].vQ[i][1]].vR.length]=vP[vI].vQ[i++].slice();}}
clear();
for(vI=0;vI<29;vI++){
if
(!vD){
vP[vI].vQ=vP[vI].vR;
vP[vI].vR=[];}
if
(vI!=29-1){
moveTo(vP[vI].vX,vP[vI].vY);
lineStyle(11,Math.min(Math.max(0,127-(vP[vI+1].vY-vP[vI].vY)*15),255),50);
lineTo(vP[vI+1].vX,vP[vI+1].vY);}}};
Just
run your mouse through the surface to make a wave.
Jesse
15-07-2003, 05:02 PM
That's really nice seno. I like it!
betaruce
15-07-2003, 10:27 PM
here's
mine
http://betaruce.xeonic.com/flash_swf/water_lines25.swf
for
(i=0; i<=Stage.width; i += 5) {
(mc=createEmptyMovieClip("p"+(++d), d))._y
= mc.y=Stage.height/2;
mc._x = mc.x=i;
mc.onEnterFrame = function()
{
if
(Math.sqrt((dx=_xmouse-this._x)*dx+(dy=_ymouse-this._y)*dy)<=(dist=70))
{
this.vx += (_xmouse+Math.cos(a=Math.atan2(this._y-_ymouse,
this._x-_xmouse))*dist-this._x)*.9;
this.vy +=
(_ymouse+Math.sin(a)*dist-this._y)*.9;
}
this.vx +=
(this.x-this._x)*.9;
this.vy += (this.y-this._y)*.9;
this._x += (this.vx
*= .85);
this._y += (this.vy *= .85);
};
}
onEnterFrame = function
() {
clear();
lineStyle(1, 0x0066ff, 70);
beginFill(0x0066ff,
70);
moveTo(p1._x, p1._y);
for (i=2; i<=d; i++) lineTo(this["p"+i]._x,
this["p"+i]._y);
lineTo(Stage.width, Stage.height);
lineTo(0,
Stage.height);
lineTo(p1._x, p1._y);
};
farafiro
15-07-2003, 11:35 PM
seno
more like a worm :p
senocular
16-07-2003, 02:20 AM
yeah it does look like a worm :) not enough lines to add
borders or a fill :D
retrotron
16-07-2003, 10:30 AM
betaruce, that reminds me of water flavored jello . . . if
they had that flavor, I'd eat it. ;)
retrotron
16-07-2003, 10:32 AM
Maybe senocular's is a worm floating in water . . . poor,
soggy, worm. ;)
tpuell
25-07-2003, 08:47 AM
so its longern 25 lines
but its really perdy
senocular
25-07-2003, 09:07 AM
for anyone interested, this is tpuell's code:
function
makeBG() {
var bg = _root.createEmptyMovieClip("bg",
0);
bg.beginGradientFill("linear",[0x000033,0x3366ff],[100,100],[0x00,0xFF],{
matrixType:"box", x:0, y:0, w:550, h:400, r: 2*Math.PI
});
bg.moveTo(0,0);
bg.lineTo(550,0);
bg.lineTo(550,400);
bg.lineTo(0,400);
bg.lineTo(0,0);
bg.endFill();
}
function
makeBlues() {
blueArr = new Array();
for (k=0; k<10; k++)
{
blueArr.push("0x" add "99" add random(100));
}
}
function
throwStone() {
var stone = this.createEmptyMovieClip("stone",
1);
stone.moveTo(275, 0);
stone.lineStyle(10, 0,
100);
stone.lineTo(275, 5);
stone.onEnterFrame = function() {
if
(this._y<200) {
this._y += 20;
} else
{
drawMany();
this.removeMovieClip();
}
}
}
function
drawEllipse(cx, cy, ax, ay, l) {
var ellipse =
this.createEmptyMovieClip("elli"+l, l);
ellipse.moveTo(275, 250);
for
(i=0; i<=6.4; i += 0.1) {
if (i<=3) {
ellipse.lineStyle(1, 0,
100*i);
} else {
ellipse.lineStyle(1, 0,
100*(6.4-i));
}
ellipse.lineTo(cx+ax*Math.sin(i),
cy+ay*Math.cos(i));
}
return ellipse;
}
function drawMany() {
for
(c=50; c>0; c -= 5) {
thisOne = drawEllipse(275, 200, 250/c, 80/c,
c);
thisOne.onEnterFrame = function() {
if (this._alpha>0)
{
thisBlue = blueArr[random(10)];
eColor = new
Color(this);
eColor.setRGB(thisBlue);
this._xscale *= 1.1;
this._x -=
this._xscale/4;
this._yscale *= 1.1;
this._y -=
this._yscale/5.5;
this._alpha -= 2;
} else
{
this.removeMovieClip();
}
}
}
}
makeBG();
makeBlues();
throwStone();
stealthelephant
07-08-2004, 11:01 AM
if you suspended a particle in water, you would see that the
wave motion would move it in a circular motion, not up and down
i was
watching a childrens program on the tele and they showed it :), so then i did a
simple wave effect, am working on some sort of 3d wave from this but not ready
yet
//set fps to 27
//1000 x 480
function drawdot(mc_mc)
{
mc_mc.lineStyle(5, 0x2F3CD0, 100);
mc_mc.moveTo(50,
50);
mc_mc.lineTo(50, 51);
}
x = -100;
xx = 0;
for (i=0;
i<=50; i++) {
_root.createEmptyMovieClip("dot"+i, i)._y =
150;
drawdot(_root["dot"+i]);
_root["dot"+i]._x =
x;
_root["dot"+i]._rotation = xx;
x += 30;
xx +=
10;
}
this.onEnterFrame = function() {
for (i=0; i<=50; i++)
{
_root["dot"+i]._rotation += 5;
}
};
farafiro
08-08-2004, 09:07 AM
Who brought this up again??var speed:Number = 0.2;
var
h:Number = 40;
var l:Number = 0.3;
var numW:Number =
Stage.width/10;
this.createEmptyMovieClip("wave",
0);
this.wave.lineStyle(1);
for (i=0; i<=numW; i++)
{
this.wave.createEmptyMovieClip("dot"+i, i);
var c:Color = new
Color(this.wave["dot"+i]);
//c.setRGB(Math.random()*Math.pow(16,
6));
c.setRGB(0x336699);
this.wave["dot"+i]._x = (numW*i)/4;
with
(this.wave["dot"+i]) {
lineStyle(5);
moveTo(10, 100);
lineTo(10,
100.5);
}
this.wave["dot"+i].angle = i*_level0.l;
this.wave["dot"+i].ty
= _y;
this.wave["dot"+i].onEnterFrame = function() {
this._y =
this.ty+Math.sin(this.angle)*h;
this.angle +=
_level0.speed;
};
}
stealthelephant
08-08-2004, 12:08 PM
Who brought this up again??var speed:Number = 0.2;
var
h:Number = 40;
var l:Number = 0.3;
var numW:Number =
Stage.width/10;
this.createEmptyMovieClip("wave",
0);
this.wave.lineStyle(1);
for (i=0; i<=numW; i++)
{
this.wave.createEmptyMovieClip("dot"+i, i);
var c:Color = new
Color(this.wave["dot"+i]);
//c.setRGB(Math.random()*Math.pow(16,
6));
c.setRGB(0x336699);
this.wave["dot"+i]._x = (numW*i)/4;
with
(this.wave["dot"+i]) {
lineStyle(5);
moveTo(10, 100);
lineTo(10,
100.5);
}
this.wave["dot"+i].angle = i*_level0.l;
this.wave["dot"+i].ty
= _y;
this.wave["dot"+i].onEnterFrame = function() {
this._y =
this.ty+Math.sin(this.angle)*h;
this.angle +=
_level0.speed;
};
}
was that 1 posted already or did u just do
it up?
if it was posted already, i missed it :confused:
farafiro
09-08-2004, 01:23 AM
huh
really, I didn't see it. I only reviewd the last 3
page and I didn't see like
lemme check again
farafiro
09-08-2004, 01:55 AM
ok, inudor posted something like mine but it's very
different coding
and also mine is less in script, I can change it
......
if u want ;)
farafiro
09-08-2004, 02:24 AM
k, I think this is different//
var speed:Number =
0.2;
var h:Number = 40;
var l:Number = 0.5;
var numW:Number =
Stage.width/10;
var numH:Number = Stage.height/10;
var d:Number =
0;
//
for (i=0; i<=numW; i++) {
for (j=0; j<=numH; j++)
{
d++;
this.createEmptyMovieClip("wave"+d,
d);
this["wave"].lineStyle(1);
var c:Color = new
Color(this["wave"+d]);
c.setRGB(0x336699);
this["wave"+d]._x =
i*10;
this["wave"+d]._y = j*10;
with (this["wave"+d])
{
lineStyle(5);
moveTo(0, 0);
lineTo(0,
.5);
}
this["wave"+d].angle = _level0.l*d;
this["wave"+d].ty =
this["wave"+d]._y;
this["wave"+d].onEnterFrame = function() {
this._y =
this.ty+Math.sin(this.angle)*_level0.h;
this.angle +=
_level0.speed;
};
}
}
stealthelephant
09-08-2004, 06:31 AM
mine got the least lines :)
farafiro
09-08-2004, 08:45 AM
:confused:
darkzak
13-08-2004, 03:29 PM
Here is my first submission to one of these challenges. It
is a sprinkler.
function createDrop()
{
_root.createEmptyMovieClip("drop" + index, index++);
_root["drop" +
index].lineStyle(.25, 10000*Math.random(), 70);
_root["drop" +
index].lineTo(2*Math.random(),2*Math.random());
_root["drop" + index]._y
=80;
_root["drop" + index].xVel = Math.sin(index/70)*((Math.random()*4) +1);
_root["drop" + index].timer = 0;
_root["drop" + index].onEnterFrame =
function() {
this.timer++;
this.yVel = -(5 - (.098
*this.timer));
this._x += this.xVel;
this._y += this.yVel;
if(this._y
> 100) {
this.removeMovieClip();
}
}
}
_root.onEnterFrame =
function () {
createDrop();
createDrop();
}
kellykamay
29-08-2004, 01:34 PM
wow guys u've done a wonderful job..i envy ur
talents
anyway i got a question...so what kind of math are involve
here,is it trigo or geometry? or is there also physics?..
stealthelephant
30-08-2004, 06:21 AM
mmm not physics the way maya does dynamics or like ray
tracing, mine was just noticing the physics or water motion then i did a simple
effect on it, the atomic challenge was based on physics and geometry
retrotron
30-08-2004, 07:56 AM
I didn't use any physics, though I did use a little trig to
draw the rings in the water.
kellykamay
30-08-2004, 02:03 PM
ic..any good books that u will recommend guys?..i think i
need that teaches math in macromedia flash...and some equations that i could use
for making cool effects..just like u did guys...
sorry for being
demanding...i just want to learn more..hehe
thanks..Godspeed
stealthelephant
30-08-2004, 02:23 PM
robert penners book is good(ish) for flash
but you are
really looking for is a graphical programming book with mathematical techniques
- and they are normally in a better language like java or c++ - if u know them
languages (or any other language in fact) the migration of the code to flash
should be easy
retrotron
30-08-2004, 05:16 PM
Yeah, as stealthelephant mentioned, robert penner's book is
a great place to start. There's also the Friends Of Ed 'Flash Math Creativity'
book.
kellykamay
31-08-2004, 02:27 PM
cool...thanks for the help guys..i'll better check on robert
penners book..
to stealthelephant... thanks for the tip about the java
and c++..and yup im familiar with those two..i already saw some books on c++
that focuses on graphics im going to check on that too...
oh by the way i
already have one of FOED's book..."foundation actionscript for flash mx"..great
book
ok thats it thanks again..Godspeed
vBulletin v3.0.3, Copyright ©2000-2005, Jelsoft Enterprises
Ltd.