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!
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:
Let's get to the code behind this interesting effect:
Copy your texture file to the
te
xtures
directory and rename it toflashlight.png
.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...