Questions about First Person Shooter

So, I have few questions…

  1. whenever I want to use base.win.getPointer(), I have to put 0 inside the parameter. Does anyone know why you have to put 0?

  2. This code is from here. (youtube.com/watch?v=pKhmXZ9Aejg)

    def mouseUpdate(self,task):
        md = base.win.getPointer(0)
        x = md.getX()
        y = md.getY()
        if base.win.movePointer(0, base.win.getXSize()/2, base.win.getYSize()/2):
            self.node.setH(self.node.getH() -  (x - base.win.getXSize()/2)*0.3)
            self.node.setP(self.node.getP() - (y - base.win.getYSize()/2)*0.3)
        return task.cont

(self.node is just a nodepath that is child to the camera.)

My questions is, I don’t understand this line

if base.win.movePointer(0, base.win.getXSize()/2, base.win.getYSize()/2):

Why is this working? I don’t understand why ‘if’ statement is used with base.win.movePointer…
and why do you put 0?

  1. In some cases, there can be more than one pointer, especially when enabling raw mouse support. 0 always refers to the system mouse pointer.

  2. Well, you put 0 in movePointer because you want to move the aforementioned system pointer.

The reason why there’s an “if” is that movePointer isn’t guaranteed to succeed at moving the pointer. If the mouse is outside the window, or if the window is minimized, the operating system won’t allow Panda to move the pointer. So, if it fails, it returns False. In this case, you usually don’t want to keep spinning the camera around endlessly, so the code decides not to update the camera unless it succeeds in moving the pointer.