Graphics Reference
In-Depth Information
port value is 1 , the object's location is set to a location just below the second upper ring. If the port value
is 3 , the location is set to just below the rightmost upper ring. Note that in both of these clauses, place[2]
refers to the z-axis coordinate of the position dealt with. Subtracting 0.8 has the effect of placing the ball just
below the upper rings:
if hit:
print(hit.getPropertyNames())
if hit['port'] == 1:
place = list(torus2.position)
place[2] = place[2] - 0.8
own.position = place
if hit['port'] == 3:
place = list(torus4.position)
place[2] = place[2] - 0.8
own.position = place
If you run the BGE now, the results might not be as you expect. With the settings described so far, the ball
will not fall straight through the series of rings but rather will collide with the first ring it strikes, and the forces
from that collision will affect its trajectory as it emerges from the next ring in the series. To remedy this, set the
ring dynamics to Ghost in the Logic buttons area.
Creating a Login Screen
In this section, you'll walk through an implementation of a simple login screen with name and password fields.
Python is necessary here to process the name and password to ensure that they match and also to handle other
functionsoftheloginscreen.Intheexample,thenameandpassworddataisstoredinasimpledictionarywithin
the script itself, but you could also load the data from an external database (to learn how to do this, you will
need to refer to general Python documentation for accessing the database of your choice).
The starting setup for this section, without the Python code or logic, can be found on the website for this
book, in the file login_nologic.blend . The finished login screen is in the file login.blend .
Objects and Logic Bricks
To get started, I placed a number of objects in the 3D space to create a login screen, as shown in Figure 16-7 .
The login screen is made up of three vertex-painted planes that compose the text fields themselves. Above the
fields are textured planes for dynamic text exactly like the ones described in Chapter 15. Two small circles are
placed over the left side of each text field, which will be used to indicate which text field is active to type into.
 
Search WWH ::




Custom Search