Graphics Programs Reference
In-Depth Information
# finally, set the dLoc vector of the baseMover actuator to the
values calculated in the previous lines of code…
act.dLoc = [xVal, yVal, zVal]
# … and send the actuator the activation signal, so that it
performs the action of moving the object.
cont.activate(act)
2.
Then let's add a second text datablock, set its name to look.py , and enter
this code:
# ask for the functionality of these libraries to be available in
this script
import bge
import mathutils
import math
# create a function to improve the readability of the code below
def showMousePointer():
bge.render.showMouse(True)
# create a function to improve the readability of the code below
def hideMousePointer():
bge.render.showMouse(False)
# define two variables to be used as constants (all uppercase
is just a way to signify they are constants). These variables
indicate what is the maximum (up) and minimum (down) angle the
camera can rotate. The computation is needed to convert the value
from degrees to radians.
MAX_ANGLE = 60*math.pi/180
MIN_ANGLE = -MAX_ANGLE
# get a reference to the controller that called this script and to
the object owner of that controller
cont = bge.logic.getCurrentController()
obj = cont.owner
# get a reference to the three sensors connected to the controller
that called this script
click = cont.sensors['click']
unclick = cont.sensors['unclick']
move = cont.sensors['mousemove']
# get references to the actuators that this controller is
connected to
viewRot = cont.actuators['viewRot']
baseMover = cont.actuators['baseMover']
# get references to the objects that own the viewRot and baseMover
actuators. These references are needed to access the properties of
those objects
 
Search WWH ::




Custom Search