本文整理汇总了Python中Input.keyRelease方法的典型用法代码示例。如果您正苦于以下问题:Python Input.keyRelease方法的具体用法?Python Input.keyRelease怎么用?Python Input.keyRelease使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Input
的用法示例。
在下文中一共展示了Input.keyRelease方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import Input [as 别名]
# 或者: from Input import keyRelease [as 别名]
class Controller:
mouseSensitivity = 0.15
movementSpeed = 0.005
def __init__(self):
self.model = None
self.view = None
self.running = True
self.t = pygame.time.get_ticks()
self.input = Input()
self.wireframe = False
#self.input.mouseEntersScreen = lambda: pygame.mouse.set_pos(640/2, 480/2)
def update(self):
tiempoActual = pygame.time.get_ticks()
dt = tiempoActual - self.t
self.t = tiempoActual
(mouseX,mouseY) = pygame.mouse.get_pos()
(dx,dy) = pygame.mouse.get_rel()
self.input.update()
if self.input.isCloseRequested:
self.running = False
if self.input.keyPress(pygame.K_ESCAPE):
self.running = False
self.view.camera.yaw(dx * Controller.mouseSensitivity)
self.view.camera.pitch(dy * Controller.mouseSensitivity)
if self.input.keyRelease(pygame.K_f):
pygame.display.toggle_fullscreen()
self.view.reshape()
if self.input.keyHold(pygame.K_w):
self.view.camera.walkForward(Controller.movementSpeed*dt)
if self.input.keyHold(pygame.K_s):
self.view.camera.walkBackwards(Controller.movementSpeed*dt)
if self.input.keyHold(pygame.K_a):
self.view.camera.strafeLeft(Controller.movementSpeed*dt)
if self.input.keyHold(pygame.K_d):
self.view.camera.strafeRight(Controller.movementSpeed*dt)
if self.input.keyHold(pygame.K_SPACE):
self.view.camera.moveUp(Controller.movementSpeed*dt)
if self.input.keyHold(pygame.K_LSHIFT):
self.view.camera.moveDown(Controller.movementSpeed*dt)
if (not self.wireframe) and self.input.keyPress(pygame.K_p):
glPolygonMode( GL_FRONT_AND_BACK, GL_LINE )
self.wireframe = True
elif self.wireframe and self.input.keyPress(pygame.K_p):
glPolygonMode( GL_FRONT_AND_BACK, GL_FILL )
self.wireframe = False
fx,fy,fz = self.view.camera.getFocus()
fx,fy,fz = int(fx),int(fy),int(fz)
if self.input.buttonPress(1):
#print fx,fy,fz
self.model.set(fx,fy,fz,4)
elif self.input.buttonPress(3):
#print fx,fy,fz
self.model.set(fx,fy,fz,0)
def close(self):
pygame.quit()