Mouse movement question

Hi everyone,

I’m creating a first person game using the mouse to control movement, and I have a question about keeping the cursor on the screen. My game uses forward/backward mouse movement to move the character forward/backward, and right/left mouse movement to rotate the view right/left. I want to keep the cursor centered on the screen so that it won’t run off and stop the character’s motion. Any advice? Thanks a lot for your help. I should mention that I’m pretty new to Python. Here are the scripts I’m using for the mouse movement:

#fwd/backward movement
import bge

cont = bge.logic.getCurrentController()
owner = cont.owner

mouse = cont.sensors[“mouse.001”]
width = bge.render.getWindowWidth()
width = width/2

pos = mouse.position

posX = width - pos[0]
posX = posX0.03-1
owner.localPosition.x = posX

height = bge.render.getWindowHeight()
height = height/2

posY = height - pos[1]
posY = posY*0.05
owner.localPosition.y = posY

#rotate view
import bge
from bge import render
g = bge.logic
scene = g.getCurrentScene()

co = bge.logic.getCurrentController()
o = co.owner

#sensor
mouse = co.sensors[“mouse”]

#objects
Cube = scene.objects[“character.002”]

#mouse movement
movSpeed = 0.0001
rotSpeed = (0.0001, 0.000)

#mouse look
x = (render.getWindowWidth() / 2 - mouse.position[0])

Cube.applyRotation((0, 0, int(x) * rotSpeed[0]), False)
render.setMousePosition(int(render.getWindowWidth() / 2))

Please use code tags when posting code

Oh, sorry. Will do in the future.