Let's have a (virtual) fireworks competition!
Jonatan Hedborg

Who can make the nicest looking fireworks? Deadline is 31st december, 23:59 GMT.

Any language, any library. Should be able to compile and run with minimal fuss, posting of pre-built binaries is encouraged. It should run for at about a minute, and be judged for that time.

After everyone has posted, we vote for which one we liked best (other than our own). Simple!

Anyone in? Suggestions for improvements?

CGamesPlay

Compile and run on Windows? Linux? OS X?

Jonatan Hedborg

I'm not going to tell people what to use, but obviously it's more fun if as many people as possible can compile it. If you make it harder to compile, less people will view it. Then it might be good to post several screenshots or a video of the fireworks in action :)

Steve Terry

Damn, if I only had time to compete I would.

KnightWhoSaysNi

I'm working on an allegro 4.4 opengl game framework type thing.

This would help / encourage me to work on the particle system aspect of it.

blargmob

Can we pre-compile a binary and just include the source?

Jonatan Hedborg

I'm working on an allegro 4.4 opengl game framework type thing.

This would help / encourage me to work on the particle system aspect of it.

Great!

blargmob said:

Can we pre-compile a binary and just include the source?

Sure, I can't see why not.

Damn, if I only had time to compete I would.

A shame. But if you get the time, it should probably not take too long to whip something up ;)

ixilom

I'll hack something with XNA :)

blargmob
ixilom said:

XNA

8-) ;D

type568

Nice idea, I'll maybe code up something..
However, topic starter.. Would be nice if you encourage us by giving up an example ;)

ImLeftFooted

Check out what I made! :o
{"name":"dogs+and+fireworks.jpg","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/d\/7\/d798566490103d72812529acaa259f1e.png","w":490,"h":490,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/d\/7\/d798566490103d72812529acaa259f1e"}dogs+and+fireworks.jpg

Jonatan Hedborg

I'm working on mine ;) I've still to decide what library to use. I don't really feel like installing allegro 4.9, what with all the libraries needed... And I might need decent blending. Any suggestions?

Check out what I made!

Purdy! Keep it up :D

type568

And I might need decent blending. Any suggestions?

No.. But my general direction of thoughts is recursion(fractals).

FMC

I'd be interested.
What is the current way to get additive blending with Allegro nowadays?

I used to use Fblend but i'm having a few problems making it work with 4.4.
Is allegroGl the only other way?

[edit]Same question as Jonatan, didn't see his last post.

ixilom

I'm already doing something horribly wrong with my particles in XNA, it chokes my pretty decent PC with ~200 particles :o

Jonatan Hedborg

How are you storing and creating them?

ixilom

Just a generic List<T>, no fancy pools or anything, but I might need to look into that anyway :P

Frank Drebin

Dustin: please attach at least an executable to join the competition...

and here comes my entry... {"name":"600091","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/3\/6\/36db28c50ea34922142402993d3d35d7.png","w":647,"h":513,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/3\/6\/36db28c50ea34922142402993d3d35d7"}600091
as long as noone else posts an executable the winner seems to be .... me ;D

[EDIT]
now the source is available (don't steel from it!!!)
in this improved version the rockets are fired automatically so you don't have to hit the space-key all the time...

type568

Nice, that's generally what I planned to do, putpixel() is it.
However, there are many things can be improved.. E.g. perhaps colors shouldn't just go black, but lose color(move to grayscale), at the time with losing brightness overall. In addition to gravity, there could be wind and air-drag force.
This one without fractals though, probably :D

Append: Frank, source please?

Timorg

I am in. :) It will give me something to do tonight when I am bored.

ixilom

Could someone help me out with something?

I'm having problems getting a velocity vector for my particles in an explosion that results in a "ring" in the sky.
Doing something like below is fine and dandy for your avarage explosion:

foreach(Particle p in m_particles)
{
p.Velocity = new Vector2(-(rand.NextDouble()),rand.NextDouble());
}

The problem is how to create those velocities whilst not accepting a minimum range.
Like 0.1f for X and 0.1f Y not being acceptable, however it should be possible to have 0.1f X but Y being 0.9f ... Does that make any sense?

I've been scratching my head for some time now and soon I'll probably start ripping hair >:(

Arthur Kalliokoski
ixilom said:

Like 0.1f for X and 0.1f Y not being acceptable

That would be perfectly acceptable if the sprite/spark thingee was almost directly approaching/receding to your line of sight (in 3d viewpoint). It's pretty neat to see a meteor do that (seems almost motionless).

Timorg

You could do something like...

#include <cmath>

VECTOR::VECTOR(const POLAR &v)
{
    _x = v.r * std::cos(v.t);
    _y = v.r * std::sin(v.t);
}

Where v.r is the velocity (radial length) and v.t is the angle (theta).

That way they all have the same outwards speed, but each can have a different angles.

ixilom

Timorg, thanks!

I've been too focused on vectors that I totally neglected sin/cos ... d'oh ::)

Arthur Kalliokoski

If they all had the same outward speeds, you'd wind up with a ring again. Unless you're actually using a Z component of course.

Look closely:

{"name":"China_Kyling_Fireworks_Display_Shell.jpg","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/c\/7\/c77bbc14d1cbe12137ac4c31de4dad04.gif","w":400,"h":400,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/c\/7\/c77bbc14d1cbe12137ac4c31de4dad04"}China_Kyling_Fireworks_Display_Shell.jpg

ixilom

If they all had the same outward speeds, you'd wind up with a ring again.

It is the ring effect I'm trying to make :P

Arthur Kalliokoski

So use do_circle() and only draw every N'th pixel.

ixilom

Not using Allegro :P I'm doing this with XNA framework :)

Arthur Kalliokoski

So use Timorgs idea, but I'd think it'd look pretty lame...

Slartibartfast

This is what mine looks like.
{"name":"600098","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/2\/3\/23cccd0089db987103d62c6fd5565b54.png","w":650,"h":509,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/2\/3\/23cccd0089db987103d62c6fd5565b54"}600098
This is about as much as I can do without it stopping being exciting.
But it has all those configurable parameters!
Source attached, includes a crappy makefile.
The code is terribly ugly.
If anyone is bored feel free to suggest a better general approach/design I should have taken in the first place to avoid having such an ugly POS.

(Allegro 4.9.16)

EDIT: uploaded improved Line.cpp (increased line thickness to make it stand out more)

blargmob

Here's my piece of shit entry. The code is horribly ugly and there is a massive memory leak which I am far too lazy to fix. Hit the spacebar to launch a firework.

{"name":"600102","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/2\/3\/23b295132dbb118c793379186ab5627a.png","w":816,"h":636,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/2\/3\/23b295132dbb118c793379186ab5627a"}600102

type568

blargmob: You are evil. Very. Crashed on launch.

Felix-The-Ghost

You know what...I think I'll try this.

blargmob
type568 said:

blargmob: You are evil. Very. Crashed on launch.

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...

LennyLen

Here's mine:

{"name":"600105","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/7\/c\/7c57afb05efd3f893e907a004c1e28cf.png","w":758,"h":626,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/7\/c\/7c57afb05efd3f893e907a004c1e28cf"}600105

edit: Oops, forgot the source

blargmob

^^ lulz

Jonatan Hedborg
LennyLen said:

Here's mine:

Weak :'(

Vanneto

Here is my current version...

{"name":"600107","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/5\/2\/529e230857efa31da0d1c5649e24f22c.png","w":825,"h":643,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/5\/2\/529e230857efa31da0d1c5649e24f22c"}600107

Jonatan Hedborg

Wow, lots more participants than I expected! Keep it up everyone! :D

Except LennyLen. You killed my soul :(

Timorg

Except LennyLen. You killed my soul :(

Perhaps you should look at the source before it is too late to resuscitate said soul.

Jonatan Hedborg

I did.

That's what killed it.

Timorg

Oh I thought you meant that your soul died, as there was no way you could compete with the entry.

LennyLen

If I can get all the C# programming tasks I assigned myself for the day finished before I have to leave for work this evening, I'll have a go at a real entry.

But hey, at least it was nice[1], tidy, code for two minutes worth of coding. ;)

References

  1. except for checking whether the image loaded successfully
Dario ff

{"name":"600108","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/6\/5\/65d1dbee6fb4379c961fabc16732ac4a.jpg","w":793,"h":612,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/6\/5\/65d1dbee6fb4379c961fabc16732ac4a"}600108

You could've photoshopped it a bit, apart from resizing :P

LennyLen
dario ff said:

You could've photoshopped it a bit, apart from resizing

Just figuring out how to re-tint the image in PhotoShop would have taken me longer than it took to code the entire thing. ;)

Dario ff

CTRL+U - Hue, Colorize
CTRL+T - Transform

Now you don't have to figure it out :)

LennyLen

Perhaps I should also have mentioned that I don't have PhotoShop. ;)

Don Freeman

LennyLen: I give you points...that made me laugh. :)

ImLeftFooted

Hey look someone already posted my image on google image search!
65d1dbee6fb4379c961fabc16732ac4a-240.jpg

Trent Gamblin

Here's my entry

{"name":"600113","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/2\/4\/24c62b7bbcfa2df048e4c45db4fa069a.jpg","w":806,"h":625,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/2\/4\/24c62b7bbcfa2df048e4c45db4fa069a"}600113

LennyLen

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

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
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

Still got a few days to go ;)

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

Mark Oates

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

Ahahaha!

ixilom

Just a preview :P

video

LennyLen

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

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

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

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

Doubt it.

Trent Gamblin

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

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

Trent Gamblin

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

Here's a video

video

BAF

Neat effect.

type568

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
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

nm

type568

See if this version works better (attached).

Awesome, works fine.

Vanneto

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.

Trent Gamblin

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

Vanneto

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

Trent Gamblin

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

Vanneto

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?

GullRaDriel

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

Trent Gamblin

OpenGL and Direct3D are typically about the same... but in some cases D3D can be slower (rarely) and so can OpenGL (more often) on Windows depending on the system.

Vanneto

I just noticed OpenGL is a bit faster at rendering using the primitivesa addon. Looks like OpenGL doesn't like a lot of textures but loves vertices, just a hunch. Anyway, works a lot better now even with 5000 particles, thank Trent.

Jonatan Hedborg

Latest version uploaded! Should not crash, regardless of particle count... Added some statistics (fps and active particles), and of course the motion blur :)

I'm pretty pleased at how I ended up solving the particle handling... It should be very fast and still pretty flexible.

Do you guys get any slowdowns?

blargmob

Jonatan, that was beautiful!

Vanneto

Here is my current version. The colors/speed/size are all customizable, currently it uses a white explosion. If something doesn't work (dll missing) please tell.

Also, how does it work with a lot of particles? (click very fast to produce them)

Jonatan Hedborg

liballegro_image-4.9.15.dll is missing (at least).

ixilom

Jonatan, that is pretty slick :)

I think I'll have to re-code my "blur" effect, I'm pumping out too much particles just to create that effect. Although I am doing 14160 of them without any noticeable slowdown ... hmm.

I even built a small editor for the launch sequence with all the needed parameters ;D
{"name":"600139","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/8\/6\/86f80cebcb48c490e74f81d60d257062.png","w":968,"h":413,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/8\/6\/86f80cebcb48c490e74f81d60d257062"}600139

Vanneto

I don't even link with allegro_image, so don't know why it complains about that. How about now?

ixilom

Works fine here Vanetto :)
I don't have anything Allegro related installed, so it is safe to assume all the needed DLL files are now included ;)

Runs smoothly until I frantically press the mousebuttons to get 25K particles, it then drops down to ~30 FPS :) (~60 FPS with 14K)

I have for now "composed" about 30 seconds fireworks-frenzy-show with my editor (and cheating with notepad), another 30 to go :P

Archon

Could you upload some screenshots for each of your updates for those that don't want to download every release or if they don't have OpenLayer?

Jonatan Hedborg

Some screenshots!

{"name":"600144","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/f\/3\/f333ff3f5761cf8c14a318526d37a08a.jpg","w":795,"h":595,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/f\/3\/f333ff3f5761cf8c14a318526d37a08a"}600144
{"name":"600145","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/3\/9\/39f5b2cef77f9449ba79c7cdc5c22aa6.jpg","w":792,"h":595,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/3\/9\/39f5b2cef77f9449ba79c7cdc5c22aa6"}600145
{"name":"600146","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/b\/c\/bcd513012e90348d5bad15be5dda152a.jpg","w":798,"h":597,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/b\/c\/bcd513012e90348d5bad15be5dda152a"}600146

LennyLen

I improved mine a little bit. It has regulated timing now, and continues on indefinitely until you press ESC. I'm quite happy with how it fast it runs, since it's my first attempt at particles, and it's not using any hardware acceleration.

The source and a Windows binary are attached. I've also made another video, though it's at a very low framerate, so doesn't look that great.

video

FMC

Lenny, i think it would look nicer if you slowed it down a bit, it's too fast right now (for my eyes at least!). :)

(i'll soon upload my entry)

Thomas Fjellstrom

Its also far too uniform and ring shaped.

ixilom

[Edit]
Eh, wasn't funny... I quoted wrong person thinking it was someone else.

;D

FMC

It is done!

Here it is: http://www.allegro.cc/files/attachment/600153 (source + binary + dll + data)

It's scripted and you WILL KNOW when it ends, please don't loose the GRAN FINALE ;)
There are a few pauses during the act, but they are just that, pauses.

A few things:
-Nine different (more or less) fireworks in display for a minute or so with much randomness and scripted launching sequence.
-The source is a huge hack, avoid it if possible!
-The program will use your desktop resolution, scaling itself, but best results will appear at 1680x1050. :)

-If the program isn't smooth i reccomend lowering these two:

#define MINE_PARTS 350
#define ROCKET_PARTS 400

-Screenshot of near-Finale:

{"name":"600154","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/c\/f\/cff179deb16a8270bb941fd05ea246da.jpg","w":840,"h":525,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/c\/f\/cff179deb16a8270bb941fd05ea246da"}600154

Please let me know if it runs! :)

ixilom
FMC said:

Please let me know if it runs! :)

Runs fine on 1440x900 ... and looking good :)

LennyLen
FMC said:

Lenny, i think it would look nicer if you slowed it down a bit, it's too fast right now (for my eyes at least!).

I just checked the YouTube video, and it seems to be running slightly fast. It also seems to have dropped a few more frames than the version I uploaded.

Its also far too uniform and ring shaped.

I've attached a version with more randomness in the particle's velocities, so it makes it less evenly distributed.

edit:

FMC said:

Please let me know if it runs!

It ran very nicely here at 1680x1050.

FMC
ixilom said:

Runs fine on 1440x900 ... and looking good

Great news... waiting for your entry, video looked nice.

LennyLen said:

It ran very nicely here at 1680x1050.

Good!
Your entry is still a little too fast for me, but maybe it's just me. :)

Cookies to Jonatan who came up with an idea that gave me an excuse to code something (it had been ages!) :)

blargmob: your program crashes on start for me :(

ixilom

Finito

I'm finally done. YAY!

Jibberish

It was fun to make, even if I over engineered it (like I always do :P)
Seems everyone else has been able to cram everything in a neat and tight package (like main.c), whilst I went apeshit and made a shitload of files :P

The files

Source
Binary

Getting it to work

The source was built with Visual Studio, .NET 3.5 and XNA 3.1, so you gonna need those.
The binary most likely needs some parts of XNA 3.1.

Youtube

If no one for some reason is able to run/build my contribution, there is always youtube :)

video

Thanks

Thank you Allegro.cc and members, not just for this thread, but all the help and stupid flamewars we had this year. Lets not stop next year ;D

Final words

I'm of to bed, wont be online later today (it is 3am now) as I'm going over to my sisters place to "celebrate" the new year when I wake up.

I wish you all a happy 2010!

Vote for me, or else! ;)

bamccaig

I'm a little drunk. Anyway, I've been too exhausted to attempt to build any entries, and I generally avoid binaries. From the YouTube submissions I've seen, ixilom's entry seems very well assembled. :D I am drunk so I don't really remember previous posts as well as I'd like to, but it does strike me as the most detailed[1]. :D

References

  1. Though honorable mentions go to LennyLen for his brilliant fake, which I thought was sooooo awesome until I realized it was a fake. ;D
ImLeftFooted

I vote for mine.

Jonatan Hedborg

This is probably the final version, no more time to work on it. Overall, I'm pretty pleased with it! Could use a bit more fireworks (about 38 seconds now), and a few more different types... And better polish obviously.

Great work everyone, I'm glad this idea took off :)

{"name":"600163","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/c\/4\/c478ec4453ba6c3b48bc4b8752e98a62.jpg","w":794,"h":592,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/c\/4\/c478ec4453ba6c3b48bc4b8752e98a62"}600163

{"name":"600165","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/e\/c\/ec5088d2eedcac009df82c1f07c8e315.jpg","w":797,"h":601,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/e\/c\/ec5088d2eedcac009df82c1f07c8e315"}600165

EDIT: I do have a strange problem; I'm using an STL vector for my storage, but the program crashes whenever it grows in size (so I have to reserve(some larger number) in order for it to run)... I cant figure out why. The relevant code should be in ParticleHandler.cpp if anyone wants to have a look at it.

ImLeftFooted
void ParticleHandler::removeParticle(int index) {

    particleArray[index] = particleArray[particleArray.size()-1];

    particleArray.pop_back();

}

Should be

void ParticleHandler::removeParticle(int index) {

    if(index != particleArray.size() - 1)
        particleArray[index] = particleArray[particleArray.size()-1];

    particleArray.pop_back();

}

Jonatan Hedborg

Hmm. While that's correct (thanks for catching it!), it didn't actually solve the problem :/

I've been experimenting with adding a bit of bloom to it btw... Just drawing the particle buffer to 5 different bloom buffers (that are 1/4 of screen size), each with a 0.5 pixel offset (and one at 0,0) and then drawing those to the screen at full size.

It looks pretty good, but I think i might need to tweek a few color values around (things get a bit too white otherwise).

EDIT; also, 27k particles doesent even touch the FPS on my computer :) Pretty sweet if I may say so myself.

Happy new years everyone!

ImLeftFooted

The problem is likely a memory error elsewhere in your code. A few tips... You should use a deque as it is more optimized for removing and inserting on the ends.

Use .at() instead of [] notation. This will throw exceptions which are good for debugging. In release mode you can use [] again resulting in a small optimization.

Here is a way to write two of your functions a bit more clearly / cleanly.

Particle *ParticleHandler::getNewParticle() {

    particleArray.push_back(Particle());

    return &particleArray.back();
}

void ParticleHandler::removeParticle(int index) {

    if(index < particleArray.size() - 1)
        particleArray.at(index) = particleArray.back();

    particleArray.pop_back();
}

BAF
bamccaig said:

I generally avoid binaries.

Sounds like you've got a case of chronic gentooitis.

Jonatan Hedborg

My vote goes for ixilom! Very pretty and ambitious.

I managed to track down that nasty little memory bug I had. I was holding on to a pointer to an object in a vector while I was adding stuff to the vector, so that when it got resized, the pointer was left dangling... silly.

Here is the latest (and last, this is getting silly now ;)) version if anyone is interested :) It now has a fairly pretty "glow"-effect, motion blur, cheap reflective water (just a mirrored/stretched background) and a cheesy backdrop :D

Plenty of screenshots attached.

EDIT: I wonder if it's more effecient to store the particles as pointers in the vector, and take the cache hits or just do as I do now and take the heavier moving of memory instead.

KnightWhoSaysNi

I couldn't get any pretty firework particle explosions but I was able to make other neat particle effects at least.

ixilom

I put my vote on Jonatan :)

Vanneto

I added rockets, it was quick and dirty actually. I'm not proud of the code, just the results, I think it looks quite pretty. I'm looking into optimizing it and making it even more optically pleasing.

Any suggestions on what do add?

I attached the source too, if anyone will look at it, ignore programme.cpp/.hpp. Is there any way to optimize the loops in explosion.cpp and main.cpp?

Jonatan Hedborg

Resolution fail. Cant even see the top of the window (and I'm at 1280*1024, which afaik, is not considered tiny).

ixilom

Votes ???

blargmob

1 for Ixilom

Vanneto

OK fixed the resolution to 1024x768.

Thread #602640. Printed from Allegro.cc