diff options
author | Kester Maddock <Christopher.Maddock.1@uni.massey.ac.nz> | 2004-06-02 16:43:27 +0400 |
---|---|---|
committer | Kester Maddock <Christopher.Maddock.1@uni.massey.ac.nz> | 2004-06-02 16:43:27 +0400 |
commit | 976e3a1824622c11c0bc72110345fcceae75fd73 (patch) | |
tree | 27921d8ff9ae80ed3eb288ae702ff17902a6163d /source/gameengine/PyDoc/Rasterizer.py | |
parent | 474ec217aefd4057429d4cbde4c08768e833cfe5 (diff) |
Updates to GamePython Reference.
Added Actuator documentation.
Diffstat (limited to 'source/gameengine/PyDoc/Rasterizer.py')
-rw-r--r-- | source/gameengine/PyDoc/Rasterizer.py | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/source/gameengine/PyDoc/Rasterizer.py b/source/gameengine/PyDoc/Rasterizer.py index 2c4e368a819..ef6ec4c0bea 100644 --- a/source/gameengine/PyDoc/Rasterizer.py +++ b/source/gameengine/PyDoc/Rasterizer.py @@ -2,8 +2,42 @@ """ Documentation for the Rasterizer module. -Usage: -import Rasterizer +Example Uses an L{SCA_MouseSensor}, and two L{KX_ObjectActuator}s to implement MouseLook:: + # To use a mouse movement sensor "Mouse" and a + # motion actuator to mouse look: + import Rasterizer + import GameLogic + + # SCALE sets the speed of motion + SCALE=[1, 0.5] + + co = GameLogic.getCurrentController() + obj = co.getOwner() + mouse = co.getSensor("Mouse") + lmotion = co.getActuator("LMove") + wmotion = co.getActuator("WMove") + + # Transform the mouse coordinates to see how far the mouse has moved. + def mousePos(): + x = (Rasterizer.getWindowWidth()/2 - mouse.getXPosition())*SCALE[0] + y = (Rasterizer.getWindowHeight()/2 - mouse.getYPosition())*SCALE[1] + return (x, y) + + pos = mousePos() + + # Set the amount of motion: X is applied in world coordinates... + lmotion.setTorque(0.0, 0.0, pos[0], False) + # ...Y is applied in local coordinates + wmotion.setTorque(-pos[1], 0.0, 0.0, True) + + # Activate both actuators + GameLogic.addActiveActuator(lmotion, True) + GameLogic.addActiveActuator(wmotion, True) + + # Centre the mouse + Rasterizer.setMousePosition(Rasterizer.getWindowWidth()/2, Rasterizer.getWindowHeight()/2) + + """ def getWindowWidth(): |