TGC Codebase Backup



Basic Particles Principles by MikeS

19th Mar 2004 17:12
Summary

Learn how to use particles to your advantage.



Description

Learn how to use particles to your advantage.



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    ` This tutorial was created by Yellow -Mike- 3-12-04
` Although not necessary, it would be nice to be credited and
` notified at yellow1dbp@hotmail.com if this was used in a game
` Thanks, and I hope the tutorial helps.

`Particles tutorial
`After this tutorial, you'll have learned the basics of particles

sync on : sync rate 60 `set up our screen refresh rate
backdrop on `set up the 3D display

`The first number is the unique particle number that can only be set to one
`particle. The second number can be used for an image, yet we won't be needing one.
`The third part tells us how frequent we want the particles to occur. Finally,
`the radius tells the distance from the center of the particles they will fly out.
make particles 1,0,50,10

`For this tutorial we'll also include a second particle.
make particles 2,0,50,10

`Now lets color them to make things more interesting.
`As mentioned before, you can use and image instead of coloring them.
color particles 1,255,0,0
color particles 2,255,50,50

`Now we'll want to do something very simple. We'll rotate the particles
`This can be used to give an explosive effect when used correctly.
rotate particles 2,90,0,0
`We only need to rotate the second particle, sinc the other one is right side up already.

`We'll now set the particles life, for how long they'll live.
Set particle life 1,75
Set particle life 2,75
`We'll now set how fast the particles move
Set particle speed 1,0.004
Set particle speed 2,0.004

do `Initilize our loop

`Just a friendly reminder for when you're running the loop. :)
text 0,0,"Press spacebar to stop explosions"

`Now you can play around with the particles.
`If the spacekey is pressed it'll stop the particles,
`or ELSE, the particles will keep emitting. The emissions command
`can be a helpful way to create explosions in your games.

if spacekey()=1
 set particle emissions 1,0
 set particle emissions 2,0
else
 set particle emissions 1,25
 set particle emissions 2,25
endif


sync `Refresh the screen
loop `Loop the program

`Now you're free to play around with the particles as you like.
`I encourage you to tweak the values to your need, and take a look at
`the other help files for Particles and explore the new commands.

`Hope this helped
`Copyright(c) CurvedBasic 2004