explosions code WANTED
William Labbett

hi chaps

i'm hoping someone out there has got some simple code using allegro functions for doing explosions.

I just want it for the opening of my game - lots of explosions then the game's opening picture fading through.

I will include thanks to the person in the credits of my game, but there'll be no other reward - my game'll be freeware anyway!

Thanks for any help.

Inphernic

Either use an explosion animation or particles. Or both. The code itself is trivial, so why not have a shot at it yourself? You'll learn better that way, too.

anto80

What do you mean by explosion?

IHMO i can see 2 types of 'explosion'
1) particle-like explosions

1typedef struct Particle{
2 float x, y; // instant pos
3 float dx, dy; // instant vector
4 float ay; // acceleration (gravity)
5}Particle;
6 
7void move_particle(Particle* p){
8 p->x += p->dx;
9 p->y += p->dy;
10 p->dy += p->ay;
11}
12 
13void spawn_particles(ParticleList* pl, int n, float x, float y){
14 int i;
15 Particle p;
16 for(i=0; i<n; i++){
17 p.set(x + 10.0*cos(i*2*M_PI/n), // x
18 y + 10.0*sin(i*2*M_PI/n), // y
19 1.0*cos(i*2*M_PI/n), // dx
20 1.0*sin(i*2*M_PI/n), // dy
21 0.8); // ay
22 pl->addParticle(&p);
23 }
24}

2) sprite explosions
Create a dozen of explosion sprite to do an animation.
Display them in this order.
If you want it to look more like a real explosion, use transparency.
If you want it to look even more like a real explosion, use smoke (for example smoke sprites, like your explosion sprites).
If you want it to look further more like a real explosion, combine this with particles (1).

That's what i do.
I hope it helps.

[edit]damn!! Inphernic beat me !! :P

A J

do some particles, with trails (x-fade the previous screen with the current one).
or just get a FLIC of an explosion and play that.

William Labbett

big Thank-you to Anto80

anto80

You're welcome!!

It's very kind of you to give my name in your credits, but i can't accept because as Inphernic said, the code is so trivial we can't tell it belongs to anyone...

Thanks anyway.

If you still want to put my name on it, i wouldn't say no! ;D

And please tell us about your project revision, so that we can see the result of these great particles! 8-)

OICW

The good particle explosion system is in demo.c I think it pregenerates some number of frames of an explosion using particles and then it draws it on screen when needed.

ReyBrujo

Shawn wrote EGG, a program to prerender explosions. You should check it out.

Avenger

EGG was not only for explosions, but other particle related things too (Spaceship engine, sparks, etc.)

Thread #415131. Printed from Allegro.cc