Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Panda3D 1.7 Game Developer's Cookbook
  • Table Of Contents Toc
Panda3D 1.7 Game Developer's Cookbook

Panda3D 1.7 Game Developer's Cookbook

close
close
Panda3D 1.7 Game Developer's Cookbook

Panda3D 1.7 Game Developer's Cookbook

Overview of this book

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

Creating a flashlight effect


This recipe will show you how to implement an effect that makes the scene look like it was lit from a small flashlight. This really nice effect can help you make your dark and creepy games even darker and creepier!

Getting ready

Follow the steps from Setting up the game structure in Chapter 1 and add a directory called textures to the project.

Additionally, you will need a texture that represents the light point created by the flashlight, like the one shown as follows:

How to do it...

Let's get to the code behind this interesting effect:

  1. Copy your texture file to the textures directory and rename it to flashlight.png.

  2. Open Application.py and add the following code:

    from direct.showbase.ShowBase import ShowBase
    from panda3d.core import *
    
    class Application(ShowBase):
        def __init__(self):
            ShowBase.__init__(self)
    
            self.world = loader.loadModel("environment")
            self.world.reparentTo(render)
            self.world.setScale(0.5)
            self.world.setPos...
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Panda3D 1.7 Game Developer's Cookbook
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon