Game Python Reference Manual.

This manual lists all the Python classes and modules for Game Objects, Sensor bricks, Controllers etc.
Missing: Actuator & Controller reference.
This commit is contained in:
Kester Maddock 2004-05-24 07:49:50 +00:00
parent 86899e7a22
commit a96955efc2
24 changed files with 1275 additions and 0 deletions

@ -0,0 +1,119 @@
"""
Documentation for the GameKeys module.
This module holds key constants for the SCA_KeyboardSensor.
Alphabet keys:
AKEY
BKEY
CKEY
DKEY
EKEY
FKEY
GKEY
HKEY
IKEY
JKEY
KKEY
LKEY
MKEY
NKEY
OKEY
PKEY
QKEY
RKEY
SKEY
TKEY
UKEY
VKEY
WKEY
XKEY
YKEY
ZKEY
Number keys:
ZEROKEY
ONEKEY
TWOKEY
THREEKEY
FOURKEY
FIVEKEY
SIXKEY
SEVENKEY
EIGHTKEY
NINEKEY
Shift Modifiers:
CAPSLOCKKEY
LEFTCTRLKEY
LEFTALTKEY
RIGHTALTKEY
RIGHTCTRLKEY
RIGHTSHIFTKEY
LEFTSHIFTKEY
Arrow Keys:
LEFTARROWKEY
DOWNARROWKEY
RIGHTARROWKEY
UPARROWKEY
Numberpad Keys:
PAD0
PAD1
PAD2
PAD3
PAD4
PAD5
PAD6
PAD7
PAD8
PAD9
PADPERIOD
PADSLASHKEY
PADASTERKEY
PADMINUS
PADENTER
PADPLUSKEY
Function Keys:
F1KEY
F2KEY
F3KEY
F4KEY
F5KEY
F6KEY
F7KEY
F8KEY
F9KEY
F10KEY
F11KEY
F12KEY
Other Keys:
ESCKEY
TABKEY
RETKEY
SPACEKEY
LINEFEEDKEY
BACKSPACEKEY
DELKEY
SEMICOLONKEY
PERIODKEY
COMMAKEY
QUOTEKEY
ACCENTGRAVEKEY
MINUSKEY
SLASHKEY
BACKSLASHKEY
EQUALKEY
LEFTBRACKETKEY
RIGHTBRACKETKEY
PAUSEKEY
INSERTKEY
HOMEKEY
PAGEUPKEY
PAGEDOWNKEY
ENDKEY
"""

@ -0,0 +1,85 @@
"""
Documentation for the GameLogic Module.
Constants:
KX_TRUE: True value used by some modules
KX_FALSE: False value used by some modules.
Property Sensor:
Tests that the property sensor is able to perform.
KX_PROPSENSOR_EQUAL: Activate when the property is equal to the sensor value.
KX_PROPSENSOR_NOTEQUAL Activate when the property is not equal to the sensor value.
KX_PROPSENSOR_INTERVAL Activate when the property is between the specified limits.
KX_PROPSENSOR_CHANGED Activate when the property changes
KX_PROPSENSOR_EXPRESSION Activate when the expression matches
Constraint Actuator:
The axis and type (location/rotation) of constraint
KX_CONSTRAINTACT_LOCX
KX_CONSTRAINTACT_LOCY
KX_CONSTRAINTACT_LOCZ
KX_CONSTRAINTACT_ROTX
KX_CONSTRAINTACT_ROTY
KX_CONSTRAINTACT_ROTZ
IPO Actuator:
IPO Types
KX_IPOACT_PLAY
KX_IPOACT_PINGPONG
KX_IPOACT_FLIPPER
KX_IPOACT_LOOPSTOP
KX_IPOACT_LOOPEND
Random distributions:
KX_RANDOMACT_BOOL_CONST
KX_RANDOMACT_BOOL_UNIFORM
KX_RANDOMACT_BOOL_BERNOUILLI
KX_RANDOMACT_INT_CONST
KX_RANDOMACT_INT_UNIFORM
KX_RANDOMACT_INT_POISSON
KX_RANDOMACT_FLOAT_CONST
KX_RANDOMACT_FLOAT_UNIFORM
KX_RANDOMACT_FLOAT_NORMAL
KX_RANDOMACT_FLOAT_NEGATIVE_EXPONENTIAL
"""
def getCurrentController():
"""
Gets the Python controller associated with this Python script.
@rtype: SCA_PythonController
"""
def addActiveActuator(actuator, activate):
"""
Activates the given actuator.
@type actuator: SCA_IActuator
@type activate: boolean
@param activate: whether to activate or deactivate the given actuator.
"""
def getRandomFloat():
"""
Returns a random floating point value in the range [0...1)
"""
def setGravity(gravity):
"""
Sets the world gravity.
@type gravity: list [fx, fy, fz]
"""
def getSpectrum():
"""
Returns a 512 point list from the sound card.
This only works if the fmod sound driver is being used.
@rtype: list [float], len(getSpectrum()) == 512
"""
def stopDSP():
"""
Stops the sound driver using DSP effects.
Only the fmod sound driver supports this.
DSP can be computationally expensive.
"""

@ -0,0 +1,31 @@
# Documentation for CD Actuator
from SCA_ILogicBrick import *
class KX_CDActuator(SCA_ILogicBrick):
def startCD():
"""
Starts the CD playing.
"""
def stopCD():
"""
Stops the CD playing.
"""
def pauseCD():
"""
Pauses the CD.
"""
def setGain(gain):
"""
Sets the gain (volume) of the CD.
@type gain: float
@param gain: the gain to set the CD to. 0.0 = silent, 1.0 = max volume.
"""
def getGain():
"""
Gets the current gain (volume) of the CD.
@rtype float
@return Between 0.0 (silent) and 1.0 (max volume)
"""

@ -0,0 +1,186 @@
# Documentation for Camera game objects.
from KX_GameObject import *
class KX_Camera(KX_GameObject):
"""
A Camera object.
@cvar INSIDE: see sphereInsideFrustum and boxInsideFrustum
@cvar INTERSECT: see sphereInsideFrustum and boxInsideFrustum
@cvar OUTSIDE: see sphereInsideFrustum and boxInsideFrustum
Attributes:
@cvar lens: The camera's lens value. float
@cvar near: The camera's near clip distance. float
@cvar far: The camera's far clip distance. float
@cvar frustum_culling: True if this camera is frustum culling. boolean
@cvar projection_matrix: This camera's 4x4 projection matrix. [[float]]
@cvar modelview_matrix: This camera's 4x4 model view matrix. [[float]] (read only)
Regenerated every frame from the camera's position and orientation.
@cvar camera_to_world: This camera's camera to world transform. [[float]] (read only)
Regenerated every frame from the camera's position and orientation.
@cvar world_to_camera: This camera's world to camera transform. [[float]] (read only)
Regenerated every frame from the camera's position and orientation.
This is camera_to_world inverted.
"""
def sphereInsideFrustum(centre, radius):
"""
Tests the given sphere against the view frustum.
@return: INSIDE, OUTSIDE or INTERSECT
@type centre: list
@param centre: The centre of the sphere (in world coordinates.)
@type radius: float
@param radius: the radius of the sphere
Example:
import GameLogic
co = GameLogic.getCurrentController()
cam = co.GetOwner()
# A sphere of radius 4.0 located at [x, y, z] = [1.0, 1.0, 1.0]
if (cam.sphereInsideFrustum([1.0, 1.0, 1.0], 4) != cam.OUTSIDE):
# Sphere is inside frustum !
# Do something useful !
else:
# Sphere is outside frustum
"""
def boxInsideFrustum(box):
"""
Tests the given box against the view frustum.
@return: INSIDE, OUTSIDE or INTERSECT
@type box: list
@param box: Eight (8) corner points of the box (in world coordinates.)
Example:
@verbatim{
import GameLogic
co = GameLogic.getCurrentController()
cam = co.GetOwner()
# Box to test...
box = []
box.append([-1.0, -1.0, -1.0])
box.append([-1.0, -1.0, 1.0])
box.append([-1.0, 1.0, -1.0])
box.append([-1.0, 1.0, 1.0])
box.append([ 1.0, -1.0, -1.0])
box.append([ 1.0, -1.0, 1.0])
box.append([ 1.0, 1.0, -1.0])
box.append([ 1.0, 1.0, 1.0])
if (cam.boxInsideFrustum(box) != cam.OUTSIDE):
# Box is inside/intersects frustum !
# Do something useful !
else:
# Box is outside the frustum !
}
"""
def pointInsideFrustum(point):
"""
Tests the given point against the view frustum.
@rtype: boolean
@return: True if the given point is inside this camera's viewing frustum.
@type point: [x, y, z]
@param point: The point to test (in world coordinates.)
Example:
@verbatim{
import GameLogic
co = GameLogic.getCurrentController()
cam = co.GetOwner()
# Test point [0.0, 0.0, 0.0]"
if (cam.pointInsideFrustum([0.0, 0.0, 0.0])):
# Point is inside frustum !
# Do something useful !
else:
# Box is outside the frustum !
}
"""
def getCameraToWorld():
"""
Returns the camera-to-world transform.
@rtype: matrix (4x4 list)
@return: the camera-to-world transform matrix.
"""
def getWorldToCamera():
"""
Returns the world-to-camera transform.
This returns the inverse matrix of getCameraToWorld().
@rtype: matrix (4x4 list)
@return: the world-to-camera transform matrix.
"""
def getProjectionMatrix():
"""
Returns the camera's projection matrix.
@rtype: matrix (4x4 list)
@return: the camera's projection matrix.
"""
def setProjectionMatrix(matrix):
"""
Sets the camera's projection matrix.
You should use normalised device coordinates for the clipping planes:
left = -1.0, right = 1.0, top = 1.0, bottom = -1.0, near = 0.0, far = 1.0
@type matrix: 4x4 matrix.
@param matrix: The new projection matrix for this camera.
Example:
@verbatim{
import GameLogic
# Scale a matrix
def Scale(matrix, scalar):
for row in matrix:
for col in row:
col = col * scalar
# Generate an identiy matrix.
def Identity():
return [[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]]
# Generate a perspective projection matrix
def Perspective():
m = Identity()
m[0][0] = m[0][2] = 2.0
m[1][1] = m[1][2] = 2.0
m[2][2] = m[2][3] = -1.0
m[3][2] = -1.0
m[3][3] = 0.0
return m
# Generate an orthographic projection matrix
# You will need to Scale this matrix.
def Orthographic():
m = Identity()
m[0][0] = 2.0
m[0][3] = 0.0
m[1][1] = 2.0
m[1][3] = 0.0
m[2][2] = 1.0
m[2][3] = 1.0
m[3][3] = 1.0
return m
# Generate an isometric projection matrix
def Isometric():
m = Identity()
m[0][0] = m[0][2] = m[1][1] = 0.8660254037844386
m[1][0] = 0.25
m[1][2] = -0.25
m[3][3] = 1.0
return m
co = GameLogic.getCurrentController()
cam = co.getOwner()
cam.setProjectionMatrix(Perspective()))
"""

@ -0,0 +1,3 @@
# Documentation for KX_GameActuator
class KX_GameActuator:

@ -0,0 +1,142 @@
# Documentation for game objects
class KX_GameObject:
"""
All game objects are derived from this class.
Properties assigned to game objects are accessible as attributes
in objects of this class.
Attributes:
mass: The object's mass (provided the object has a physics controller). float. read only
parent: The object's parent object. KX_GameObject. read only
visible: visibility flag. boolean.
position: The object's position. list [x, y, z]
orientation: The object's orientation. 3x3 Matrix. You can also write a Quaternion or Euler vector.
scaling: The object's scaling factor. list [sx, sy, sz]
"""
def setVisible(visible):
"""
Sets the game object's visible flag.
@type visible: boolean
"""
def setPosition(pos):
"""
Sets the game object's position.
@type pos: [x, y, z]
@param pos: the new position, in world coordinates.
"""
def getPosition():
"""
Gets the game object's position.
@rtype list [x, y, z]
@return the object's position in world coordinates.
"""
def setOrientation(orn):
"""
Sets the game object's orientation.
@type orn: 3x3 rotation matrix, or Quaternion.
@param orn: a rotation matrix specifying the new rotation.
"""
def getOrientation():
"""
Gets the game object's orientation.
@rtype 3x3 rotation matrix
@return The game object's rotation matrix
"""
def getLinearVelocity():
"""
Gets the game object's linear velocity.
This method returns the game object's velocity through it's centre of mass,
ie no angular velocity component.
cf getVelocity()
@rtype list [vx, vy, vz]
@return the object's linear velocity.
"""
def getVelocity(point):
"""
Gets the game object's velocity at the specified point.
Gets the game object's velocity at the specified point, including angular
components.
@type point: list [x, y, z]
@param point: the point to return the velocity for, in local coordinates. (optional: default = [0, 0, 0])
@rtype list [vx, vy, vz]
@return the velocity at the specified point.
"""
def getMass():
"""
Gets the game object's mass.
@rtype float
@return the object's mass.
"""
def getReactionForce():
"""
Gets the game object's reaction force.
The reaction force is the force applied to this object over the last simulation timestep.
This also includes impulses, eg from collisions.
@rtype list [fx, fy, fz]
@return the reaction force of this object.
"""
def applyImpulse(point, impulse):
"""
Applies an impulse to the game object.
This will apply the specified impulse to the game object at the specified point.
If point != getPosition(), applyImpulse will also change the object's angular momentum.
Otherwise, only linear momentum will change.
@type point: list [x, y, z]
@param point: the point to apply the impulse to (in world coordinates)
"""
def suspendDynamics():
"""
Suspends physics for this object.
"""
def restoreDynamics():
"""
Resumes physics for this object.
"""
def enableRigidBody():
"""
Enables rigid body physics for this object.
Rigid body physics allows the object to roll on collisions.
"""
def disableRigidBody():
"""
Disables rigid body physics for this object.
"""
def getParent():
"""
Gets this object's parent.
@rtype: game object
@return this object's parent object, or None if this object has no parent.
"""
def getMesh(mesh):
"""
Gets the mesh object for this object.
@type mesh: integer
@param mesh: the mesh object to return (optional: default mesh = 0)
@rtype: mesh object
@returns the first mesh object associated with this game object, or None if this object has no meshs.
"""
def getPhysicsId():
"""
Returns the user data object associated with this game object's physics controller.
"""

@ -0,0 +1,57 @@
# Documentation for KX_MeshProxy
class KX_MeshProxy:
"""
A mesh object.
You can only change the vertex properties of a mesh object, not the mesh topology.
"""
def GetNumMaterials():
"""
Gets the number of materials associated with this object.
@rtype integer
"""
def GetMaterialName(matid):
"""
Gets the name of the specified material.
@type matid: integer
@param matid: the specified material.
@rtype: string
@return: the attached material name.
"""
def GetTextureName(matid):
"""
Gets the name of the specified material's texture.
@type matid: integer
@param matid: the specified material
@rtype: string
@return: the attached material's texture name.
"""
def GetVertexArrayLength(matid):
"""
Gets the length of the vertex array associated with the specified material.
There is one vertex array for each material.
@type matid: integer
@param matid: the specified material
@rtype: integer
@return: the number of verticies in the vertex array.
"""
def GetVertex(matid, index):
"""
Gets the specified vertex from the mesh object.
@type matid: integer
@param matid: the specified material
@type index: integer
@param index: the index into the vertex array.
@rtype KX_VertexProxy
@return a vertex object.
"""

@ -0,0 +1,25 @@
# Documentation for KX_MouseFocusSensor
from SCA_MouseSensor import *
class KX_MouseFocusSensor(SCA_MouseSensor):
"""
The mouse focus sensor detects when the mouse is over the current game object.
The mouse focus sensor works by transforming the mouse coordinates from 2d device
space to 3d space then raycasting away from the camera.
"""
def GetRayTarget():
"""
Returns the end point of the sensor ray.
@rtype: list [x, y, z]
@return: the end point of the sensor ray, in world coordinates.
"""
def GetRaySource():
"""
Returns the start point of the sensor ray.
@rtype: list [x, y, z]
@return: the start point of the sensor ray, in world coordinates.
"""

@ -0,0 +1,8 @@
# Documentation for KX_NearSensor
from KX_TouchSensor import *
class KX_NearSensor(KX_TouchSensor):
"""
A near sensor is a specialised form of touch sensor.
"""

@ -0,0 +1,42 @@
# Documentation for KX_NetworkMessageSensor
from SCA_ISensor import *
class KX_NetworkMessageSensor(SCA_ISensor):
"""
The Message Sensor logic brick.
Currently only loopback (local) networks are supported.
"""
def setSubjectFilterText(subject):
"""
Change the message subject text that this sensor is listening to.
@type subject: string
@param subject: the new message subject to listen for.
"""
def getFrameMessageCount():
"""
Get the number of messages received since the last frame.
@rtype: integer
"""
def getBodies():
"""
Gets the list of message bodies.
@rtype: list
"""
def getSubject():
"""
Gets the message subject this sensor is listening for from the Subject: field.
@rtype: string
"""
def getSubjects():
"""
Gets the list of message subjects received.
@rtype list
"""

@ -0,0 +1,30 @@
# Documentation for KX_RadarSensor
from KX_NearSensor import *
class KX_RadarSensor(KX_NearSensor):
"""
Radar sensor is a near sensor with a conical sensor object.
"""
def getConeOrigin():
"""
Returns the origin of the cone with which to test. The origin
is in the middle of the cone.
@rtype: list [x, y, z]
"""
def getConeTarget():
"""
Returns the center of the bottom face of the cone with which to test.
@rtype: list [x, y, z]
"""
def getConeHeight():
"""
Returns the height of the cone with which to test.
@rtype: float
"""

@ -0,0 +1,32 @@
# Documentation for KX_RaySensor
from SCA_ISensor import *
class KX_RaySensor(SCA_ISensor):
"""
A ray sensor detects the first object in a given direction.
"""
def getHitObject():
"""
Returns the game object that was hit by this ray.
@rtype: KX_GameObject
"""
def getHitPosition():
"""
Returns the position (in worldcoordinates) where the object was hit by this ray.
@rtype: list [x, y, z]
"""
def getHitNormal():
"""
Returns the normal (in worldcoordinates) of the object at the location where the object was hit by this ray.
@rtype: list [nx, ny, nz]
"""
def getRayDirection():
"""
Returns the direction from the ray (in worldcoordinates)
@rtype: list [dx, dy, dz]
"""

@ -0,0 +1,49 @@
# Documentation for KX_TouchSensor
from SCA_ISensor import *
class KX_TouchSensor(SCA_ISensor):
"""
Touch sensor detects collisions between objects.
"""
def setProperty(name):
"""
Set the property or material to collide with. Use
setTouchMaterial() to switch between properties and
materials.
@type name: string
"""
def getProperty():
"""
Returns the property or material to collide with. Use
getTouchMaterial() to find out whether this sensor
looks for properties or materials.
@rtype: string
"""
def getHitObject():
"""
Returns the last object hit by this touch sensor.
@rtype: KX_GameObject
"""
def getHitObjectList():
"""
Returns a list of all objects hit in the last frame.
Only objects that have the requisite material/property are listed.
@rtype: list [KX_GameObject]
"""
def getTouchMaterial():
"""
Returns KX_TRUE if this sensor looks for a specific material,
KX_FALSE if it looks for a specific property.
"""
def setTouchMaterial(flag):
"""
Set flag to KX_TRUE to switch on positive pulse mode,
KX_FALSE to switch off positive pulse mode.
@type flag: KX_TRUE or KX_FALSE.
"""

@ -0,0 +1,74 @@
# Documentation for the vertex proxy class
class KX_VertexProxy:
"""
A vertex holds position, UV, colour and normal information.
Note:
The physics simulation is NOT currently updated - physics will not respond correctly
to changes in the vertex position.
"""
def getXYZ():
"""
Gets the position of this vertex.
@rtype: list [x, y, z]
@return: this vertexes position in local coordinates.
"""
def setXYZ(pos):
"""
Sets the position of this vertex.
@type pos: list [x, y, z]
@param: the new position for this vertex in local coordinates.
"""
def getUV():
"""
Gets the UV (texture) coordinates of this vertex.
@rtype: list [u, v]
@return: this vertexes UV (texture) coordinates.
"""
def setUV(uv):
"""
Sets the UV (texture) coordinates of this vertex.
@type uv: list [u, v]
"""
def getRGBA():
"""
Gets the colour of this vertex.
Example:
# Big endian:
col = v.getRGBA()
red = (col & 0xff000000) >> 24
green = (col & 0xff0000) >> 16
blue = (col & 0xff00) >> 8
alpha = (col & 0xff)
# Little endian:
col = v.getRGBA()
alpha = (col & 0xff000000) >> 24
blue = (col & 0xff0000) >> 16
green = (col & 0xff00) >> 8
red = (col & 0xff)
@rtype: integer
@return: packed colour. 4 byte integer with one byte per colour channel in RGBA format.
"""
def setRGBA(col):
"""
Sets the colour of this vertex.
@type col: integer
@param col: the new colour of this vertex in packed format.
"""
def getNormal():
"""
Gets the normal vector of this vertex.
@rtype: list [nx, ny, nz]
@return: normalised normal vector.
"""

@ -0,0 +1,11 @@
SOURCES=$(shell ls *.py)
TARGETS:=$(SOURCES:.py=.html)
PYDOC=/usr/lib/python2.2/pydoc.py
all: $(TARGETS)
%.html: %.py
$(PYDOC) -w $*

@ -0,0 +1,74 @@
"""
Documentation for the Rasterizer module.
Usage:
import Rasterizer
"""
def getWindowWidth():
"""
Gets the width of the window (in pixels)
@rtype: integer
"""
def getWindowHeight():
"""
Gets the height of the window (in pixels)
@rtype: integer
"""
def makeScreenshot(filename):
"""
Writes a screenshot to the given filename.
@type filename: string
"""
def enableVisibility(visible):
"""
Doesn't really do anything...
"""
def showMouse(visible):
"""
Enables or disables the operating system mouse cursor.
@type visible: boolean
"""
def setMousePosition(x, y):
"""
Sets the mouse cursor position.
@type x, y: integer
"""
def setBackgroundColor(rgba):
"""
Sets the window background colour.
@type rgba: list [r, g, b, a]
"""
def setMistColor(rgb):
"""
Sets the mist colour.
@type rgb: list [r, g, b]
"""
def setMistStart(start):
"""
Sets the mist start value. Objects further away than start will have mist applied to them.
@type start: float
"""
def setMistEnd(end):
"""
Sets the mist end value. Objects further away from this will be coloured solid with
the colour set by setMistColor().
@type end: float
"""

@ -0,0 +1,8 @@
# Documentation for SCA_AlwaysSensor
from SCA_ISensor import *
class SCA_AlwaysSensor(SCA_ISensor):
"""
This sensor is always activated.
"""

@ -0,0 +1,28 @@
# Documentation for the logic brick base class SCA_ILogicBrick
from KX_GameObject import *
class SCA_ILogicBrick:
"""
Logic brick base class.
"""
def getOwner():
"""
Gets the game object associated with this logic brick.
@rtype KX_GameObject
"""
def setExecutePriority(priority):
"""
Sets the priority of this logic brick.
@type priority: integer
@param priority: the priority of this logic brick.
"""
def getExecutePriority():
"""
Gets the execution priority of this logic brick.
@rtype integer
@return this logic bricks current priority.
"""

@ -0,0 +1,61 @@
# Documentation for SCA_ISensor
from SCA_ILogicBrick import *
class SCA_ISensor(SCA_ILogicBrick):
"""
Base class for all sensor logic bricks.
"""
def isPositive():
"""
True if this sensor brick has been activated.
"""
def getUsePosPulseMode():
"""
True if the sensor is in positive pulse mode.
"""
def setUsePosPulseMode(pulse):
"""
Sets positive pulse mode.
@type pulse: boolean
@param pulse: If True, will activate positive pulse mode for this sensor.
"""
def getFrequency():
"""
The frequency for pulse mode sensors.
@rtype integer
@return the pulse frequency in 1/50 sec.
"""
def setFrequency(freq):
"""
Sets the frequency for pulse mode sensors.
@type freq: integer
@return the pulse frequency in 1/50 sec.
"""
def getUseNegPulseMode():
"""
True if the sensor is in negative pulse mode.
"""
def setUseNegPulseMode(pulse):
"""
Sets negative pulse mode.
@type pulse: boolean
@param pulse: If True, will activate negative pulse mode for this sensor.
"""
def getInvert():
"""
True if this sensor activates on negative events.
"""
def setInvert(invert):
"""
Sets if this sensor activates on positive or negative events.
@type invert: boolean
@param invert: true if activates on negative events; false if activates on positive events.
"""

@ -0,0 +1,57 @@
# Documentation for SCA_KeyboardSensor
from SCA_ISensor import *
class SCA_KeyboardSensor(SCA_ISensor):
"""
A keyboard sensor detects player key presses.
See module GameKeys for keycode values.
"""
def getKey():
"""
Returns the key code this sensor is looking for.
"""
def setKey(keycode):
"""
Set the key this sensor should listen for.
@type keycode: keycode from GameKeys module
"""
def getHold1():
"""
Returns the key code for the first modifier this sensor is looking for.
"""
def setHold1():
"""
Sets the key code for the first modifier this sensor should look for.
"""
def getHold2():
"""
Returns the key code for the second modifier this sensor is looking for.
"""
def setHold2():
"""
Sets the key code for the second modifier this sensor should look for.
"""
def getPressedKeys():
"""
Get a list of keys that have either been pressed, or just released this frame.
@rtype: list of key status. [[keycode, status]]
"""
def getCurrentlyPressedKeys():
"""
Get a list of currently pressed keys that have either been pressed, or just released
@rtype: list of key status. [[keycode, status]]
"""

@ -0,0 +1,22 @@
# Documentation for SCA_MouseSensor
from SCA_ISensor import *
class SCA_MouseSensor(SCA_ISensor):
"""
Mouse Sensor logic brick.
"""
def getXPosition():
"""
Gets the x coordinate of the mouse.
@rtype: integer
@return: the current x coordinate of the mouse, in frame coordinates (pixels)
"""
def getYPosition():
"""
Gets the y coordinate of the mouse.
@rtype: integer
@return: the current y coordinate of the mouse, in frame coordinates (pixels).
"""

@ -0,0 +1,56 @@
# Documentation for SCA_PropertySensor
from SCA_ISensor import *
class SCA_PropertySensor(SCA_ISensor):
"""
Activates when the game object property matches.
"""
def getType():
"""
Gets when to activate this sensor.
KX_PROPSENSOR_EQUAL, KX_PROPSENSOR_NOTEQUAL,
KX_PROPSENSOR_INTERVAL, KX_PROPSENSOR_CHANGED,
or KX_PROPSENSOR_EXPRESSION.
"""
def setType(checktype):
"""
Set the type of check to perform.
@type checktype: KX_PROPSENSOR_EQUAL, KX_PROPSENSOR_NOTEQUAL,
KX_PROPSENSOR_INTERVAL, KX_PROPSENSOR_CHANGED,
or KX_PROPSENSOR_EXPRESSION.
"""
def getProperty():
"""
Return the property with which the sensor operates.
@rtype string
@return the name of the property this sensor is watching.
"""
def setProperty(name):
"""
Sets the property with which to operate. If there is no property
of that name, this call is ignored.
@type name: string.
"""
def getValue():
"""
Return the value with which the sensor compares to the value of the property.
@rtype string
@return the value of the property this sensor is watching.
"""
def setValue(value):
"""
Set the value with which the sensor operates. If the value
is not compatible with the type of the property, the subsequent
action is ignored.
@type value: string
"""

@ -0,0 +1,48 @@
# Documentation for SCA_PythonController
from SCA_ILogicBrick import *
class SCA_PythonController(SCA_ILogicBrick):
"""
A Python controller uses a Python script to activate it's actuators,
based on it's sensors.
"""
def getSensors():
"""
Gets a list of all sensors attached to this controller.
@rtype: list [SCA_ISensor]
"""
def getSensor(name):
"""
Gets the named linked sensor.
@type name: string
@rtype: SCA_ISensor
"""
def getActuators():
"""
Gets a list of all actuators linked to this controller.
@rtype: list [SCA_IActuator]
"""
def getActuator(name):
"""
Gets the named linked actuator.
@type name: string
@rtype: SCA_IActuator
"""
def getScript():
"""
Gets the Python script this controller executes.
@rtype: string
"""
def setScript(script):
"""
Sets the Python script this controller executes.
@type script: string.
"""

@ -0,0 +1,27 @@
# Documentation for SCA_RandomSensor
from SCA_ISensor import *
class SCA_RandomSensor(SCA_ISensor):
"""
This sensor activates randomly.
"""
def setSeed(seed):
"""
Sets the seed of the random number generator.
If the seed is 0, the generator will produce the same value on every call.
@type seed: integer.
"""
def getSeed():
"""
Returns the initial seed of the generator. Equal seeds produce equal random
series.
@rtype: integer
"""
def getLastDraw():
"""
Returns the last random number generated.
"""