INCLUDING THE ENGINE
|
Here's a sample
code on how to include the engine into
your game and make it ready to rumble:
Graphics3D 800,600
SetBuffer BackBuffer()
MyCam = CreateCamera()
Include "particle candy.bb"
Include "particle types.bb"
SetParticleWind 1.0
InitParticles MyCam, "particles.png", 2
Easy, isn't it?
The ParticleCandy engine is provided as
an external .bb file. To add particle power
to your game, simply include this
file on top of your own code:
Include "particle candy.bb"
You may also include the optional particle
library ('named particle types.bb'), if you
plan to use the pre-defined particle- and
emitter types (heck, why not?):
Include "particle types.bb"
|
ENGINE INITIALIZATION
|
InitParticles Cam%, texFile$, texFrames%, [viewportW%], [viewportH%]
This command will initialize the engine and must be called once
before creating any particles. NOTE: When you are using ClearWorld()
to clean up ALL entities within your game, you must call InitParticles()
again to re-initialize the engine.
Here's an explanation of the parameters used:
Cam% = Handle of your active camera entity. Since all the particles are automatically orientated to face the camera, you have to give ParticleCandy a
reference to your camera object. Obviously, you should create your camera
before using this command.
texFile$ = The file name of the texture image to use.
texFrames% = Number of columns (or rows) the texture image contains (explanation see below).
viewportW% = Optional. Width of the screen or viewport used (if not specified, the engine will use the screen width obtained by GraphicsWidth() by default).
viewportH% = Optional. Height of the screen or viewport used (if not specified, the engine will use the screen height obtained by GraphicsHeight() by default).
What texture image to use
The particle texture should contain all the different
particle images you want to use. All image
frames should have the same size (for example 128x128
or 64x64) and the single image frames, as well as
the complete texture image, should be square sized.
Here's an example texture:
This texture contains four frames, so it has
two columns (or two rows, if you want). The number
of columns and rows will always be the same (since
the texture file is square sized). So, assuming you'd
like to use this texture in your game, you would
have to tell it to the engine like this:
InitParticles MyCam, "particles.png", 2
The first parameter is the Camera Handle, the second is the image file name, the
third one indicates how many columns (or rows, it's the same)
the texture file contains (in this case two).
Later, you'll tell ParticleCandy which image to use
by indicating the frame number. The image frame in the top-left
corner is always image number 1. The next frame to the
right is frame number 2 etc. The image frames in the
texture file are numbered from left to right, next row,
again left to right, next row, and so on... See the example above
(the one to the right).
|
|