本文整理汇总了Python中pygame.K_KP_ENTER属性的典型用法代码示例。如果您正苦于以下问题:Python pygame.K_KP_ENTER属性的具体用法?Python pygame.K_KP_ENTER怎么用?Python pygame.K_KP_ENTER使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类pygame
的用法示例。
在下文中一共展示了pygame.K_KP_ENTER属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_KP_ENTER [as 别名]
def handle(self, event):
gd.BoardGame.handle(self, event) # send event handling up
if event.type == pygame.MOUSEBUTTONDOWN and event.button == 1:
active = self.board.active_ship
if active == 0:
self.change_fract_btn(self.numbers, -1, 0)
elif active == 1:
self.change_fract_btn(self.numbers, 1, 0)
elif active == 2:
self.change_fract_btn(self.numbers, 0, -1)
elif active == 3:
self.change_fract_btn(self.numbers, 0, 1)
elif active == 4:
self.change_fract_btn(self.numbers2, -1, 0)
elif active == 5:
self.change_fract_btn(self.numbers2, 1, 0)
elif active == 6:
self.change_fract_btn(self.numbers2, 0, -1)
elif active == 7:
self.change_fract_btn(self.numbers2, 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()
示例2: handle
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_KP_ENTER [as 别名]
def handle(self, event):
gd.BoardGame.handle(self, event) # send event handling up
if not self.show_msg:
if event.type == pygame.KEYDOWN and (event.key != pygame.K_RETURN and event.key != pygame.K_KP_ENTER):
lhv = len(self.home_square.value)
self.changed_since_check = True
if event.key == pygame.K_BACKSPACE:
if lhv > 0:
self.home_square.value = self.home_square.value[0:lhv - 1]
else:
char = event.unicode
if len(char) > 0 and lhv < 3 and char in self.digits:
self.home_square.value += char
self.home_square.update_me = True
self.mainloop.redraw_needed[0] = True
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()
if event.type == pygame.MOUSEBUTTONDOWN:
self.auto_check_reset()
示例3: handle
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_KP_ENTER [as 别名]
def handle(self, event):
gd.BoardGame.handle(self, event) # send event handling up
if not self.show_msg:
if event.type == pygame.KEYDOWN and (event.key != pygame.K_RETURN and event.key != pygame.K_KP_ENTER):
lhv = len(self.home_square.value)
self.changed_since_check = True
if event.key == pygame.K_BACKSPACE:
if lhv > 0:
self.home_square.value = self.home_square.value[0:lhv - 1]
else:
char = event.unicode
if len(char) > 0 and lhv < self.sollen and char in self.digits:
self.home_square.value += char
self.home_square.update_me = True
self.mainloop.redraw_needed[0] = True
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()
if event.type == pygame.MOUSEBUTTONDOWN:
self.auto_check_reset()
示例4: handle
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_KP_ENTER [as 别名]
def handle(self, event):
gd.BoardGame.handle(self, event) # send event handling up
if event.type == pygame.MOUSEBUTTONDOWN and event.button == 1:
active = self.board.active_ship
if active == 0:
self.change_fract_btn(-1)
elif active == 1:
self.change_fract_btn(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.nm1.value)
self.changed_since_check = True
if event.key == pygame.K_BACKSPACE:
if lhv > 2:
self.nm1.value = self.nm1.value[0:lhv - 1]
else:
char = event.unicode
if len(char) > 0 and char in self.digits:
self.numbers_disp[0] = int(char)
self.nm1.set_value("0.%s" % char)
self.check_result()
self.nm1.update_me = True
self.mainloop.redraw_needed[0] = True
示例5: handle
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_KP_ENTER [as 别名]
def handle(self, event):
gd.BoardGame.handle(self, event) # send event handling up
if event.type == pygame.MOUSEBUTTONDOWN and event.button == 1:
active = self.board.active_ship
if active == 0:
self.change_fract_btn(self.numbers, -1, 0)
elif active == 1:
self.change_fract_btn(self.numbers, 1, 0)
elif active == 2:
self.change_fract_btn(self.numbers, 0, -1)
elif active == 3:
self.change_fract_btn(self.numbers, 0, 1)
elif active == 4:
self.change_fract_btn(self.numbers2, -1, 0)
elif active == 5:
self.change_fract_btn(self.numbers2, 1, 0)
elif active == 6:
self.change_fract_btn(self.numbers2, 0, -1)
elif active == 7:
self.change_fract_btn(self.numbers2, 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()
示例6: handle
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_KP_ENTER [as 别名]
def handle(self, event):
gd.BoardGame.handle(self, event) # send event handling up
if event.type == pygame.MOUSEBUTTONDOWN and event.button == 1:
active = self.board.active_ship
if self.missing_number == 1:
if active == 0:
self.change_fract_btn(-1, 0)
elif active == 1:
self.change_fract_btn(1, 0)
else:
if active == 0:
self.change_fract_btn(0, -1)
elif active == 1:
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:
lhv = len(self.active_num.value)
self.changed_since_check = True
if event.key == pygame.K_BACKSPACE:
if lhv > 0:
self.active_num.value = self.active_num.value[0:lhv - 1]
else:
char = event.unicode
if self.typed and len(char) > 0 and lhv < 3 and char in self.digits:
self.active_num.value += char
elif char in self.digits:
self.active_num.value = char
self.typed = True
if len(self.active_num.value) > 0:
self.result[self.missing_number - 1] = int(self.active_num.value)
else:
self.result[self.missing_number - 1] = 0
self.active_num.update_me = True
self.mainloop.redraw_needed[0] = True
self.auto_check_reset()
示例7: handle
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_KP_ENTER [as 别名]
def handle(self, event):
gd.BoardGame.handle(self, event)
if not self.show_msg:
if event.type == pygame.KEYDOWN and (event.key != pygame.K_RETURN and event.key != pygame.K_KP_ENTER):
lhv = len(self.home_square.value)
self.changed_since_check = True
if event.key == pygame.K_BACKSPACE:
if lhv > 0:
self.home_square.value = self.home_square.value[0:lhv - 1]
elif not self.board.grid[4][18]:
char = event.unicode
if len(char) > 0 and char in self.digits:
self.home_square.value = char
self.home_square.update_me = True
self.mainloop.redraw_needed[0] = True
elif event.type == pygame.MOUSEMOTION and self.drag:
if self.board.grid[4][18]:
self.home_square.value = ""
self.home_square.update_me = True
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)
if self.board.grid[4][18]:
self.check_result()
self.home_square.value = ""
self.home_square.update_me = True
elif event.type == pygame.KEYDOWN and (event.key == pygame.K_RETURN or event.key == pygame.K_KP_ENTER):
self.check_result()
if event.type == pygame.MOUSEBUTTONDOWN:
self.auto_check_reset()
if event.type == pygame.MOUSEMOTION or event.type == pygame.MOUSEBUTTONUP:
self.default_hover(event)
示例8: handle
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_KP_ENTER [as 别名]
def handle(self, event):
gd.BoardGame.handle(self, event) # send event handling up
if event.type == pygame.MOUSEBUTTONDOWN and event.button == 1:
active = self.board.active_ship
if active == 0:
self.change_fract_btn(self.numbers, -1, 0)
elif active == 1:
self.change_fract_btn(self.numbers, 1, 0)
elif active == 2:
self.change_fract_btn(self.numbers, 0, -1)
elif active == 3:
self.change_fract_btn(self.numbers, 0, 1)
elif active == 4:
self.change_fract_btn2(self.numbers2, -1, 0)
elif active == 5:
self.change_fract_btn2(self.numbers2, 1, 0)
elif active == 6:
self.change_fract_btn2(self.numbers2, 0, -1)
elif active == 7:
self.change_fract_btn2(self.numbers2, 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()
示例9: handle
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_KP_ENTER [as 别名]
def handle(self, event):
gd.BoardGame.handle(self, event)
if not self.show_msg:
if event.type == pygame.KEYDOWN and (event.key != pygame.K_RETURN and event.key != pygame.K_KP_ENTER):
lhv = len(self.home_square.value)
self.changed_since_check = True
if event.key == pygame.K_BACKSPACE:
if lhv > 0:
self.home_square.value = self.home_square.value[0:lhv - 1]
elif not self.board.grid[4][16]:
char = event.unicode
if len(char) > 0 and char in self.digits:
self.home_square.value = char
self.home_square.update_me = True
self.mainloop.redraw_needed[0] = True
elif event.type == pygame.MOUSEMOTION and self.drag:
if self.board.grid[4][16]:
self.home_square.value = ""
self.home_square.update_me = True
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)
if self.board.grid[4][16]:
self.home_square.value = ""
self.home_square.update_me = True
self.check_result()
elif event.type == pygame.KEYDOWN and (event.key == pygame.K_RETURN or event.key == pygame.K_KP_ENTER):
self.check_result()
if event.type == pygame.MOUSEBUTTONDOWN:
self.auto_check_reset()
if event.type == pygame.MOUSEMOTION or event.type == pygame.MOUSEBUTTONUP:
self.default_hover(event)
示例10: handle
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_KP_ENTER [as 别名]
def handle(self, event):
gd.BoardGame.handle(self, event)
if not self.show_msg:
if event.type == pygame.KEYDOWN and (event.key != pygame.K_RETURN and event.key != pygame.K_KP_ENTER):
lhv = len(self.home_square.value)
self.changed_since_check = True
if event.key == pygame.K_BACKSPACE:
if lhv > 0:
self.home_square.value = self.home_square.value[0:lhv - 1]
elif not self.board.grid[4][18]:
char = event.unicode
if len(char) > 0 and lhv < 2 and char in self.digits:
self.home_square.value += char
self.home_square.update_me = True
self.mainloop.redraw_needed[0] = True
elif event.type == pygame.MOUSEMOTION and self.drag:
if self.board.grid[4][18]:
self.home_square.value = ""
self.home_square.update_me = True
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)
if self.board.grid[4][18]:
self.check_result()
elif event.type == pygame.KEYDOWN and (event.key == pygame.K_RETURN or event.key == pygame.K_KP_ENTER):
self.check_result()
if event.type == pygame.MOUSEBUTTONDOWN:
self.auto_check_reset()
if event.type == pygame.MOUSEMOTION or event.type == pygame.MOUSEBUTTONUP:
self.default_hover(event)
示例11: onKeyDown
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_KP_ENTER [as 别名]
def onKeyDown(self, event):
if not self.select_item:
if event.type == pygame.KEYDOWN and event.key == pygame.K_DELETE:
pass
elif event.type == pygame.KEYDOWN and event.key != pygame.K_RETURN and event.key != pygame.K_KP_ENTER and event.key != pygame.K_TAB:
lhv = len(self.value)
if event.key == pygame.K_BACKSPACE:
if lhv > 0:
if self.ls.lang.ltr_text:
self.value = self.value[0:lhv - 1]
else:
self.value = self.value[1:lhv]
else:
char = event.unicode
if len(char) > 0 and lhv < 21:
if self.ls.lang.ltr_text:
self.value = self.value + char
else:
self.value = char + self.value
if self.selection_modifier:
if self.ls.prev_user_checked:
if self.value != self.ls.prev_user_checked.value:
self.ls.prev_user_checked.update_me = True
self.ls.prev_user_checked.checked = False
self.ls.reload_selects()
self.ls.set_scrollbar_top(self.ls.scroll_min_top)
elif event.key == pygame.K_RETURN or event.key == pygame.K_KP_ENTER or event.key == pygame.K_TAB:
self.nextFocus()
self.update_trigger()
示例12: __pgbox
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_KP_ENTER [as 别名]
def __pgbox(title, message):
try:
import pygame as pg
pg.quit() #clean out anything running
pg.display.init()
pg.font.init()
screen = pg.display.set_mode((460, 140))
pg.display.set_caption(title)
font = pg.font.Font(None, 18)
foreg, backg, liteg = (0, 0, 0), (180, 180, 180), (210, 210, 210)
ok = font.render('Ok', 1, foreg, liteg)
okbox = ok.get_rect().inflate(200, 10)
okbox.centerx = screen.get_rect().centerx
okbox.bottom = screen.get_rect().bottom - 10
screen.fill(backg)
screen.fill(liteg, okbox)
screen.blit(ok, okbox.inflate(-200, -10))
pos = [10, 10]
for text in message.split('\n'):
if text:
msg = font.render(text, 1, foreg, backg)
screen.blit(msg, pos)
pos[1] += font.get_height()
pg.display.flip()
stopkeys = pg.K_ESCAPE, pg.K_SPACE, pg.K_RETURN, pg.K_KP_ENTER
while 1:
e = pg.event.wait()
if e.type == pg.QUIT or \
(e.type == pg.KEYDOWN and e.key in stopkeys) or \
(e.type == pg.MOUSEBUTTONDOWN and okbox.collidepoint(e.pos)):
break
pg.quit()
except pg.error:
raise ImportError
示例13: __human_control
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_KP_ENTER [as 别名]
def __human_control(self, key):
if self.player1_human_control and self.player2_human_control:
if self.two_players:
if key == pygame.K_LEFT:
self.player1.move(GlobalConstants.LEFT_ACTION, self.sprites)
if key == pygame.K_RIGHT:
self.player1.move(GlobalConstants.RIGHT_ACTION, self.sprites)
if key == pygame.K_UP:
self.player1.move(GlobalConstants.UP_ACTION, self.sprites)
if key == pygame.K_DOWN:
self.player1.move(GlobalConstants.DOWN_ACTION, self.sprites)
if key == pygame.K_KP_ENTER:
self.__fire_bullet(self.player1, False)
if key == pygame.K_a:
self.player2.move(GlobalConstants.LEFT_ACTION, self.sprites)
if key == pygame.K_d:
self.player2.move(GlobalConstants.RIGHT_ACTION, self.sprites)
if key == pygame.K_w:
self.player2.move(GlobalConstants.UP_ACTION, self.sprites)
if key == pygame.K_s:
self.player2.move(GlobalConstants.DOWN_ACTION, self.sprites)
if key == pygame.K_SPACE:
self.__fire_bullet(self.player2, False)
else:
if key == pygame.K_LEFT:
self.player1.move(GlobalConstants.LEFT_ACTION, self.sprites)
if key == pygame.K_RIGHT:
self.player1.move(GlobalConstants.RIGHT_ACTION, self.sprites)
if key == pygame.K_UP:
self.player1.move(GlobalConstants.UP_ACTION, self.sprites)
if key == pygame.K_DOWN:
self.player1.move(GlobalConstants.DOWN_ACTION, self.sprites)
if key == pygame.K_SPACE:
self.__fire_bullet(self.player1, False)
else:
if not self.player1_human_control:
if self.two_players:
if key == pygame.K_LEFT:
self.player2.move(GlobalConstants.LEFT_ACTION, self.sprites)
if key == pygame.K_RIGHT:
self.player2.move(GlobalConstants.RIGHT_ACTION, self.sprites)
if key == pygame.K_UP:
self.player2.move(GlobalConstants.UP_ACTION, self.sprites)
if key == pygame.K_DOWN:
self.player2.move(GlobalConstants.DOWN_ACTION, self.sprites)
if key == pygame.K_SPACE:
self.__fire_bullet(self.player2, False)
else:
if key == pygame.K_LEFT:
self.player1.move(GlobalConstants.LEFT_ACTION, self.sprites)
if key == pygame.K_RIGHT:
self.player1.move(GlobalConstants.RIGHT_ACTION, self.sprites)
if key == pygame.K_UP:
self.player1.move(GlobalConstants.UP_ACTION, self.sprites)
if key == pygame.K_DOWN:
self.player1.move(GlobalConstants.DOWN_ACTION, self.sprites)
if key == pygame.K_SPACE:
self.__fire_bullet(self.player1, False)
示例14: handle
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_KP_ENTER [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
示例15: handle
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_KP_ENTER [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