You are invited to Log in or Register a free Frihost Account!

# Fireworks

Recently, I had the sudden urge to try my hand at something that at least vaguely reflected real life - real physics. But what? What on earth could I program in Flash without too much hassle and that also followed the rules of physics and was, at the same time, fascinating to look at?

Now of course you already know the answer to that, you've seen the title to this post. I decided to create some fireworks! This would provide me with a challenge but wouldn't require masses of graphical work either.

As this is my first blog I should probably take a minute out to explain that I love challenges, especially programming challenges. Often I manage to solve some problem or other and then loose all interest in whatever I was doing merely because there's no challenge in it any more. I should also say that I'm a programmer at heart... Yeah, I can do graphics that look okay, but it takes me far longer than it should and I get less enjoyment from it.

Anyway, I expect you're tiring now - I can't help but write long blogs / comments, I like writing - so I'll get back to Fireworks.
I had to use the SUVAT equations as well as trigonometry and maths involving vectors to get the right effect. I also got a little confused when bouncing them off the sides of the stage. There's a little more information about the maths used on Fireworks page of my FriHost site, but not much. If anyone would like something more in depth about this I'm happy to make another blog; just don't ask me for any source code.

Did I manage to make something that reflected real life? Yes! I think I did. However, I cheated slightly by increasing the rate of time (I think by 50%, I can't remember). My reason for this being that the fireworks move in pixels per second and not meters per second and thus appear very slow in real time. So speeding them up actually means they reflect life more fully.
I'm not sure whether to make the explosion particles fade out as they fall - what do you think? Oh, and have you got any other suggestions?

Here's a link to Fireworks: http://ninjakannon.frih.net/?pageid=7!

Wow that was really good. The maths involved must have been really hard to do, but you seemed to have pulled it off.

Just one query. Some of the fireworks seem to speed up at random points during their flight (i.e. they appear, speed up slightly, slow down, and then randomly speed up again).

Other than that it was great.
Genesiz on Sat Oct 27, 2007 10:33 am
Oh thanks! I tried pretty hard to get this to look good.

About the speeding up and slowing down again, a speed change occurs when more fireworks or explosion particles are created on the stage. This is because it takes extra CPU usage to work out their position and, furthermore, when creating them - especially the particles - more work has to be done by flash.

I don't think there's a better way to code this so that it runs quicker. But if I do find a method of making it more efficient then I'll definitely implement it.
ninjakannon on Wed Oct 31, 2007 1:02 am