本文整理汇总了Python中pygame.K_TAB属性的典型用法代码示例。如果您正苦于以下问题:Python pygame.K_TAB属性的具体用法?Python pygame.K_TAB怎么用?Python pygame.K_TAB使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类pygame
的用法示例。
在下文中一共展示了pygame.K_TAB属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _map_keys
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_TAB [as 别名]
def _map_keys(self):
key_map = self.io.key_map
key_map[imgui.KEY_TAB] = pygame.K_TAB
key_map[imgui.KEY_LEFT_ARROW] = pygame.K_LEFT
key_map[imgui.KEY_RIGHT_ARROW] = pygame.K_RIGHT
key_map[imgui.KEY_UP_ARROW] = pygame.K_UP
key_map[imgui.KEY_DOWN_ARROW] = pygame.K_DOWN
key_map[imgui.KEY_PAGE_UP] = pygame.K_PAGEUP
key_map[imgui.KEY_PAGE_DOWN] = pygame.K_PAGEDOWN
key_map[imgui.KEY_HOME] = pygame.K_HOME
key_map[imgui.KEY_END] = pygame.K_END
key_map[imgui.KEY_DELETE] = pygame.K_DELETE
key_map[imgui.KEY_BACKSPACE] = pygame.K_BACKSPACE
key_map[imgui.KEY_ENTER] = pygame.K_RETURN
key_map[imgui.KEY_ESCAPE] = pygame.K_ESCAPE
key_map[imgui.KEY_A] = pygame.K_a
key_map[imgui.KEY_C] = pygame.K_c
key_map[imgui.KEY_V] = pygame.K_v
key_map[imgui.KEY_X] = pygame.K_x
key_map[imgui.KEY_Y] = pygame.K_y
key_map[imgui.KEY_Z] = pygame.K_z
示例2: play
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_TAB [as 别名]
def play(self, file):
self.memory = np.load(file)
i = 0
stop = False
flag = 0
while True:
self.time = self.memory[i].time
self.cars = self.memory[i].cars
self.car_num = len(self.cars)
self.compet_info = self.memory[i].compet_info
self.detect = self.memory[i].detect
self.vision = self.memory[i].vision
self.bullets = self.memory[i].bullets
for event in pygame.event.get():
if event.type == pygame.QUIT:
return
pressed = pygame.key.get_pressed()
if pressed[pygame.K_TAB]: self.dev = True
else: self.dev = False
self.one_epoch()
if pressed[pygame.K_SPACE] and not flag:
flag = 50
stop = not stop
if flag > 0: flag -= 1
if pressed[pygame.K_LEFT] and i > 10: i -= 10
if pressed[pygame.K_RIGHT] and i < len(self.memory)-10: i += 10
if i < len(self.memory)-1 and not stop: i += 1
self.clock.tick(200)
示例3: get_order
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_TAB [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
示例4: debugLoop
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_TAB [as 别名]
def debugLoop(self):
self.draw()
pygame.display.update()
try:
for event in pygame.event.get():
if event.type == pygame.QUIT:
self.exit_status = 1
self.debug_mode = False
if event.type == pygame.KEYDOWN:
if (event.key == pygame.K_LSHIFT or event.key == pygame.K_RSHIFT):
self.debug_mode = False
elif event.key == pygame.K_TAB:
self.debug_console.set_trace() #Drop into the console
elif event.key == pygame.K_LEFT:
self.cameraX = -5
elif event.key == pygame.K_RIGHT:
self.cameraX = 5
elif event.key == pygame.K_UP:
self.cameraY = -5
elif event.key == pygame.K_DOWN:
self.cameraY = 5
elif event.key == pygame.K_z:
self.zoomVal = 0.01
elif event.key == pygame.K_x:
self.zoomVal = -0.01
elif event.type == pygame.KEYUP:
if event.key == pygame.K_LEFT or event.key == pygame.K_RIGHT:
self.cameraX = 0
elif event.key == pygame.K_UP or event.key == pygame.K_DOWN:
self.cameraY = 0
elif event.key == pygame.K_z or event.key == pygame.K_x:
self.zoomVal = 0
for cont in self.controllers:
cont.getInputs(event)
self.stage.moveCamera(self.cameraX,self.cameraY)
self.stage.zoomCamera(self.zoomVal)
except bdb.BdbQuit:
pass
示例5: handle
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_TAB [as 别名]
def handle(self, event):
gd.BoardGame.handle(self, event) # send event handling up
if event.type == pygame.MOUSEBUTTONDOWN and event.button == 1:
pos = [event.pos[0] - self.layout.game_left, event.pos[1] - self.layout.top_margin]
for each in self.text_fields:
if each.rect.topleft[0] < pos[0] < each.rect.topleft[0] + each.rect.width and \
each.rect.topleft[1] < pos[1] < each.rect.topleft[1] + each.rect.height:
self.toggle_active_fract(each)
active = self.board.active_ship
if active == 0:
self.change_fract_btn(self.response, -1, 0)
elif active == 1:
self.change_fract_btn(self.response, 1, 0)
elif active == 2:
self.change_fract_btn(self.response, 0, -1)
elif active == 3:
self.change_fract_btn(self.response, 0, 1)
self.auto_check_reset()
elif event.type == pygame.KEYDOWN and (event.key == pygame.K_RETURN or event.key == pygame.K_KP_ENTER):
self.check_result()
elif event.type == pygame.KEYDOWN:
self.auto_check_reset()
lhv = len(self.current_txt)
self.changed_since_check = True
if event.key == pygame.K_BACKSPACE:
if lhv > 0:
self.current_txt = self.current_txt[0:lhv - 1]
self.active_fract.value = self.current_txt
self.active_fract.update_me = True
if len(self.current_txt) > 0:
if self.active_fract == self.sm1a:
self.response[0] = int(self.active_fract.value)
elif self.active_fract == self.sm1b:
self.response[1] = int(self.active_fract.value)
elif event.key == pygame.K_TAB:
if self.active_fract == self.sm1a:
self.toggle_active_fract(self.sm1b)
else:
self.toggle_active_fract(self.sm1a)
else:
char = event.unicode
if char in self.digits:
if len(char) > 0 and lhv < 3 and self.active_fract.value != self.qm:
self.current_txt += char
else:
self.current_txt = char
self.active_fract.value = self.current_txt
if self.active_fract == self.sm1a:
self.response[0] = int(self.active_fract.value)
if self.response[0] == self.sum_numbers[0]:
self.toggle_active_fract(self.sm1b)
elif self.active_fract == self.sm1b:
self.response[1] = int(self.active_fract.value)
self.active_fract.update_me = True
self.mainloop.redraw_needed[0] = True
示例6: handle
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_TAB [as 别名]
def handle(self, event):
gd.BoardGame.handle(self, event) # send event handling up
if event.type == pygame.MOUSEBUTTONDOWN and event.button == 1:
pos = [event.pos[0] - self.layout.game_left, event.pos[1] - self.layout.top_margin]
if self.nm1.rect.topleft[0] < pos[0] < self.nm1.rect.topleft[0] + self.nm1.rect.width and \
self.nm1.rect.topleft[1] < pos[1] < self.nm1.rect.topleft[1] + self.nm1.rect.height:
self.toggle_active_fract(self.nm1, self.nm2)
elif self.nm2.rect.topleft[0] < pos[0] < self.nm2.rect.topleft[0] + self.nm2.rect.width and \
self.nm2.rect.topleft[1] < pos[1] < self.nm2.rect.topleft[1] + self.nm2.rect.height:
self.toggle_active_fract(self.nm2, self.nm1)
active = self.board.active_ship
if active == 0:
self.change_fract_btn(-1, 0)
elif active == 1:
self.change_fract_btn(1, 0)
elif active == 2:
self.change_fract_btn(0, -1)
elif active == 3:
self.change_fract_btn(0, 1)
self.auto_check_reset()
elif event.type == pygame.KEYDOWN and (event.key == pygame.K_RETURN or event.key == pygame.K_KP_ENTER):
self.check_result()
elif event.type == pygame.KEYDOWN:
self.auto_check_reset()
lhv = len(self.active_fract.value)
self.changed_since_check = True
if event.key == pygame.K_BACKSPACE:
if lhv > 0:
self.active_fract.value = self.active_fract.value[0:lhv - 1]
elif event.key == pygame.K_TAB:
if self.active_fract == self.nm1:
self.toggle_active_fract(self.nm2, self.nm1)
else:
self.toggle_active_fract(self.nm1, self.nm2)
else:
char = event.unicode
if len(char) > 0 and char in self.digits:
self.active_fract.set_value("%s" % char)
if self.active_fract == self.nm1:
self.numbers_disp[0] = int(char)
self.toggle_active_fract(self.nm2, self.nm1)
else:
self.numbers_disp[1] = int(char)
self.toggle_active_fract(self.nm1, self.nm2)
if self.nm1.value != self.qm and self.nm2.value != self.qm:
self.check_result()
self.mainloop.redraw_needed[0] = True
示例7: handle
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_TAB [as 别名]
def handle(self, event):
gd.BoardGame.handle(self, event) # send event handling up
if event.type == pygame.MOUSEBUTTONDOWN and event.button == 1:
pos = [event.pos[0] - self.layout.game_left, event.pos[1] - self.layout.top_margin]
self.auto_check_reset()
for each in self.units:
if each.rect.topleft[0] < pos[0] < each.rect.topleft[0] + each.rect.width and \
each.rect.topleft[1] < pos[1] < each.rect.topleft[1] + each.rect.height:
self.toggle_active_unit(each)
elif event.type == pygame.MOUSEBUTTONUP:
for each in self.board.units:
if each.is_door is True:
self.board.all_sprites_list.move_to_front(each)
self.mainloop.redraw_needed[0] = True
if not self.show_msg:
if event.type == pygame.KEYDOWN and (event.key != pygame.K_RETURN and event.key != pygame.K_KP_ENTER):
if self.active_unit in self.units:
self.auto_check_reset()
lhv = len(self.active_unit.value)
self.changed_since_check = True
if event.key == pygame.K_BACKSPACE:
if lhv > 0:
self.active_unit.value = self.active_unit.value[0:lhv - 1]
else:
char = event.unicode
if len(char) > 0 and ((char in self.digits) or (lhv == 0 and self.allow_dash and char == "-")):
if lhv < self.imput_limit:
self.active_unit.value += char
else:
self.active_unit.value = char
self.active_unit.update_me = True
self.mainloop.redraw_needed[0] = True
if event.type == pygame.KEYDOWN and (event.key == pygame.K_RETURN or event.key == pygame.K_KP_ENTER or
event.key == pygame.K_TAB or event.key == pygame.K_DOWN):
if self.all_completed():
self.custom_check_result()
if self.active_unit is not None:
self.toggle_active_unit(self.units[(self.active_unit.id + 1) % 5])
elif event.type == pygame.KEYDOWN and event.key == pygame.K_UP:
if self.active_unit is not None:
self.toggle_active_unit(self.units[(self.active_unit.id + 4) % 5])
if event.type == pygame.MOUSEMOTION or event.type == pygame.MOUSEBUTTONUP:
self.default_hover(event)
示例8: handle
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_TAB [as 别名]
def handle(self, event):
gd.BoardGame.handle(self, event) # send event handling up
if event.type == pygame.MOUSEBUTTONDOWN and event.button == 1:
pos = [event.pos[0] - self.layout.game_left, event.pos[1] - self.layout.top_margin]
self.auto_check_reset()
for each in self.units:
if each.rect.topleft[0] < pos[0] < each.rect.topleft[0] + each.rect.width and \
each.rect.topleft[1] < pos[1] < each.rect.topleft[1] + each.rect.height:
self.toggle_active_unit(each)
elif event.type == pygame.MOUSEBUTTONUP:
for each in self.board.units:
if each.is_door is True:
self.board.all_sprites_list.move_to_front(each)
self.mainloop.redraw_needed[0] = True
if not self.show_msg:
if event.type == pygame.KEYDOWN and (event.key != pygame.K_RETURN and event.key != pygame.K_KP_ENTER):
if self.active_unit in self.units:
self.auto_check_reset()
lhv = len(self.active_unit.value)
self.changed_since_check = True
if event.key == pygame.K_BACKSPACE:
if lhv > 0:
self.active_unit.value = self.active_unit.value[0:lhv - 1]
else:
char = event.unicode
if len(char) > 0 and ((char in self.digits) or (lhv == 0 and self.allow_dash and char == "-")):
if lhv < self.imput_limit:
self.active_unit.value += char
else:
self.active_unit.value = char
self.active_unit.update_me = True
self.mainloop.redraw_needed[0] = True
if event.type == pygame.KEYDOWN and (event.key == pygame.K_RETURN or event.key == pygame.K_KP_ENTER or
event.key == pygame.K_TAB or event.key == pygame.K_DOWN):
if self.all_completed():
self.custom_check_result()
if self.active_unit is not None:
self.toggle_active_unit(self.units[(self.active_unit.id + 1) % 5])
elif event.type == pygame.KEYDOWN and event.key == pygame.K_UP:
if self.active_unit is not None:
self.toggle_active_unit(self.units[(self.active_unit.id + 4) % 5])
if event.type == pygame.MOUSEMOTION or event.type == pygame.MOUSEBUTTONUP:
self.default_hover(event)