Trying to simulate the flamethrower from GTA2

Started by
12 comments, last by Norman Barrows 10 years, 6 months ago

Delete all OpenGL code (OpenGL is used only for drawing), math is math

commented code:

// particles.rotate = particles.rotate +1;
/*if (GetTickCount()-particles.frametime >= sprite.speed ) {
particles.frametime = GetTickCount();

//particles.frame = particles.frame + 1; odkomentowac
//if (particles.frame > high(sprite.animtextures) )then begin particles.frame := 0; particles.draw := false; end; odkomenotwac

}

*/

is for animating sprites (simple array of textures that index is changed


t3dpoint __fastcall vectors_frontadd(t3dpoint v1, t3dpoint v2) //plaszczyzna XY
{
t3dpoint result;
result.x = v1.x+v2.x;
result.y = v1.y-v2.y;
result.z = v1.z-v2.z;

return result;
}
 

rest is just math

oh and glop angle is actually a 'heading' angle. / heading here is up down angle

Advertisement

hi.

I just a a quick look but I think its your heading for the particles are all using the current units facing direction.

So all your particles need to have there own heading vector and that should do the trick.

rolleyes.gif

You can do this by simply using a bunch of fire particles. Your player will have a particle emitter positioned a set distance away from the center of the player and based on the players orientation. There are a few things you'll want to think about when setting the properties for your emitter:
-The frequency/rate of particle emission

-The initial velocity of a particle (which should also factor in the current velocity of the emitter)

-The initial size of a particle

-etc. etc.

For your flame thrower, all you'd really have to do is create a flame particle every fraction of a second, give it an initial position and an initial velocity, and then let your particle system update all of the particles in its list of active particles. Once a particle has been emitted from the emitter, its position and velocity should be completely independent of the emitter.

It looks like the GTA2 flame thrower is shooting out flame particles at a high rate and the lifespan of each particle is quite short. I predict that if your character is initially stationary and shooting flames, then the distance of the farthest flame from the player should be at its standard length (let's call it 1 Flame Length). I also predict that if your character suddenly starts moving towards the direction of flames, the flame length should shorten for a brief period since the player is moving with the slower moving flame particles and the flame length may be 0.8 units of flame length until the first flame emitted with the player velocity reaches its lifespan. If the player moves backwards, then we should expect the flame length to extend (1.2 flame length?) for a brief moment (and we may even expect to see gaps between particles if the emitter frequency is too low).

Anyways, here are a few things you can try:
-You don't need to store the angle on a flame particle. Give it a velocity instead. Velocity is a 2D or 3D vector. The orientation of the vector contains the direction of movement. The magnitude of the velocity vector contains the speed. Every frame, all you have to do is add the velocity vector to the position coordinate.
-If you use spherical fire sprites, you don't have to rotate your flames. If you simply must use non-spherical sprites, you can still get the direction of travel by normalizing your velocity vector and using those normalized values to rotate your sprite. A normalized 2D velocity vector already contains [Cos(theta), Sin(theta)]
-I don't know if you're doing it already, but I'd recommend using a memory pool for your particles (you don't want to allocate and deallocate memory for each particle each time its created and dies).
-If you're feeling crazy, you can also store an "Acceleration" value in a particle. If you remember your calculus and physics, velocity is the change in position over time. Accelleration is the change in velocity over time. (And surge is the change in accelleration over time, such as a gas pedal on a car). For each frame and for every active particle, you'd do: Velocity += Accelleration; Position += Velocity; If you set a small negative number to the accelleration, your particle will gradually slow down as it travels.

+1 what slayemin said.

and don't forget to change the sprite based on particle age. if you look at the GTA2 screen shots, the particles near the flamethrower are white-yellow, and change to orange-red over time (as they move farther away).

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

This topic is closed to new replies.

Advertisement