本文整理汇总了Python中pygame.K_e方法的典型用法代码示例。如果您正苦于以下问题:Python pygame.K_e方法的具体用法?Python pygame.K_e怎么用?Python pygame.K_e使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pygame
的用法示例。
在下文中一共展示了pygame.K_e方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: key_event_up
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_e [as 别名]
def key_event_up(event):
global penSize, undoed, holdingCTRL, colorScheme, selectedTool
if event.key == pg.K_1:
colorScheme = 1
elif event.key == pg.K_2:
colorScheme = 2
if event.key == pg.K_e:
selectedTool = 1
B_Buttons[1].clicked = True
for subbutton in B_Buttons:
if B_Buttons.index(subbutton) != selectedTool:
subbutton.clicked = False
elif event.key == pg.K_b:
selectedTool = 0
B_Buttons[0].clicked = True
for subbutton in B_Buttons:
if B_Buttons.index(subbutton) != selectedTool:
subbutton.clicked = False
elif event.key == pg.K_g:
selectedTool = 2
B_Buttons[2].clicked = True
for subbutton in B_Buttons:
if B_Buttons.index(subbutton) != selectedTool:
subbutton.clicked = False
elif event.key == pg.K_i:
selectedTool = 3
B_Buttons[3].clicked = True
for subbutton in B_Buttons:
if B_Buttons.index(subbutton) != selectedTool:
subbutton.clicked = False
if event.key == pg.K_LCTRL:
holdingCTRL = False
if event.key == pg.K_SPACE:
if holdingCTRL:
g1.clean()
undoed = True
if event.key == pg.K_s:
if holdingCTRL:
shortcutPath = FileManager(1)
SaveFile(g1, shortcutPath)
if event.key == pg.K_z:
if holdingCTRL:
for i in range(g1.yCount):
for j in range(g1.xCount):
if round == 1:
g1.change_color(j, i, g1.undoList[1][i][j])
if round == -1:
g1.change_color(j, i, g1.undoList[0][i][j])
undoed = True
示例2: get_order
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_e [as 别名]
def get_order(self):
# get order from controler
for event in pygame.event.get():
if event.type == pygame.QUIT:
return True
pressed = pygame.key.get_pressed()
if pressed[pygame.K_1]: self.n = 0
if pressed[pygame.K_2]: self.n = 1
if pressed[pygame.K_3]: self.n = 2
if pressed[pygame.K_4]: self.n = 3
self.orders[self.n] = 0
if pressed[pygame.K_w]: self.orders[self.n, 0] += 1
if pressed[pygame.K_s]: self.orders[self.n, 0] -= 1
if pressed[pygame.K_q]: self.orders[self.n, 1] -= 1
if pressed[pygame.K_e]: self.orders[self.n, 1] += 1
if pressed[pygame.K_a]: self.orders[self.n, 2] -= 1
if pressed[pygame.K_d]: self.orders[self.n, 2] += 1
if pressed[pygame.K_b]: self.orders[self.n, 3] -= 1
if pressed[pygame.K_m]: self.orders[self.n, 3] += 1
if pressed[pygame.K_SPACE]: self.orders[self.n, 4] = 1
else: self.orders[self.n, 4] = 0
if pressed[pygame.K_f]: self.orders[self.n, 5] = 1
else: self.orders[self.n, 5] = 0
if pressed[pygame.K_r]: self.orders[self.n, 6] = 1
else: self.orders[self.n, 6] = 0
if pressed[pygame.K_n]: self.orders[self.n, 7] = 1
else: self.orders[self.n, 7] = 0
if pressed[pygame.K_TAB]: self.dev = True
else: self.dev = False
return False
示例3: __init__
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_e [as 别名]
def __init__(self, input, target):
super().__init__()
self.input = input
self.target = target
# forward vector stays level with horizontal plane
self.forward = np.array( [0, 0, -1] )
# up vector is constant
self.up = np.array( [0,1,0] )
# recalculate right vector whenever forward vector changes
self.right = np.cross( self.forward, self.up )
# control rate of movement
self.deltaTime = 1.0/60.0 # TODO: get actual number from input?
self.unitsPerSecond = 1
self.moveAmount = self.unitsPerSecond * self.deltaTime
self.degreesPerSecond = 60
self.turnAmount = self.degreesPerSecond * (3.1415926 / 180) * self.deltaTime
# customizable key mappings
# standard controls (WASDRF, QETG)
self.KEY_MOVE_FORWARDS = pygame.K_w
self.KEY_MOVE_BACKWARDS = pygame.K_s
self.KEY_MOVE_LEFT = pygame.K_a
self.KEY_MOVE_RIGHT = pygame.K_d
self.KEY_MOVE_UP = pygame.K_r
self.KEY_MOVE_DOWN = pygame.K_f
self.KEY_TURN_LEFT = pygame.K_q
self.KEY_TURN_RIGHT = pygame.K_e
self.KEY_LOOK_UP = pygame.K_t
self.KEY_LOOK_DOWN = pygame.K_g
示例4: find_print_event
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_e [as 别名]
def find_print_event(self, events):
"""Return the first found event if found in the list.
"""
for event in events:
if event.type == pygame.KEYDOWN and event.key == pygame.K_e\
and pygame.key.get_mods() & pygame.KMOD_CTRL:
return event
if event.type == pygame.MOUSEBUTTONUP and event.button in (1, 2, 3):
# Don't consider the mouse wheel (button 4 & 5):
rect = self._window.get_rect()
if pygame.Rect(rect.width // 2, 0, rect.width // 2, rect.height).collidepoint(event.pos):
return event
if event.type == BUTTONDOWN and event.printer:
return event
return None