Graphics Reference
In-Depth Information
Figure 16-10 Properties on the camera
The full logic for the password-processing functionality is shown in Figure 16-11 . It includes the required
five sensors, a script controller that calls a script named Control.py , and a Scene actuator that will set the
scene to the Welcome scene when the password matches the username. You'll also need to switch the scene to
Welcome and make sure its camera has the same logic setup, with Control.py as its controller.
Figure 16-11 Logic bricks on the camera
Before moving on to the code of Control.py , take a closer look at those five sensors connected to the
script controller. You can see all five sensors in their unfolded state in Figure 16-12 .
Always The first sensor is an Always sensor that ensures that the script runs constantly. This sensor is given
the name init by default because one of its purposes is to ensure that the initialization code is executed
immediately, but this sensor is not accessed directly in the code, so it does not really matter what its name is.
Mouse The next sensor is a Mouse sensor of type Mouse Over Any, and its name is mouse . As you might
guess, this sensor will register as positive if the mouse is moved over any object from the perspective of the
camera in the game-play environment.
Keyboard The next sensor is a Keyboard sensor. Instead of choosing a specific key, the All Keys option is
selected. Furthermore, the value keystrokelog is entered into the Log Toggle field. As you recall, the
keystrokelog property is a Boolean type property with a value of True . Setting Log Toggle to True
enables keyboard input to be interpreted as a string. The Target field determines which property the string is
passed to. The value input is entered into this field so that the string will be passed to the input property.
Property To print the input to the screen letter by letter, you need to add a sensor that fires each time a letter
isentered.ThisisdoneusingaPropertysensoroftypeChangedwithaPropertyvalueof input .Thismeans
 
 
 
 
Search WWH ::




Custom Search