viernes, 25 de enero de 2008

RaStReOmOuSe.Py

# Import Modules
import Rasterizer

# Get Controller & Owner
cont = GameLogic.getCurrentController()
own = cont.getOwner()

# Sensors & Actuators
M_Move = cont.getSensor("mueve")
RotX = cont.getActuator("RotX")
RotY = cont.getActuator("RotY")

# Values
Width = Rasterizer.getWindowWidth()
Height = Rasterizer.getWindowHeight()
Xpos = M_Move.getXPosition()
Ypos = M_Move.getYPosition()
Rot = own.getOrientation()[2][2]

########## Constraints ##########
#################################
XSensitivity = 0.003
YSensitivity = 0.003
TopMax = -0.9
LowMax = 0.9

# Get The Offset
OfX = (Width/2-Xpos)*XSensitivity
OfY = -(Height/2-Ypos)*YSensitivity

RotX.setDRot(0,0,OfX,1)
RotY.setDRot(0,0,0,1)
if OfY < 0 and Rot > TopMax:
RotY.setDRot(OfY,0,0,1)
elif OfY > 0 and Rot < LowMax:
RotY.setDRot(OfY,0,0,1)

GameLogic.addActiveActuator(RotX,1)
GameLogic.addActiveActuator(RotY,1)
GameLogic.addActiveActuator(RotX,0)
GameLogic.addActiveActuator(RotY,0)

Rasterizer.setMousePosition(Width/2,Height/2)

No hay comentarios: