Cool Missile Trails

Blitz3D Forums/Blitz3D Programming/Cool Missile Trails

Buggy(Posted 2007) [#1]
Is there an easy way to make those cool, bloomy, missile trails that are so often seen in 2D space shooters without any userlibs, DLLs, or anything like that?

Example:

More importantly, is there an easy way to achieve this effect without using any 3D commands in Blitz3D? I'm creating a simple 2D shooter, and didn't want to have to use any 3D if possible.


_33(Posted 2007) [#2]
I's suggest using sprites.

Commands are; LoadSprite, RotateSprite, ScaleSprite, HandleSprite, SpriteViewMode

For each trail, you'd have multiple copies of the same sprite animation which does the trail, when the sprite animation finishes one cycle, then you would remove that sprite. Or, don't do animation and just scale the sprite smaller and when you reach a certain value, remove the end trail sprite.


Trader3564(Posted 2007) [#3]
i beleiver there is an example in the B3D folder of an plane flying in the desert with dudes running over the place. I guess that has exactly what you want.


IPete2(Posted 2007) [#4]
You should build a mini particle system for yourself, using either single surface techniques. There are plenty of examples in the code archives and free particle systems knocking about.

IPete2.


Matty(Posted 2007) [#5]
I think the others missed your statement 'i don't want to use any 3d commands at all'

If you are going to do glowy trails in 2d then to get that additive blend effect you will need to read pixels from the backbuffer and process them by adding the 'rocket trail' pixel color components to the backbuffer color components at that point and writing it to the backbuffer using writepixel.

In blitz3d this will be slow. If you want to do direct pixel access at high speed then blitzplus is much better. However - in most cases it is better to use the 3d approach nowadays - especially for something like this. This is possible in blitz3d, and is easy with something like nsprite or spritecandy. In blitzplus it will be fast enough as writepixel and readpixel are an order of magnitude faster under blitzplus than under blitz3d.


plash(Posted 2007) [#6]
B3d does not support alpha channels (right?), you can make custom alpha drawing functions, but it will be very slow.


MixailV(Posted 2007) [#7]
Heh, see FastImage - it's ultra fast 2D like BMax!


bytecode77(Posted 2007) [#8]
you have to use a particle system!
there are a few ones.
try the devil particle system on www.devil-engines.net


Buggy(Posted 2007) [#9]
I have some reluctance to use a 3D system. One of these days I need to get myself BlitzMax.

1) I'm much more comfortable programming in 2D.
2) The game is based around mouse movement, and my efforts to map the mouse to 3D as accurately as in 2D did not work out.


cyberyoyo(Posted 2007) [#10]
translucent additive particles.
If you want to do a game like that you'll have to use a particle system anyway.
It's not very difficult to create if you know how it works.
You don't need 3D for that, as long as you can display sprites, you can use them in a particle system.


Stevie G(Posted 2007) [#11]
.


Buggy(Posted 2007) [#12]
I prefer to code everything myself... and I've got a few 2D particle systems I can implement.

A big hindrance in me using 3D is mapping the mouse to 3D coords. When I can't do that, what's the use in using sprites? If I don't know where the mouse is, then I don't know where the player is, so I don't know where the player's trails are.

Thanks all.


Leto(Posted 2007) [#13]
It's simple to translate MouseX,MouseY to whatever your 3D scale is.

If you don't want do translate, one idea is to draw your 3D scene in a 1:1 pixel scale, meaning that if your window is 800px wide, create your scene as 800 units wide. Because the mouse still exists in two dimensions (MouseX,MouseY) there's no issue in translating that to "3D X,Y". That's how i've seen 2D-in-3D systems work.


Stevie G(Posted 2007) [#14]
@ Buggy,

Using 3d is much better for you here. Just use mousexspeed and mouseyspeed scaled by some factor and then movemouse to the middle of the viewport each frame.

Works well for me anyway.

Alternatively, here's a bit of code to for a 2d-in-3d GUI which works in all resolutions - you'll need your own cursor texture.



Stevie


Matty(Posted 2007) [#15]
Hi Buggy - have a look at nsprite2. It provides an entire commandset that is identical to the 2d drawing commands in blitz3d but uses hardware accelerated 3d. The only difference is the commands have a "ns_" prefix to them. or something like that. I bought a copy of it a while ago but haven't used it yet.


Buggy(Posted 2007) [#16]
Thanks all.

I will take some time off just to experiment with it being in 3D, and see if it is easy enough to code, with a big enough improvement.


Buggy(Posted 2007) [#17]
While I haven't actually done this in 3D (apparently I'm not a man of my word), I realized that 3D won't solve the problem of what I'm really trying to do.

I suppose I didn't really explain this, but I want it to be a continuous missile trail. I could, in 2D or 3D, create a trail image/sprite behind the missile each frame, but that would be lumpy when the missile's moving a lot each frame.

And while I do understand that I could create a lot of these, close together, to achieve the effect I'm looking for, it might slow down my game drastically when a bunch of missiles are onscreen, and I'm wondering if there's a simpler way to do this.

Since I'm using 2D, I suppose what I'm looking for is some sort of irregular polygon/rect command that can create filled rects that aren't composed of strictly horizontal and vertical lines. Short of that, I suppose I could simply create a bunch of lines instead.

To give you an idea:




cyberyoyo(Posted 2007) [#18]
And while I do understand that I could create a lot of these, close together, to achieve the effect I'm looking for, it might slow down my game drastically when a bunch of missiles are onscreen, and I'm wondering if there's a simpler way to do this.

That's the point of using Hardware accelerated 3D, with it you can send hundreds of sprites to the graphic card and making flashy games becomes very easy. I think most of the flashy games you can see nowadays use 3D rendering, if you don't want to use hardware accelerated 3D you'll be limited in the effects you can achieve.
You can't make simpler than that.


Buggy(Posted 2007) [#19]
So having 1000 sprites is like having 100 images? Ooh... that's tempting.