PDA

View Full Version : Flowerchain, and maybe others



McGiver
January 12th, 2006, 09:20 PM
function createflowerblast(i) {
_root.createEmptyMovieClip("flower"+i, i+100)._x = _xmouse;
_root["flower"+i]._y = _ymouse;
_root["flower"+i].leafconfig = [Math.round(Math.sqrt(Math.random()*80))+3, Math.round((Math.random()*2+1))*3];
_root["flower"+i][leafpoint+(0)] = -Math.sqrt(Math.random()*100)*10;
for (k=1; k<=_root["flower"+i].leafconfig[1]; k++) {
_root["flower"+i][leafpoint+k] = _root["flower"+i][leafpoint+(k-1)]-Math.sqrt(Math.random()*100)*3+5;
_root["flower"+i].leafsize += _root["flower"+i][leafpoint+k];
}
_root["flower"+i].createEmptyMovieClip("leaf"+0, 10).lineStyle(1, 0x990000, 50);
_root["flower"+i]["leaf"+0].beginGradientFill("radial", [parseInt(("0x"+(Math.round(Math.random()*239+16)).toString(16)+"ff"+(Math.round(Math.random()*239+16)).toString(16))) , parseInt(("0x"+(Math.round(Math.random()*155+100)).toString(16)+ (Math.round(Math.random()*155+100)).toString(16)+( Math.round(Math.random()*155+100)).toString(16))), parseInt(("0x"+(Math.round(Math.random()*155+100)).toString(16)+ (Math.round(Math.random()*155+100)).toString(16)+( Math.round(Math.random()*155+100)).toString(16))), parseInt(("0x"+(Math.round(Math.random()*155+100)).toString(16)+ (Math.round(Math.random()*155+100)).toString(16)+( Math.round(Math.random()*155+100)).toString(16))), parseInt(("0x"+(Math.round(Math.random()*155+100)).toString(16)+ (Math.round(Math.random()*155+100)).toString(16)+( Math.round(Math.random()*155+100)).toString(16))), parseInt(("0x"+(Math.round(Math.random()*155+100)).toString(16)+ (Math.round(Math.random()*155+100)).toString(16)+( Math.round(Math.random()*155+100)).toString(16)))], [80, 80, 80, 80, 80, 80], [0, 60, 100, 140, 180, 255], {matrixType:"box", x:(-_root["flower"+i].leafsize)/2-10, y:(-_root["flower"+i].leafsize)/2-10, w:_root["flower"+i].leafsize+20, h:_root["flower"+i].leafsize+20, r:(0/180)*Math.PI});
for (_root["flower"+i]._xscale=_root["flower"+i]._yscale=k=1; k<=(_root["flower"+i].leafconfig[1]); k += 2) {
_root["flower"+i]["leaf"+0].curveTo(Math.sqrt(_root["flower"+i].leafconfig[1]-k)*-15, _root["flower"+i][leafpoint+k], Math.sqrt(_root["flower"+i].leafconfig[1]-(k+1))*-15, _root["flower"+i][leafpoint+(k+1)]);
}
for (k=(_root["flower"+i].leafconfig[1])-1; k>1; k -= 2) {
_root["flower"+i]["leaf"+0].curveTo(Math.sqrt(_root["flower"+i].leafconfig[1]-k)*15, _root["flower"+i][leafpoint+k], Math.sqrt(_root["flower"+i].leafconfig[1]-(k-1))*15, _root["flower"+i][leafpoint+(k-1)]);
}
_root["flower"+i]["leaf"+0].curveTo(Math.sqrt(_root["flower"+i].leafconfig[1]-k)*15, _root["flower"+i][leafpoint+k], 0, 0);
for (j=1; j<_root["flower"+i].leafconfig[1]; j++) {
_root["flower"+i]["leaf"+0].duplicateMovieClip("leaf"+j, j+10)._rotation = j*(360/_root["flower"+i].leafconfig[1]);
}
}
_root.onEnterFrame = function() {
for (n=_root.rootArr[1]-5; _root.rootArr[0] != 1 && n<=_root.rootArr[1]; n++) {
_root["flower"+n]._xscale = _root["flower"+n]._yscale=Math.pow((_root["flower"+n].grow += 1000000), 0.15);
}
if ((_root.rootArr[0] == 1 && (_root.rootArr[1]>5 && _root.rootArr[2]++)) || _root.rootArr[2] == undefined) {
for (n=_root.rootArr[2]; n<=_root.rootArr[2]+20; n++) {
_root["flower"+(n)]._alpha -= 5;
}
_root["flower"+(_root.rootArr[2]-50)].removeMovieClip();
(_root.rootArr[2] == undefined || _root.rootArr[2]>_root.rootArr[1]+51) ? _root.rootArr=[0, 0, -20] : 1;
}
};
_root.onMouseMove = function() {
(_root.rootArr[0] != 1) ? createflowerblast(++_root.rootArr[1]) : 1;
};
_root.onMouseDown = function() {
_root.rootArr[0] = 1;
};


nothing I haven't done before, but with some small improvements.
let me know if the code compression level is too high :D

I've an intermediate diploma test on wednesday, so I should do something else than flash :azn:

see also
->sharks (http://www.kirupa.com/forum/showthread.php?t=205743)
->Bf compiler/interpreter (http://www.kirupa.com/forum/showthread.php?t=205641)

icio
January 12th, 2006, 10:11 PM
Awesome, McGiver. That's seriously smart :)

freeskier89
January 12th, 2006, 10:48 PM
Awesome, McGiver. That's seriously smart :) Indeed, it is :) ! I really like it. The only thing that I think would make it better is, draw the flowers with math rather than manual defs; That would allow for more flexibility for the creation of the flowers (use polar). Still is great :D. The compression might be pushing it a little, but I think it is alright.

expensive_pen
January 12th, 2006, 11:40 PM
yeah that is really cool looking, good job

NiñoScript
January 13th, 2006, 01:31 AM
WOW... i think i lost :(

J
January 13th, 2006, 02:07 AM
Wow fantastic!! :)

Thats cool. U will b the strong contender

hybrid101
January 13th, 2006, 10:12 AM
killed my pc. it's too heavy!

McGiver
January 13th, 2006, 10:41 AM
:( runs fine on my laptop even with 600 MHz
what did you do? open the swf and run it for 20 minutes? :puzzled:
thanks everyone btw :)
@freeskier89: I have a math version, but that takes more lines

kirupa
January 13th, 2006, 01:21 PM
Runs fine for me McGiver, and your entry looks nice :)

Would it be possible for you to attach (using the forum's attach feature) the SWF to your post also. That way, in a few years, the entries will still be browsable even if you changed your servers, etc.

dbarbarian
January 13th, 2006, 05:39 PM
Brilliant!

Neil
January 13th, 2006, 06:47 PM
Incredible... how can you possibly code that in 25 lines ! Unbelievable... good job man !

McGiver
January 14th, 2006, 07:25 AM
@kirupa - swf attached :)

and actually it was a lot more than 25 lines - I was just abled to remove unnecessary stuff like "endFill" and merging every

if(a){
for(i=0;i<b;i++){
//code
}
}
to


for(i=0;i<b&&a;i++){
//code
}

...and not to forget: try to use any function that returns something

hybrid101
January 14th, 2006, 07:49 AM
ok. got it to work. that is awesome man!!! i love it!

Seb Hughes
January 14th, 2006, 01:42 PM
Wow that is very nice and the fading back kicks ***

Deril
January 14th, 2006, 05:56 PM
thats look realy nice...
hey... clicks on the scrtean do something too?! :)

didnt noticed then looked first time ..

McGiver
January 15th, 2006, 06:21 AM
yep, clicks fade the last flowerchain out, and start a new one

mmubashar
February 6th, 2006, 03:00 AM
McGiver! That is SUPERB! Nice effects! And whow, the fading back effect! I just love this one! Real programmers are born with good brains. You got my vote dude! I want it after the competition is over!! I just LOVE IT!!

ShahZ

SimplyArun
February 6th, 2006, 03:41 AM
This is darn good I LOVE IT

pedro.paulo
February 8th, 2006, 12:10 AM
Incredible.. absolute incredible

vega
July 14th, 2006, 09:11 AM
Wow! Very nicely done.

And yeah fading back was a really great idea. Kudos! :thumb: