本文整理匯總了Python中pygame.K_m方法的典型用法代碼示例。如果您正苦於以下問題:Python pygame.K_m方法的具體用法?Python pygame.K_m怎麽用?Python pygame.K_m使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pygame
的用法示例。
在下文中一共展示了pygame.K_m方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: handle_event
# 需要導入模塊: import pygame [as 別名]
# 或者: from pygame import K_m [as 別名]
def handle_event(self, event: pygame.event.EventType) -> None:
"""
Handle pygame events for moving and zooming in the displayed area.
:param event: a pygame event
"""
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_l:
self.scaling *= 1 / self.SCALING_FACTOR
if event.key == pygame.K_o:
self.scaling *= self.SCALING_FACTOR
if event.key == pygame.K_m:
self.centering_position[0] -= self.MOVING_FACTOR
if event.key == pygame.K_k:
self.centering_position[0] += self.MOVING_FACTOR
示例2: get_order
# 需要導入模塊: import pygame [as 別名]
# 或者: from pygame import K_m [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