Allegro.cc - Online Community

Allegro.cc Forums » Off-Topic Ordeals » Let's have a (virtual) fireworks competition!

This thread is locked; no one can reply to it. rss feed Print
Let's have a (virtual) fireworks competition!
LennyLen
Member #5,313
December 2004
avatar

Can someone check some maths for me?

Consider the following diagram:

{"name":"600114","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/b\/8\/b8e1af488d6542be9c84565ec0c63194.png","w":800,"h":600,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/b\/8\/b8e1af488d6542be9c84565ec0c63194"}600114

If V and A are known, and you want to calculate X and Y, they can be calculated as follows, yes?

X = V * cos(A)
Y = V * sin(A)

And if the angle is in degrees, then to pass it to the math.h functions, which are in radians (iirc), you should then do:

X = V * cos(A * PI / 180)
Y = V * sin(A * PI / 180)

So, have I got all that right?

OnlineCop
Member #7,919
October 2006
avatar

If "A" is your theta, you are correct that

X = V * cos(A);
Y = V * sin(A);

For the next part, you may find it easier to precalculate your values for either PI / 180 or 180 / PI:

static const double RAD2DEG = 180.0 / M_PI;
static const double DEG2RAD = M_PI / 180.0;

X = V * cos(A * DEG2RAD);
Y = V * sin(A * DEG2RAD);

Looks like you have it correct.

type568
Member #8,381
March 2007
avatar

blargmob said:

What exactly happened? Did it say anything? You'll need XNA GS 3.1 and .NET 3.5 in order to build it. And I think you just need .NET 3.5 to run it.

Can't, just crashed. What I have out of these platforms- no clue. Just Win7 x64..

P.S.
Come on people.. Make it move. Static images are boring :(

Append:
All those that move, are nice though :P:)

ixilom
Member #7,167
April 2006
avatar

Still got a few days to go ;)

Progress has been slow though, a friend is visiting = no coding ;)

___________________________________________
Democracy in Sweden? Not since 2008-Jun-18.
<someone> The lesbians next door bought me a rolex for my birthday.
<someone> I think they misunderstood when I said I wanna watch...

Mark Oates
Member #1,146
March 2001
avatar

Hey look someone already posted my image on google image search!

Ahahaha!

--
Visit CLUBCATT.com for cat shirts, cat mugs, puzzles, art and more <-- coupon code ALLEGRO4LIFE at checkout and get $3 off any order of 3 or more items!

AllegroFlareAllegroFlare DocsAllegroFlare GitHub

ixilom
Member #7,167
April 2006
avatar

Just a preview :P

video

___________________________________________
Democracy in Sweden? Not since 2008-Jun-18.
<someone> The lesbians next door bought me a rolex for my birthday.
<someone> I think they misunderstood when I said I wanna watch...

LennyLen
Member #5,313
December 2004
avatar

Here's what I threw together:

video

(It may still be waiting for processing on YouTubeIt only took 42 minutes, but it's up now)

The source code is attached. I didn't really attempt to regulate speed or optimize the code, so it may not run so well on slower computers.

EDIT: I forgot to mention, The reason I asked about the maths earlier was that there were certain areas that were never being drawn to, and I thought I had my equations wrong. It turned out is was just due to the crappiness of rand(). When I switched to using a Mersenne Twister algorithm instead, the particle distribution became even.

Jonatan Hedborg
Member #4,886
July 2004
avatar

ixilom: Wow. Really awesome.

Here is my first version, I might update it a bit if I feel like it ;)

I did some experimentation with function pointers, void*'s etc... There are plenty of hacks in the source, so don't go there unless you really want to.

It kinda started out with just plain C, but moved slightly over to C++ because I started to use OpenLayer and figured "meh, what the hell"... Fun exercise though!

{"name":"600129","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/d\/7\/d77c039cd81df6ea716f4c7009b7a804.jpg","w":800,"h":603,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/d\/7\/d77c039cd81df6ea716f4c7009b7a804"}600129

Trent Gamblin
Member #261
April 2000
avatar

I updated my original entry (and the link to the app in my post). Here it is again: link.

Edit: Oops, seems I messed it up. Wasn't working right on my faster computer. Updated again.

Jonatan Hedborg
Member #4,886
July 2004
avatar

Anyone know if it's possible/easy to add some motion blur in openlayer? I would guess through direct OpenGL access, which is fine.

ImLeftFooted
Member #3,935
October 2003
avatar

Doubt it.

Trent Gamblin
Member #261
April 2000
avatar

Yes, the easiest way to do motion blur is when you have a solid colored background. Fireworks are on black so it's easy. Render your frames to a buffer, never erase the buffer and after drawing a frame draw a translucent black rectangle over the whole scene. It'll gradually fade everything out like a motion blur.

ImLeftFooted
Member #3,935
October 2003
avatar

Hm. You could also just draw the particle 10 times with varying alpha tint.

Trent Gamblin
Member #261
April 2000
avatar

Then you have to draw the particle 10 times, and keep track of 9 previous positions.

Here's a video

video

BAF
Member #2,981
December 2002
avatar

Neat effect.

type568
Member #8,381
March 2007
avatar

Here is my first version, I might update it a bit if I feel like it

It was nice before it crashed, with no info on the crash(

Jonatan Hedborg
Member #4,886
July 2004
avatar

type568 said:

It was nice before it crashed

Hmm. Strange. At what point did it crash? (ie, what happened on the screen)
See if this version works better (attached).

Also with motion blur!

EDIT:

Yes, the easiest way to do motion blur is when you have a solid colored background. Fireworks are on black so it's easy. Render your frames to a buffer, never erase the buffer and after drawing a frame draw a translucent black rectangle over the whole scene. It'll gradually fade everything out like a motion blur.

Oh yeah, of course! :D It was super easy to implement and looks really good! Thanks

FMC
Member #4,431
March 2004
avatar

nm

[FMC Studios] - [Caries Field] - [Ctris] - [Pman] - [Chess for allegroites]
Written laws are like spiders' webs, and will, like them, only entangle and hold the poor and weak, while the rich and powerful will easily break through them. -Anacharsis
Twenty years from now you will be more disappointed by the things that you didn't do than by the ones you did do. So throw off the bowlines. Sail away from the safe harbor. Catch the trade winds in your sails. Explore. Dream. Discover. -Mark Twain

type568
Member #8,381
March 2007
avatar

See if this version works better (attached).

Awesome, works fine.

Vanneto
Member #8,643
May 2007

In Allegro 5, which is faster, having a ALLEGRO_BITMAP represent the particle, or just drawing pixels? I am getting some slowdowns with over 1000 particles in the scene, so I'm just wondering.

In capitalist America bank robs you.

Trent Gamblin
Member #261
April 2000
avatar

If they're single pixels use an array of ALLEGRO_VERTEX (primitives addon) and al_draw_prim with the ALLEGRO_PRIM_POINT type.

Vanneto
Member #8,643
May 2007

This will be faster than using ALLEGRO_BITMAP's? Well, I'm going to try it, thanks for the tip.

In capitalist America bank robs you.

Trent Gamblin
Member #261
April 2000
avatar

Yes, it should be the fastest way to draw single pixels.

Vanneto
Member #8,643
May 2007

Well, while I brought this up, I noticed that the ALLEGRO_OPENGL driver is significantly slower at drawing many textures (1000) than the DIRECT3D driver... I updated my drivers to make sure they aren't to blame and the problem persists. Is this just how OpenGL works?

In capitalist America bank robs you.

GullRaDriel
Member #3,861
September 2003
avatar

It's also a matter of which OS you're using along OpenGL.

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!



Go to: