Jump to content
  • Advertisement
Sign in to follow this  
martini1

Exhaust flames help???

This topic is 3498 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to shoot flames out of the rear of an almost circular, rotating spaceship. I'm using the following code at present, which kind of works, but leaves a trailing flame. I'm trying to get a flame that shoots directly out of the rear in a straight line rather than trailing as the ship rotates. An array of explosions, reducing in size is used to form the flame. Any help or tips??? void Spaceship::ExhaustFlame(void) { Vector2D pos = v2dPosition; Vector2D vel = Vector2D(sin(dAngle),cos(dAngle)); vel = -v2dVelocity * 8; //Minus operator for opposite direction int size = 25; for(int i = 0; i < 10; i++) { pos += vel * pTheGameTimer->mdFrameTime; size -= 4; //Decrement animation size pExplosion->InitObject(pos, size, 0.7); pExplosion->MoveObject(); pExplosion->DrawObject(); } }

Share this post


Link to post
Share on other sites
Advertisement
looks like your using some form of particles, not a very good for what you want ( as you can probably tell ). Why not just have the flame be an animation of the ship? as i understand, you dont want the flame to do anything "dynamic" so this should be an easy way forward ( unless your ships flames a ridiculously larger than that the ship )..

Share this post


Link to post
Share on other sites
I assume you have a particle like this:

(p-code)
class Particle {
Vector position;
float time;
}


But to get flames as you want, you could replace it with:

class ExhaustParticle {
const Ship &ship;
float z;
}


We assume that Ship has a method to get the direction and the position, like this:
Vector Ship::getForwardDirection () const {
return direction;
}
Vector Ship::getPosition () const {
return position;
}


Then, to create a new Particle, we'd go with this constructor:
ExhaustParticle::ExhaustParticle (const Ship &ship_, float z_)
: ship (ship_), z(z_)
{
}


After all, you want to draw the particle, so we need to calculate the position. This would go like that:
Vector ExhaustParticle::getPosition () const {
return ship.getPosition() + ship.getForwardDirection() * z_;
}


Negative values for d would yield a position behind the ship's center.


Surely this is rather trivial, but to give you just the idea. You could end up with a solution where you replace ExhaustParticle::z of type float with a full vector (let's call it v), and then your ExhaustParticle::getPosition() would look like:

Vector ExhaustParticle::getPosition () const {
return ship.getPosition()
+ ship.getStrafeDirection() * v.x
+ ship.getUpDirection() * v.y
+ ship.getForwardDirection() * v.z
;
}


The key in this all is the member reference ExhaustParticle::ship. You could also use a pointer or a shared_ptr<>, of course.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!