Simultaneous Actor Spawning and Particle Engine?

NessusXVINessusXVI Member Posts: 6
edited November -1 in Working with GS (Mac)
I'm working on a Space Invaders style game, and I find myself in need of a few effects. First, I need to populate the entire screen with stars at random position and moving at random speeds towards the bottom of the screen. My first thought was to use particles, however I like my stars to twinkle, and I could find no way to randomly vary the color of particles over each particle's lifetime. I eventually resolved to use two hundred animated actors instead. Before you say anything, yes, the game is still running smoothly. However, for the life of me, I cannot find a behavior or set of behaviors for spawning large numbers of actors SIMULTANEOUSLY. If I can't spawn actors simultaneously, I'll need to obscure the star field from the player until it is set up. I can do this with an additional fake loading screen, but I would rather not.

Second, I need to create explosions: large numbers of particle spawned simultaneously, but each moving in a random direction. For the life of me, I cannot get the particles to spawn with different trajectories. I only ever see one particle, which I assume must have the 99 other particles hiding directly beneath it. Rapidly rotating the emitter actor only gives me five or six individually visible particles at most. There must be a way to emit hundreds of particles in all directions, simultaneously.

Any insights or suggestions would be greatly appreciated. I did a number of forum searches beforehand, but the results were unsatisfactory.

Comments

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    Hi NessuXV; particles would be much better to look at I'm thinking, and certainly less hassle than 200 actors, for certain, placed or spawned; using just one actor for particles...easier to reuse as well on other scenes. Although having said that, I'm not certain there is a way to have them twinkle in the particles behaviour as you want. But...perhaps try the following; none twinkle as such but do appear to in their own way as the size changes/stars delete. Especially as this is only a background, maybe you'll change your mind about the twinkling.... (it might distract the player anyway from playing the actual game).

    Put your particle actor approx. 380 Y (if for iPhone) i.e outside of the screen. In the particles behaviour, try the following (obviously change a few parameters as an experiment to see what you like best):

    Spawn Rate: 200 Particle Startup: 2 Particle Lifetime 8

    Vel/Pos: Direction: random(221,330) relative to actor Speed 50, affected by gravity on

    Size 15 Size changes to 2 Duration 4 secs

    Color: experiment with blending options maybe

    Rotation initial 60 Angular Vel. 140

    As for moving in random directions for your explosions, in the Velocity/Position tab, put Direction as random(0,360) (or technically, random(0,359) but both work the same...) and experiment with that. Hope that helps. :-)

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • msonesmsones Inactive, Chef Emeritus Posts: 75
    One possible way to make the stars twinkle would be to put an actor over them (the entire screen, basically), and change the alpha of that actor from 0 to .1 (or similar) and back over a period of time (every 1.5 seconds, for instance). Of course, this will make them all twinkle identically. You could just pick a few (5-10) to twinkle and cover them with actors whose alpha changes - you'd get the twinkle effect on individual stars without having to do all of them.
  • PsmithPsmith Member Posts: 14
    What about using a rotating "mask" actor colored the same as the star background, overlaying the star layer - composed of hundreds of "holes" punched in the mask - the holes being only a little larger than the stars, themselves.

    As the mask rotates from its center, rather quickly, stars "appear" and "disappear" by means of the holes in the mask - thus producing a twinkling effect.

    It's an old "mechanical" star trick used at amusement parks and the like.

    Psmith
  • NessusXVINessusXVI Member Posts: 6
    Thanks for the suggestions, everyone. The star mask idea sounds very promising. I think I may experiment with a few dozen masks with randomly changing alpha values and screen positions. EDIT: Actually, I may create a mask in Gimp composed of a grid of squares with differing opacity- or even better, an image of high contrast noise- and then have the thing move slowly from left to right, looping around the screen as necessary. The game seems to run fine with 200 stars, but a little experimentation leads me to believe I will quickly lose performance if I try to use actors for all particles planned for the game (such as fireworks and explosions).

    I see that the direction of particles coming from an emitter can be randomized, but the effect is still more like a spinning sprinkler. A firework bursts from nothing, points of light spreading out in a spherical fashion before twinkling out. I can live without the twinkling, really- or use circular masks constrained to the firework emitters' locations- but I would really need the particles to burst as one in every direction for the effect to work.

    I'll keep tinkering.
Sign In or Register to comment.