Engine Trails

I was wondering... how I would implement a trail of exhaust coming out of a simulated 'engine.' I've seen some other (albeit older) games and watched their exaust; some use crosses or circles that are 'layed out' behind the engine area, and fade out with time. If anyone here has done this before, or something similar, it would be great if you could show me how it works, thanks for any effort you put in this.

[423 byte] By [Sentient-Absencea] at [2007-10-1 2:32:34]
# 1

this may not be the best way however it does work

keep an array of x and y the size is the number of tray sprites

// 10 tray sprites

int x[]=new int[10];

int y[]=new int[10];

sprite 0 is the brightest and sprite 9 is the darkest. everyframe move the coords one space in the array;

e.g.:

x[10]=x[9]

x[9]=x[8]

...

x[2]=x[1]

x[1]=x[0]

x[0]=current X Position for the engine

do the same thing with Y and place sprites 0 to 9 at the coords specified in the array

that should do it

must41a at 2007-7-8 11:40:22 > top of Java-index,Other Topics,Java Game Development...
# 2
what you are looking for is a "Particle System". They are very powerful things if implemented correctly, smoke, fire, sparks, the lot!Just google for "Particle System Source + java" and you should get tons!-Digiwired
digiwireda at 2007-7-8 11:40:22 > top of Java-index,Other Topics,Java Game Development...
# 3
Very interesting. Thank you very much =)
Sentient-Absencea at 2007-7-8 11:40:22 > top of Java-index,Other Topics,Java Game Development...
# 4
I can definitely use this particle system, but I was wondering if you knew also of a way where I can make the trails look more like a steady stream, instead of separate particles? such as a missle trail, or those snipershot trails like in 'Halo' ? Or do those use particles too?
Sentient-Absencea at 2007-7-8 11:40:22 > top of Java-index,Other Topics,Java Game Development...
# 5
Those are also particles. Do you know the smoke and fire in Call of Duty? thats particles. Everything thats an effect (well, mostly) is due to a particle system of some sort. Even the gun fires in most FPS, those are particle systems too...-Digiwired
digiwireda at 2007-7-8 11:40:22 > top of Java-index,Other Topics,Java Game Development...
# 6

Thx, digi... I guess I should start working on a particle system of my own. I've looked into some of the ones I got from 'googling' the keywords, but I still have to look further into it.

Btw, do you know how to rotate the camera around a certain point? I've been having trouble trying to implement that as well. =\

Sentient-Absencea at 2007-7-8 11:40:22 > top of Java-index,Other Topics,Java Game Development...
# 7

as a matter of fact...i do! :D

What you need to learn my friend is whats called "Spherical Coordinates". Google for that and you get some equations. Il save you the trouble and write them here now:

x = P * Cos (Phi);

y = P * Sin(Theta) * cos(Phi);

And thats how you rotate. You need to alter the Theta and Phi and P (rho) And your basically done. Set that as the position of the camera. Then you need to do some simple trig to find out the angle between the camera and the object ande point it towards that.

Btw, i know this works in 3D, not sure in 2D. I presumed your doing it in 2d.

-Digiwired

digiwireda at 2007-7-8 11:40:22 > top of Java-index,Other Topics,Java Game Development...
# 8

as a matter of fact...i do! :D

What you need to learn my friend is whats called "Spherical Coordinates". Google for that and you get some equations. Il save you the trouble and write them here now:

x = P * Cos (Phi);

y = P * Sin(Theta) * cos(Phi);

And thats how you rotate. You need to alter the Theta and Phi and P (rho) And your basically done. Set that as the position of the camera. Then you need to do some simple trig to find out the angle between the camera and the object ande point it towards that.

Btw, i know this works in 3D, not sure in 2D. I presumed your doing it in 2d.

-Digiwired

digiwireda at 2007-7-8 11:40:22 > top of Java-index,Other Topics,Java Game Development...
# 9
No worries, its 3D alright. Tyvm for the equations =)
Sentient-Absencea at 2007-7-8 11:40:22 > top of Java-index,Other Topics,Java Game Development...
# 10

I've got this from MathWorld, in the article for Spherical Coords.

x= rCos(theta)Sin(phi)

y= rSin(theta)Sin(phi)

z= rCos(phi)

In the site, there's all this matrix and vector *junk.* I know it's not useless stuff, but I won't necessarily need it at this moment right? I really don't want to learn that stuff. Details about matricies, all that.

So, just use these equations and I'm set, right? hopefully...

Sentient-Absencea at 2007-7-8 11:40:22 > top of Java-index,Other Topics,Java Game Development...
# 11

well, you will need matrices for rotation.

What these equations will give you is a position, not a rotation. So you will need to do some basic trig functions to direct the camera towards the desired object. OpenGL interfaces with matrices for rotation, and naturally, you will need to do your rotation in matrices. Or learn quaternions, which ever :)

Btw, are you using a specific engine? or building one from scratch?

-Digiwired

digiwireda at 2007-7-8 11:40:22 > top of Java-index,Other Topics,Java Game Development...
# 12
I'm making one from scratch =\Noo not matricies noo.... I really don't have much of an idea of what quaternions are.. I'm a math/gameprogramming newbie =( The article at MathWorld implicitly implies (to me, of course)that matricies are involved anyway. Is that right?
Sentient-Absencea at 2007-7-8 11:40:22 > top of Java-index,Other Topics,Java Game Development...
# 13

matrices are involved everywhere :)

Scary thought isnt? But seriously, once you get used to them, how they work, they are just like 1+ 1 = 2.

They are simple, trust me, just grab a book and go for it. I dont have any recomndations to be honest, because i learnt from the internet, but thats just me. Books are great!

-Digiwired

digiwireda at 2007-7-8 11:40:22 > top of Java-index,Other Topics,Java Game Development...
# 14
> matrices are involved everywhere :)The matrix is everywhere.
JN_a at 2007-7-8 11:40:22 > top of Java-index,Other Topics,Java Game Development...