#### Archived

This topic is now archived and is closed to further replies.

# how do you make those particles move in patterns?

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

## Recommended Posts

hello, like for example move in a letter ''S'' or ''W'' pattern or just about to move in any way you want, just like how the space ship move in a space shooter game, many thanks,

##### Share on other sites
Usually for special effect like that you hardcode in a pattern that particles move along. Another method, if you just want to make an S or W is to add a bunch of line emitters in the shape of your patter. And still a third, although somewhat difficult way to do things is to have some kind of invisible gravity volume in space that affects the movement of particles. My engine does not support those at this time. See my engine here

(I never miss a chance to show off my work

Gamedev for learning.
libGDN for putting it all together.

##### Share on other sites
An S pattern can be formed by a sinusoidal function like, for instance, sine!

A W pattern can be formed by Sin[sup]-1[/sup](sin x) ... (inverse Sin of (sin x))

(Of course you would need to restrict the domains of these functions, else they will keep going on for ever and ever, due to their inherent cyclic nature)

There is probably some mathematical way to describe any path you could think of, and if mathematics fails you (heaven forbid!) then you can always just hard code it, as CpMan suggested.

##### Share on other sites
no hard code plz, it''s not the most intuitive of all,

CpMan: yepz i already saw your work on your post at the dx forum, could you tell me how you did the letter M or what are those shapes something functions are for so it''ll be easier for me to understand your code?

i think all these is just a matter of changing the velocity and we can make ''all'' kinds of movements we want..., but still very vague for me,

thnaks,

##### Share on other sites
I dont know whether u are asking for this or not... so i''m just assuming.

create a texture [ preferably a bmp pic ] with a letter ''W'' written on it and the rest part black. Now load the texture in GL_RGBA format and assign alpha as 0 wherever there are "black" pixel 255 otherwise.

now render the rect with the texturing by enabling GL_DEPTH_TEST and with glAlphaFunc(GL_GREATER,0);

To rotate and move the letter, all u have to do is aply transformations on the rect only, just as u would do with any other geom figures

Is that what u were looking for ?

##### Share on other sites
uh... no?

say in a space shooter game, the enemy ship moves in a pattern how do you imitate/create those patterns..,

##### Share on other sites
Define a few points, say, for the letter ''W'', you define 5 points. Now, you write some function to simulate natural behaviour to follow the points in order, from point #0 to point #1, then point #2 etc. The function can depend on environment, speed, direction or even random numbers Trick around a little, we all need new ideas.

##### Share on other sites
To get any pattern you want...

Sounds awfully like a fourier transform! I''ve only had 4 weeks of lectures on them so far though so asking me to produce maths would be quite tricky :-)

However to get a nice representation of the pattern would take a lot of processing (tens, hundreds or even thousands of sines/cosines).

You could pregenerate the path by sampling the transform every so far along but then you could always just hardcode the path instead and interpolate which will be a lot *lot* less intensive.

Anyway my 2 pence :-)

-Meto

##### Share on other sites
hiya,

well i guess there''s not much to making patterns other than interpolating between waypoints, but i''d still like to hear suggestions though,

##### Share on other sites
Rather than using repeating patterns, have you considered using flocking of some sort? Look into Craig Reynold''s Steering behaviors (homefully I remembered the name correctly).

If you don''t want enemy spaceships to stick together in a flock, maybe you could try just a random wandering behavior. Wandering is simple.

Each particle is always moving forward at a constant speed. It can steer left, right, up, and down. For simplicity, I''ll stick to the 2d case and just use left and right. Now, take a single particle. Imagine that a random angle, alpha, is associated with it. The particle is oriented at an angle theta, and can turn at a specific speed. Every timestep, it turns, bringing theta closer to alpha. But here''s the catch: every timestep, a small random amount is added to or subtracted from alpha. This results in a wandering behavior which may be useful.

1. 1
Rutin
42
2. 2
3. 3
4. 4
5. 5

• 18
• 20
• 14
• 14
• 9
• ### Forum Statistics

• Total Topics
633377
• Total Posts
3011565
• ### Who's Online (See full list)

There are no registered users currently online

×

## Important Information

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!