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

Using the built-in collision detection system


Not all problems concerning world and player interaction need to be handled by a fully fledged physics API—sometimes a much more basic and lightweight system is just enough for our purposes. This is why in this recipe we dive into the collision handling system that is built into the Panda3D engine.

Getting ready

This recipe relies upon the project structure created in Setting up the game structure found in Chapter 1, Setting Up Panda3D and Configuring Development Tools.

How to do it...

Let's go through this recipe's tasks:

  1. Open Application.py and add the include statements as well as the constructor of the Application class:

    from direct.showbase.ShowBase import ShowBase
    from panda3d.core import *
    import random
    
    class Application(ShowBase):
        def __init__(self):
            ShowBase.__init__(self)
            self.cam.setPos(0, -50, 10)
            self.setupCD()
            self.addSmiley()
            self.addFloor()
            taskMgr.add(self.updateSmiley, "UpdateSmiley...