It's difficult to move the cycle when the camera doesn't go with it, so we're going to make the camera move with the cycle and while we're at it we can set up some zoom in and zoom out controls using the mouse buttons.
For starters, we'll disable the default camera controls. Add this code just below our variable declarations in the
__init__
method.base.disableMouse()
After that, put this code into the
__init__
method right below the line that callsself.cycle.setPos
.base.camera.reparentTo(self.cycle) base.camera.setY(base.camera, -5)
Now, we need to expand our key map to include the left and right mouse buttons. Change the key map definition to the following:
self.keyMap = {"w" : False, "s" : False, "a" : False, "d" : False, "mouse1" : False, "mouse3" : False}
Naturally, we also need to register the mouse-click events. Add the following two lines at the very bottom of the...