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!
Dustin Dettmer
Member #3,935
October 2003
avatar

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
Member #2,981
December 2002
avatar

bamccaig said:

I generally avoid binaries.

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

Jonatan Hedborg
Member #4,886
July 2004
avatar

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.

-------
Sweden: Free from the shackles of Democracy since 2008-06-18!

KnightWhoSaysNi
Member #7,339
June 2006
avatar

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

ixilom
Member #7,167
April 2006
avatar

I put my vote on Jonatan :)

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

Vanneto
Member #8,643
May 2007
avatar

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?

--
May you one day find Allah in your hearth and accept His Word as The Truth!

Jonatan Hedborg
Member #4,886
July 2004
avatar

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

-------
Sweden: Free from the shackles of Democracy since 2008-06-18!

ixilom
Member #7,167
April 2006
avatar

Votes ???

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

Jesse Lenney
Member #8,356
February 2007
avatar

1 for Ixilom

---
"No amount of prayer would have produced the computers you use to spread your nonsense." Arthur Kalliokoski

Vanneto
Member #8,643
May 2007
avatar

OK fixed the resolution to 1024x768.

--
May you one day find Allah in your hearth and accept His Word as The Truth!



Go to: