PDA

View Full Version : [DBarbarian Entry 1] - Fireworks



dbarbarian
January 13th, 2006, 05:12 PM
I made two versions. One regular and one rainbow.
Let me know which one you like better, because I can't decide.

The rainbow code is the same as this one, but with different color settings.

EDIT: This code should be legal.

this.headA = new Array();

this.drawCircle = function(col,siz,x,y,d) {
this.createEmptyMovieClip("c"+d,d)._x = x;
this["c"+d]._y = y;
this["c"+d].lineStyle(siz,col,100);
this["c"+d].lineTo(1,0);
return this["c"+d];
}

this.removeParticle = function(n,ind) {
n.removeMovieClip();
this.headA.splice(ind,1);
}

this.onEnterFrame = function() {
for (i in this.headA) {
this.headA[i][0]._x += (this.headA[i][5]!="head2") ? this.headA[i][3]:(this.headA[i][1]-this.headA[i][0]._x)/8;
this.headA[i][0]._y += (this.headA[i][5]!="head2") ? this.headA[i][4]:(this.headA[i][2]-this.headA[i][0]._y)/8;
this.headA[i][0]._xscale = this.headA[i][0]._yscale = (80+random(70)-35);
this.headA[i][2] += (this.headA[i][5]=="head2") ? 2:0;
col = new Color(this.headA[i][0]).setRGB("0xFFFF"+((random(2)==0) ? "FF":((random(2)==0) ? "CC":"99")));
if (this.headA[i][5] == "head" and (this.headA[i][0]._x-this.headA[i][1])*(this.headA[i][0]._x-this.headA[i][1])+(this.headA[i][0]._y-this.headA[i][2])*(this.headA[i][0]._y-this.headA[i][2])<100) {
for(j=0; j<16; j++) {
this.headA.push([this.drawCircle("0xFFFFFF",5,this.headA[i][0]._x,this.headA[i][0]._y,this.d++),this.headA[i][0]._x+((j<8) ? (random(20)+100):(random(10)+55))*Math.cos(j*Math. PI/4+Math.random()*Math.PI/8),this.headA[i][0]._y+((j<8) ? (random(20)+100):(random(10)+55))*Math.sin(j*Math. PI/4+Math.random()*Math.PI/8),0,0,"head2"]);
}
this.removeParticle(this.headA[i][0],i);
} else if (this.headA[i][5] == "head2" and this.headA[i][0].clicks++>20+random(15)) {
this.removeParticle(this.headA[i][0],i);
} else if (this.headA[i][5] == "trail" and this.headA[i][2]-this.headA[i][0]._y<2) {
this.removeParticle(this.headA[i][0],i);
}
(this.headA[i][5]!="trail" and random(2)==0) ? this.headA.push([this.drawCircle("0xFFFFFF",2,this.headA[i][0]._x+random(8)-4,this.headA[i][0]._y+random(8)-4,this.d++),this.headA[i][0]._x,this.headA[i][0]._y+random(20)+5,0,1,"trail"]):0;
}
}
this.onMouseDown = function() {
this.tempx = random(400);
this.headA.push([this.drawCircle("0xFFFFFF",5,this.tempx,415,this.d++),this._xmouse,this._ymo use,7*Math.cos(Math.atan2(this._ymouse-415,this._xmouse-this.tempx)),7*Math.sin(Math.atan2(this._ymouse-415,this._xmouse-this.tempx)),"head"]);
}

*NOTE: Do not click too many times. I recommend having 2 fireworks onscreen at one time.
http://dounanthebarb.tripod.com/Kirupa25LineContest/cdb25LineEntry1Fireworks.html
http://dounanthebarb.tripod.com/Kirupa25LineContest/cdb25LineEntry1RbFireworks.html

****NOTE 2*******
Do NOT view the swf file below. For some strange reason, the particles are not removed. The html files are working correctly though.

kdd
January 13th, 2006, 05:20 PM
cool, but if one clicks it too many times, it lags a lot.

dbarbarian
January 13th, 2006, 05:24 PM
Thanks. I added a note on there.

icio
January 13th, 2006, 06:16 PM
It's unfortunate that you don't have enough lines to remove the particles too, that would be the icing on the cake :) - it's a very nice effect :)

dbarbarian
January 13th, 2006, 06:50 PM
Thanks.

I do remove the particles, but for some reason the swf files that I uploaded don't do it. Weird.
The swf work fine on my harddrive, or when I copy and paste the code. But once it's uploaded onto here, the particles aren't removed.

View the html files, those are working properly.

virusescu
January 13th, 2006, 07:10 PM
lovely. I was planning on some fireworks too.

Remove the random colors and put some life to it like changing from yellow to red and then fade out. I like this anyway. When it's small it looks really good :).

icio
January 13th, 2006, 07:28 PM
Oh yeah, that is strange. :puzzle:

Nice effect :thumb:

DDD
January 13th, 2006, 07:53 PM
I had to try it call me a kid, but I clicked hella times.....almost brought my computer to its knees. Nice effect tho.

hybrid101
January 14th, 2006, 01:47 AM
pretty nice effect! but it is pretty cpu intensive

dbarbarian
January 14th, 2006, 03:14 AM
virusecu: I can't think of a one line way to make the particles fade colors and alpha. I'll see if I can compress the code some and I might be able to squeeze it in there. Thanks for the input =)

icio: Thank you. It's a weird problem. It happened to my third submission too, the snake game. Except there, instead of not remove objects, nothing shows up at all except the background. My coding must be soo bad that this site can't process it. :worried:

DDD: lol. Thanks.

hybrid101: Yea. That's what happens when you have a lot of particles looping around. I tried it with less particles, but it just doesn't look as good. I have a much better fireworks experiment that implemented tweens so the little particles didn't need to be pushed into arrays, so I could have a lot more particles on screen. But I would rather not post the link right now as this current one pales in comparison, and I would rather not make my entry look worse than it already is. :ponder: :)

EDIT:
You know what...it actually looks pretty cool when it's small and the particles aren't removed. Kinda looks like your creating palm trees. Odd colored palm trees, but trees nonetheless.

Sinister Shadow
January 14th, 2006, 05:42 AM
Nice, but the coloured one looks a bit too colourful to me. I'll probably like it more if the colours changed less but it's still funky! :D

dbarbarian
January 14th, 2006, 01:02 PM
Thanks sinister.

Here is the original fireworks experiment in case anyone would like to see it. Use 1,2,3,4,5 to shoot different fireworks.

Warning: tripod hosting.
http://dounanthebarb.tripod.com/Work/centfireworks.html

Seb Hughes
January 14th, 2006, 01:35 PM
Very nice, but if you click to much it lags :(

phorte
January 14th, 2006, 08:08 PM
wicked stuff..

McGiver
January 15th, 2006, 06:51 AM
wow, this is cool. :thumb2:

dbarbarian
January 15th, 2006, 05:28 PM
Thanks for the feedback.

Yea, unfortunately it does lag a lot with all the partcles (and especially since they are not being removed for some reason).
The only way to fix that is to decrease the amount of particles produced, but that doesn't look as good. :(

pom
January 24th, 2006, 01:56 PM
Nice, but I have some particles showing up in the top left corner of the screen :-/

SimplyArun
February 6th, 2006, 03:51 AM
nice! I like the one with mono-colors not the multicolored one

neeraj8585
February 28th, 2008, 07:07 AM
its supererb

but iam geeting error while testing the file using above code, plz update that bug

thanks

saxx
July 11th, 2008, 01:22 AM
yep after three or four consecutive clicks it totally owns my computer. I really love it regardless

hive_boy
January 6th, 2010, 10:43 PM
woooowwww...,it's so cool...,