PDA

View Full Version : Explosions!


zap1992
02-14-2006, 10:03 PM
Lets see.... Any type of explosion including volcanoes, particles, bombs, fades, and just about anything you can think of... I think this should be 50 lines or less as to allow for a full spectrum of..... scripts. Let the games begin?


Note: I will post my 'entry' ASAP

invader
02-15-2006, 05:05 PM
how about 36 lines? (i recommend using 30+ fps)

size = 100;
howMany = 5;
function createBoom() {
if (depth>20) {
depth = 0; }
depth++;
createEmptyMovieClip("boom"+depth,depth);
boom = this["boom"+depth];
boom.onEnterFrame = function () {
this.Scale += this.rate;
this._xscale = this.Scale;
this._yscale = this.Scale;
this._alpha = 100 - this.Scale;
if (this.Scale>=100) {
createBoom();
this.removeMovieClip(); } }
boom._xscale = 0;
boom._yscale = 0;
boom.Scale = 0;
boom.rate = 5+Math.random()*10;
boom._x = Math.random()*550;
boom._y = Math.random()*400;
boom.lineStyle(0);
boom.moveTo(size,0);
for(a=1;a<12;a++) {
x = .1*size*Math.cos((a-.5)*Math.PI/6);
y = .1*size*Math.sin((a-.5)*Math.PI/6);
ax = size*Math.cos(a*Math.PI/6);
ay = size*Math.sin(a*Math.PI/6);
boom.curveTo(x,y,ax,ay); }
x = .1*size*Math.cos((a-.5)*Math.PI/6);
y = .1*size*Math.sin((a-.5)*Math.PI/6);
boom.curveTo(x,y,size,0); }
depth=0;
for (i=0;i<howMany;i++) {
createBoom(); }

falltimemusic
02-15-2006, 05:48 PM
Im looking through your code and I don't see anything that makes the graphic! Is "boom" a built in graphic or something?

zap1992
02-16-2006, 01:12 AM
boom.lineStyle(0);
boom.moveTo(size,0);
for(a=1;a<12;a++) {
x = .1*size*Math.cos((a-.5)*Math.PI/6);
y = .1*size*Math.sin((a-.5)*Math.PI/6);
ax = size*Math.cos(a*Math.PI/6);
ay = size*Math.sin(a*Math.PI/6);
boom.curveTo(x,y,ax,ay); }
x = .1*size*Math.cos((a-.5)*Math.PI/6);
y = .1*size*Math.sin((a-.5)*Math.PI/6);
boom.curveTo(x,y,size,0); }



EDIT:Oooohhh... thats pretty cool (hadn't tried it until now) sorry about my code not existing yet :-P ill get on it

zap1992
02-20-2006, 02:01 AM
detail = 150;
ticker = -1;
createEmptyMovieClip("particle", 0);
particle.lineStyle(10, 0xCC0000, 50);
particle.lineTo(0, 0);
particle.lineTo(0, .5);
createEmptyMovieClip("background", 1);
background.beginFill(0x000000,100);
background.lineTo(0,0)
background.lineTo(550,0)
background.lineTo(550,400)
background.lineTo(0,400)
background.lineTo(0,0)
function onMouseDown() {
xmouse = _root._xmouse;
ymouse = _root._ymouse;
for (x=2; x<=detail+1; x++) {
particle.duplicateMovieClip("dot"+x, x);
_root["dot"+x].rand = random(100);
_root["dot"+x]._alpha = _root["dot"+x].rand+15;
_root["dot"+x]._width = _root["dot"+x].rand/100*25;
_root["dot"+x]._height = _root["dot"+x].rand/100*25;
_root["dot"+x].angle = (random(80)+230)*Math.PI/180;
_root["dot"+x].distance = 5;
_root["dot"+x].speed = Math.random()*10;
_root["dot"+x].X = xmouse;
_root["dot"+x].Y = ymouse;
_root["dot"+x]._x = xmouse;
_root["dot"+x]._y = ymouse;}}
function onEnterFrame() {
for (x=1; x<=detail+1; x++) {
with (_root["dot"+x]) {
if (speed>=3) {
ang = angle/(Math.PI/180);
angle = ang*(Math.PI/180);
distance += speed;
speed -= .3;
_y = Math.sin(angle)*distance+Y;
_x = Math.cos(angle)*distance+X;
} else {
if (_y<=Y-_width/2) {
speed -= 1;
_y -= speed/2;
diff = X-_x;
_x -= (Math.abs(diff)/diff)*Math.abs(diff/40);}}}}}

invader
02-21-2006, 02:12 AM
nice!

sometimes you question people who start challenges but don't include an example. however, i really liked yours. had a bit of a lava look to it. awesome. i did get errors when i tested it. perhaps it's the for() loop in the onEnterFrame starting at x=1, when the dot#'s were created starting at #2

@falltimemusic
it uses Flash's drawing API. you can create a movie clip using code:createEmptyMovieClip("myName",this.getNextHighestDepth());
then you can draw with it:createEmptyMovieClip("myName",this.getNextHighestDepth());
myName.lineStyle(0); // sets the appearance of the line
myName.moveTo(size,0); // moves the position where it starts drawing
size=100;
for(a=1;a<12;a++) {
x = .1*size*Math.cos((a-.5)*Math.PI/6);
y = .1*size*Math.sin((a-.5)*Math.PI/6);
ax = size*Math.cos(a*Math.PI/6);
ay = size*Math.sin(a*Math.PI/6);
myName.curveTo(x,y,ax,ay); } // draws a curve to the next point. you can also use .lineTo()
x = .1*size*Math.cos((a-.5)*Math.PI/6);
y = .1*size*Math.sin((a-.5)*Math.PI/6);
myName.curveTo(x,y,size,0); }

zap1992
02-22-2006, 01:47 AM
fireworks anyone? =D
NOTE: You can have multiple fireworks at once!! but watch out, if you turn up maxbursts too high you get some serious lag (unless you turn down detail that is)

function onLoad() {
//change any of these variables
detail = 150;
angle = -90;
spread = 360;
size = 26;
maxburst = 2;
//Dont change anything below here
countz = -1;
ticker = -1;
createEmptyMovieClip("background", 1);
background.beginFill(0x000000, 100);
background.lineTo(0, 0);
background.lineTo(550, 0);
background.lineTo(550, 400);
background.lineTo(0, 400);
background.lineTo(0, 0);}
function onMouseDown() {explosionsize = random(10) + 5
xmouse = _root._xmouse;
ymouse = _root._ymouse;
createEmptyMovieClip("particle", 0);
particle.lineStyle(10, Math.round(Math.random()*0xFFFFFF+1), 50);
particle.lineTo(0, 0);
particle.lineTo(0, .5);
countz++
if (countz>=maxburst) {countz = 0;}
for (x=2+(countz*detail+1); x<=(countz*detail+1) + detail+1; x++) {
particle.duplicateMovieClip("dot"+x, x);
_root["dot"+x].rand = random(100);
_root["dot"+x]._alpha = _root["dot"+x].rand+15;
_root["dot"+x]._width = _root["dot"+x].rand/100*size;
_root["dot"+x]._height = _root["dot"+x].rand/100*size;
_root["dot"+x].angle = (random(spread)+angle-spread/2)*Math.PI/180;
_root["dot"+x].distance = 5;
_root["dot"+x].speed = Math.random()*2+explosionsize;
_root["dot"+x].X = xmouse;
_root["dot"+x].Y = ymouse;
_root["dot"+x]._x = xmouse;
_root["dot"+x]._y = ymouse;}}
function onEnterFrame() {for (x=2; x<=(detail*maxburst) + 2 && x<= 10000; x++) {if (_root["dot"+x]._name != undefined) {with (_root["dot"+x]) {if (speed>=0) {
ang = angle/(Math.PI/180);
angle = ang*(Math.PI/180);
distance += speed;
speed -= 1;
_y = Math.sin(angle)*distance+Y;
_x = Math.cos(angle)*distance+X;
_alpha -= 3;
} else {if (_y<=Stage.width) {_alpha -= 3;
speed -= 1;
_y -= speed/2;
diff = X-_x;
_x -= (Math.abs(diff)/diff)*Math.abs(diff/100);}}}}}}

And of course for those of you who are amazingly laz, the automated version...(Sorry, i didn't format it for minimal lines so... it hits 68 :D)

function onLoad() {
//change any of these variables
detail = 150;
angle = -90;
spread = 360;
size = 26;
maxburst = 2;
//Dont change anything below here
countz = -1;
ticker = -1;
createEmptyMovieClip("background", 1);
background.beginFill(0x000000, 100);
background.lineTo(0, 0);
background.lineTo(550, 0);
background.lineTo(550, 400);
background.lineTo(0, 400);
background.lineTo(0, 0);
}
function onEnterFrame() {
if (Math.random()*100<5) {
explosionsize = Math.random()*5+7.5;
xmouse = Math.random()*550;
ymouse = Math.random()*400;
createEmptyMovieClip("particle", 0);
particle.lineStyle(10, Math.round(Math.random()*0xFFFFFF+1), 50);
particle.lineTo(0, 0);
particle.lineTo(0, .5);
countz++;
if (countz>=maxburst) {
countz = 0;
}
for (x=2+(countz*detail+1); x<=(countz*detail+1)+detail+1; x++) {
particle.duplicateMovieClip("dot"+x, x);
_root["dot"+x].rand = random(100);
_root["dot"+x]._alpha = _root["dot"+x].rand+15;
_root["dot"+x]._width = _root["dot"+x].rand/100*size;
_root["dot"+x]._height = _root["dot"+x].rand/100*size;
_root["dot"+x].angle = (random(spread)+angle-spread/2)*Math.PI/180;
_root["dot"+x].distance = 5;
_root["dot"+x].speed = Math.random()*2+explosionsize;
_root["dot"+x].X = xmouse;
_root["dot"+x].Y = ymouse;
_root["dot"+x]._x = xmouse;
_root["dot"+x]._y = ymouse;
}
}
for (x=2; x<=(detail*maxburst)+2 && x<=10000; x++) {
if (_root["dot"+x]._name != undefined) {
with (_root["dot"+x]) {
if (speed>=0) {
ang = angle/(Math.PI/180);
angle = ang*(Math.PI/180);
distance += speed;
speed -= 1;
_y = Math.sin(angle)*distance+Y;
_x = Math.cos(angle)*distance+X;
_alpha -= 3;
} else {
if (_y<=Stage.width) {
_alpha -= 3;
speed -= 1;
_y -= speed/2;
diff = X-_x;
_x -= (Math.abs(diff)/diff)*Math.abs(diff/100);
}
}
}
}
}
}

daly3721
06-01-2006, 12:11 PM
fireworks anyone? =D
NOTE: You can have multiple fireworks at once!! but watch out, if you turn up maxbursts too high you get some serious lag (unless you turn down detail that is)

function onLoad() {
//change any of these variables
detail = 150;
angle = -90;
spread = 360;
size = 26;
maxburst = 2;
//Dont change anything below here
countz = -1;
ticker = -1;
createEmptyMovieClip("background", 1);
background.beginFill(0x000000, 100);
background.lineTo(0, 0);
background.lineTo(550, 0);
background.lineTo(550, 400);
background.lineTo(0, 400);
background.lineTo(0, 0);}
function onMouseDown() {explosionsize = random(10) + 5
xmouse = _root._xmouse;
ymouse = _root._ymouse;
createEmptyMovieClip("particle", 0);
particle.lineStyle(10, Math.round(Math.random()*0xFFFFFF+1), 50);
particle.lineTo(0, 0);
particle.lineTo(0, .5);
countz++
if (countz>=maxburst) {countz = 0;}
for (x=2+(countz*detail+1); x<=(countz*detail+1) + detail+1; x++) {
particle.duplicateMovieClip("dot"+x, x);
_root["dot"+x].rand = random(100);
_root["dot"+x]._alpha = _root["dot"+x].rand+15;
_root["dot"+x]._width = _root["dot"+x].rand/100*size;
_root["dot"+x]._height = _root["dot"+x].rand/100*size;
_root["dot"+x].angle = (random(spread)+angle-spread/2)*Math.PI/180;
_root["dot"+x].distance = 5;
_root["dot"+x].speed = Math.random()*2+explosionsize;
_root["dot"+x].X = xmouse;
_root["dot"+x].Y = ymouse;
_root["dot"+x]._x = xmouse;
_root["dot"+x]._y = ymouse;}}
function onEnterFrame() {for (x=2; x<=(detail*maxburst) + 2 && x<= 10000; x++) {if (_root["dot"+x]._name != undefined) {with (_root["dot"+x]) {if (speed>=0) {
ang = angle/(Math.PI/180);
angle = ang*(Math.PI/180);
distance += speed;
speed -= 1;
_y = Math.sin(angle)*distance+Y;
_x = Math.cos(angle)*distance+X;
_alpha -= 3;
} else {if (_y<=Stage.width) {_alpha -= 3;
speed -= 1;
_y -= speed/2;
diff = X-_x;
_x -= (Math.abs(diff)/diff)*Math.abs(diff/100);}}}}}}

And of course for those of you who are amazingly laz, the automated version...(Sorry, i didn't format it for minimal lines so... it hits 68 :D)

function onLoad() {
//change any of these variables
detail = 150;
angle = -90;
spread = 360;
size = 26;
maxburst = 2;
//Dont change anything below here
countz = -1;
ticker = -1;
createEmptyMovieClip("background", 1);
background.beginFill(0x000000, 100);
background.lineTo(0, 0);
background.lineTo(550, 0);
background.lineTo(550, 400);
background.lineTo(0, 400);
background.lineTo(0, 0);
}
function onEnterFrame() {
if (Math.random()*100<5) {
explosionsize = Math.random()*5+7.5;
xmouse = Math.random()*550;
ymouse = Math.random()*400;
createEmptyMovieClip("particle", 0);
particle.lineStyle(10, Math.round(Math.random()*0xFFFFFF+1), 50);
particle.lineTo(0, 0);
particle.lineTo(0, .5);
countz++;
if (countz>=maxburst) {
countz = 0;
}
for (x=2+(countz*detail+1); x<=(countz*detail+1)+detail+1; x++) {
particle.duplicateMovieClip("dot"+x, x);
_root["dot"+x].rand = random(100);
_root["dot"+x]._alpha = _root["dot"+x].rand+15;
_root["dot"+x]._width = _root["dot"+x].rand/100*size;
_root["dot"+x]._height = _root["dot"+x].rand/100*size;
_root["dot"+x].angle = (random(spread)+angle-spread/2)*Math.PI/180;
_root["dot"+x].distance = 5;
_root["dot"+x].speed = Math.random()*2+explosionsize;
_root["dot"+x].X = xmouse;
_root["dot"+x].Y = ymouse;
_root["dot"+x]._x = xmouse;
_root["dot"+x]._y = ymouse;
}
}
for (x=2; x<=(detail*maxburst)+2 && x<=10000; x++) {
if (_root["dot"+x]._name != undefined) {
with (_root["dot"+x]) {
if (speed>=0) {
ang = angle/(Math.PI/180);
angle = ang*(Math.PI/180);
distance += speed;
speed -= 1;
_y = Math.sin(angle)*distance+Y;
_x = Math.cos(angle)*distance+X;
_alpha -= 3;
} else {
if (_y<=Stage.width) {
_alpha -= 3;
speed -= 1;
_y -= speed/2;
diff = X-_x;
_x -= (Math.abs(diff)/diff)*Math.abs(diff/100);
}
}
}
}
}
}

i am from huangshi,hb,china - a pretty tiny city,it is wonderful here .i am learning .:)

TeddyKrulewich
06-02-2006, 02:13 AM
Here is my explosion. It is based on an explosion class I made almost a month ago. Also this is the first time I've entered some code in a challenge.

this.createEmptyMovieClip("p0", 100);
p0._x = 275;
p0._Y = 200;
p0.lineStyle(1, 0xff0000, 100);
p0.moveTo(0, 0);
p0.lineTo(0, 3);
pNum = 1000;
function explode() {
for (i=0; i<pNum; ++i) {
duplicateMovieClip("p0", "p"+i, i);
this["p"+i]._alpha=100;
this["p"+i].decay = Math.round(Math.random()*9)+1;
this["p"+i].initXvel = Math.round(Math.random()*-10)+10;
this["p"+i].xvel = this["p"+i].initXvel;
this["p"+i].yvel = Math.round(Math.random()*-10)+10;
this["p"+i]._x = 275+Math.round(Math.random()*-10)+10;
this["p"+i]._y = 200+Math.round(Math.random()*-10)+10;
this["p"+i].onEnterFrame = function() {
this._alpha -= this.decay;
if (this.initXvel<5) {
this._x += this.xvel;
} else {
this._x -= this.xvel;
}
this._y -= this.yvel;
this.xvel -= 1;
this.yvel -= 0.5;
};
}
}
explode();

jclarke
06-21-2006, 01:21 PM
Hey guys i though i'd give it a go attached is my explosion effect!

zap1992
06-21-2006, 08:22 PM
Looks really cool. It would look a bit cooler if it went faster and there were multiple ones of them. Also, if it got bigger before it shrank it would be more realistic. Keep up the good work.