当前位置: 首页>>代码示例>>Python>>正文


Python pygame.K_RETURN属性代码示例

本文整理汇总了Python中pygame.K_RETURN属性的典型用法代码示例。如果您正苦于以下问题:Python pygame.K_RETURN属性的具体用法?Python pygame.K_RETURN怎么用?Python pygame.K_RETURN使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在pygame的用法示例。


在下文中一共展示了pygame.K_RETURN属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __startInterface

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_RETURN [as 别名]
def __startInterface(self):
		clock = pygame.time.Clock()
		while True:
			for event in pygame.event.get():
				if event.type == pygame.QUIT or (event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE):
					pygame.quit()
					sys.exit(-1)
				if event.type == pygame.KEYDOWN and event.key == pygame.K_RETURN:
					return
			self.screen.fill(self.cfg.AQUA)
			text1 = 'Press <Enter> to start the game'
			text2 = 'Press <Esc> to quit the game'
			text_render1 = self.font_big.render(text1, False, self.cfg.BLUE)
			text_render2 = self.font_big.render(text2, False, self.cfg.BLUE)
			self.screen.blit(text_render1, ((self.cfg.SCREENWIDTH-text_render1.get_rect().width)//2, (self.cfg.SCREENHEIGHT-text_render1.get_rect().height)//4))
			self.screen.blit(text_render2, ((self.cfg.SCREENWIDTH-text_render2.get_rect().width)//2, (self.cfg.SCREENHEIGHT-text_render2.get_rect().height)//2))
			pygame.display.flip()
			clock.tick(30) 
开发者ID:CharlesPikachu,项目名称:Games,代码行数:20,代码来源:game.py

示例2: endInterface

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_RETURN [as 别名]
def endInterface(screen, score_left, score_right):
	clock = pygame.time.Clock()
	font1 = pygame.font.Font(config.FONTPATH, 30)
	font2 = pygame.font.Font(config.FONTPATH, 20)
	msg = 'Player on left won!' if score_left > score_right else 'Player on right won!'
	texts = [font1.render(msg, True, config.WHITE),
			 font2.render('Press ESCAPE to quit.', True, config.WHITE),
			 font2.render('Press ENTER to continue or play again.', True, config.WHITE)]
	positions = [[120, 200], [155, 270], [80, 300]]
	while True:
		screen.fill((41, 36, 33))
		for event in pygame.event.get():
			if event.type == pygame.QUIT:
				pygame.quit()
				sys.exit()
			if event.type == pygame.KEYDOWN:
				if event.key == pygame.K_RETURN:
					return
				elif event.key == pygame.K_ESCAPE:
					sys.exit()
					pygame.quit()
		for text, pos in zip(texts, positions):
			screen.blit(text, pos)
		clock.tick(10)
		pygame.display.update() 
开发者ID:CharlesPikachu,项目名称:Games,代码行数:27,代码来源:Game17.py

示例3: gameOverScreen

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_RETURN [as 别名]
def gameOverScreen(self):
        """ Show game over screen """

        global screen

        # stop game main loop (if any)
        self.running = False

        screen.fill([0, 0, 0])

        self.writeInBricks("game", [125, 140])
        self.writeInBricks("over", [125, 220])
        pygame.display.flip()

        while 1:
            time_passed = self.clock.tick(50)
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    quit()
                elif event.type == pygame.KEYDOWN:
                    if event.key == pygame.K_RETURN:
                        self.showMenu()
                        return 
开发者ID:uvipen,项目名称:AirGesture,代码行数:25,代码来源:battle_city_utils.py

示例4: _map_keys

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_RETURN [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 
开发者ID:swistakm,项目名称:pyimgui,代码行数:24,代码来源:pygame.py

示例5: handle

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_RETURN [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:
                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 char in self.digits:
                        if len(char) > 0 and lhv < self.max_len:
                            self.home_square.value += char
                        else:
                            self.home_square.value = char
                self.home_square.update_me = True
                self.mainloop.redraw_needed[0] = True 
开发者ID:imiolek-ireneusz,项目名称:eduActiv8,代码行数:20,代码来源:game031.py

示例6: handle

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_RETURN [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:
                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 char in self.digits:
                        if len(char) > 0 and lhv < 2:
                            self.home_square.value += char
                        else:
                            self.home_square.value = char
                self.home_square.update_me = True
                self.mainloop.redraw_needed[0] = True 
开发者ID:imiolek-ireneusz,项目名称:eduActiv8,代码行数:20,代码来源:game080.py

示例7: handle

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_RETURN [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() 
开发者ID:imiolek-ireneusz,项目名称:eduActiv8,代码行数:27,代码来源:game115.py

示例8: handle

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_RETURN [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() 
开发者ID:imiolek-ireneusz,项目名称:eduActiv8,代码行数:22,代码来源:game085.py

示例9: handle

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_RETURN [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, 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)
            elif 3 < active < 16:
                self.activate_factor(active-4)
            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() 
开发者ID:imiolek-ireneusz,项目名称:eduActiv8,代码行数:21,代码来源:game093.py

示例10: check_keydown_events

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_RETURN [as 别名]
def check_keydown_events(event: EventType, ai_settings: Settings
                         , stats: GameStats, game_items: GameItems):
    """Respond when key is being pressed."""
    if event.key == pygame.K_RIGHT:
        # Move ship to the right.
        game_items.ship.moving_right = True

    elif event.key == pygame.K_LEFT:
        # Move ship to the left.
        game_items.ship.moving_left = True

    elif event.key == pygame.K_SPACE:
        fire_bullet(ai_settings, game_items)

    elif event.key == pygame.K_q:
        quit_game(stats)

    elif event.key == pygame.K_RETURN:  # ENTER key
        start_new_game(ai_settings, stats, game_items) 
开发者ID:goswami-rahul,项目名称:alien-invasion-game,代码行数:21,代码来源:game_functions.py

示例11: textBoxInput

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_RETURN [as 别名]
def textBoxInput(textbox, functionToCall=None, args=[]):
    # starts grabbing key inputs, putting into textbox until enter pressed
    global keydict
    textbox.text = ""
    returnVal = None
    while True:
        updateDisplay()
        if functionToCall:
            returnVal = functionToCall(*args)
        for event in pygame.event.get():
            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_RETURN:
                    textbox.clear()
                    if returnVal:
                        return textbox.text, returnVal
                    else:
                        return textbox.text
                elif event.key == pygame.K_ESCAPE:
                    pygame.quit()
                    sys.exit()
                else:
                    textbox.update(event)
            elif event.type == pygame.QUIT:
                pygame.quit()
                sys.exit() 
开发者ID:StevePaget,项目名称:Pygame_Functions,代码行数:27,代码来源:pygame_functions.py

示例12: set_keyb_selection

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_RETURN [as 别名]
def set_keyb_selection(self, key):
        # highlight menu item by key selection
        for item in self.items:
            # item.set_italic(False)
            item.set_color(self.color)

        if self.cur_item is None:
            self.cur_item = 0
        else:
            if key == pygame.K_RETURN:
                self.go()
            elif key == pygame.K_UP:
                self.cur_item -= 1
            elif key == pygame.K_DOWN:
                self.cur_item += 1
            self.cur_item = self.cur_item % len(self.items)

        # self.items[self.cur_item].set_italic(True)
        self.items[self.cur_item].set_color(self.hcolor) 
开发者ID:kidscancode,项目名称:gamedev,代码行数:21,代码来源:demo_launcher.py

示例13: animateIntroScreen

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_RETURN [as 别名]
def animateIntroScreen(self):
        """ Slide intro (menu) screen from bottom to top
        If Enter key is pressed, finish animation immediately
        @return None
        """

        global screen

        self.drawIntroScreen(False)
        screen_cp = screen.copy()

        screen.fill([0, 0, 0])

        y = 416
        while (y > 0):
            time_passed = self.clock.tick(50)
            for event in pygame.event.get():
                if event.type == pygame.KEYDOWN:
                    if event.key == pygame.K_RETURN:
                        y = 0
                        break

            screen.blit(screen_cp, [0, y])
            pygame.display.flip()
            y -= 5

        screen.blit(screen_cp, [0, 0])
        pygame.display.flip() 
开发者ID:uvipen,项目名称:AirGesture,代码行数:30,代码来源:battle_city_utils.py

示例14: __nextLevel

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_RETURN [as 别名]
def __nextLevel(self):
		clock = pygame.time.Clock()
		while True:
			for event in pygame.event.get():
				if event.type == pygame.QUIT:
					pygame.quit()
					sys.exit(-1)
				if event.type == pygame.KEYDOWN and event.key == pygame.K_RETURN:
					return
			self.screen.fill(self.cfg.AQUA)
			text = 'Press <Enter> to enter the next level'
			text_render = self.font_big.render(text, False, self.cfg.BLUE)
			self.screen.blit(text_render, ((self.cfg.SCREENWIDTH-text_render.get_rect().width)//2, (self.cfg.SCREENHEIGHT-text_render.get_rect().height)//3))
			pygame.display.flip()
			clock.tick(30) 
开发者ID:CharlesPikachu,项目名称:Games,代码行数:17,代码来源:game.py

示例15: showText

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import K_RETURN [as 别名]
def showText(screen, font, is_clearance, flag=False):
	clock = pygame.time.Clock()
	msg = 'Game Over!' if not is_clearance else 'Congratulations, you won!'
	positions = [[235, 233], [65, 303], [170, 333]] if not is_clearance else [[145, 233], [65, 303], [170, 333]]
	surface = pygame.Surface((400, 200))
	surface.set_alpha(10)
	surface.fill((128, 128, 128))
	screen.blit(surface, (100, 200))
	texts = [font.render(msg, True, WHITE),
			 font.render('Press ENTER to continue or play again.', True, WHITE),
			 font.render('Press ESCAPE to quit.', True, WHITE)]
	while True:
		for event in pygame.event.get():
			if event.type == pygame.QUIT:
				sys.exit()
				pygame.quit()
			if event.type == pygame.KEYDOWN:
				if event.key == pygame.K_RETURN:
					if is_clearance:
						if not flag:
							return
						else:
							main(initialize())
					else:
						main(initialize())
				elif event.key == pygame.K_ESCAPE:
					sys.exit()
					pygame.quit()
		for idx, (text, position) in enumerate(zip(texts, positions)):
			screen.blit(text, position)
		pygame.display.flip()
		clock.tick(10) 
开发者ID:CharlesPikachu,项目名称:Games,代码行数:34,代码来源:Game14.py


注:本文中的pygame.K_RETURN属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。