Book Image

Panda3D 1.7 Game Developer's Cookbook

Book Image

Panda3D 1.7 Game Developer's Cookbook

Overview of this book

Table of Contents (20 chapters)
Panda3D 1.7 Game Developer's Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Creating particle effects


Ranging from dust kicked up by an out of control race car spinning out into a run-off area over smoke that ascends from a battlefield to sparks spraying from a magic wand, particles are a great tool for adding life and visual fidelity to the graphics of a game. Therefore, this recipe will show you how to create a simple particle effect.

Getting ready

This recipe is based upon the project setup presented in Setting up the game structure. Please follow this recipe, found in Chapter 1, before proceeding.

How to do it...

Let's try the following Panda3D's particle effect system:

  1. Open the file Application.py and add the following code:

    from direct.showbase.ShowBase import ShowBase
    from panda3d.core import *
    from direct.particles.Particles import Particles
    from direct.particles.ParticleEffect import ParticleEffect
    
    class Application(ShowBase):
        def __init__(self):
            ShowBase.__init__(self)
    
            self.enableParticles()
    
            particles = Particles()
            particles...