Python pygame 模块,K_SPACE 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用pygame.K_SPACE

项目:pyclimber    作者:manixaist    | 项目源码 | 文件源码
def check_keyup_events(settings, event, screen, tile_map):
    player = tile_map.player
    if event.key == pygame.K_SPACE:
        if not player.idle_top:
            if player.falling == False:
                player.dy = settings.player_jump_velocity
                player.falling = True
            elif player.air_jumps < player.max_air_jumps:
                player.dy = settings.player_air_jump_velocity
                player.air_jumps += 1

    if event.key == pygame.K_LEFT:
        if not player.idle_top:
            if player.dx != 0.0:
                player.dx = 0.0

    if event.key == pygame.K_RIGHT:
        if not player.idle_top:
            if player.dx != 0.0:
                player.dx = 0.0
项目:LD39    作者:Bobsleigh    | 项目源码 | 文件源码
def notify(self, event):
        if self.isActivated:
            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_UP:
                    self.optionList[self.selector.selectedIndex].deselect()
                    self.selector.moveUp()
                    self.scrollUp()
                    self.optionList[self.selector.selectedIndex].select()
                elif event.key == pygame.K_DOWN:
                    self.optionList[self.selector.selectedIndex].deselect()
                    self.selector.moveDown()
                    self.scrollDown()
                    self.optionList[self.selector.selectedIndex].select()
                elif event.key == pygame.K_SPACE:
                    self.chosenOptionIndex = self.selectedIndex()
                    self.isActivated = False
                elif event.key == pygame.K_RETURN:
                    self.chosenOptionIndex = self.selectedIndex()
                    self.isActivated = False
项目:Jeff-Long-Run    作者:matthiasrigaud    | 项目源码 | 文件源码
def manager(jeff, field, frame, level_select):
    for event in pygame.event.get():
        if event.type == pygame.QUIT or (event.type == pygame.KEYDOWN and event.dict["key"] == pygame.K_ESCAPE):
            sys.exit()
        elif event.type == pygame.KEYDOWN and jeff.is_dead() and event.dict["key"] == pygame.K_r:
            jeff = Jeff.Jeff([300, Constant.GROUND_HEIGHT - 50])
            field.reload_level()
        elif event.type == pygame.KEYDOWN and (jeff.is_dead() or field.is_level_ended()) and event.dict["key"] == pygame.K_m:
            jeff = Jeff.Jeff([300, Constant.GROUND_HEIGHT - 50])
            frame = "MENU"
        elif event.type == pygame.KEYDOWN and field.is_level_ended() and event.dict["key"] == pygame.K_n:
            next_level = level_select.get_next_level(field.get_level_file())
            if next_level != "":
                jeff = Jeff.Jeff([300, Constant.GROUND_HEIGHT - 50])
                field.load_level(next_level)
        elif event.type == pygame.KEYDOWN and event.dict["key"] == pygame.K_SPACE:
            jeff.jump(True)
        elif event.type == pygame.KEYUP and event.dict["key"] == pygame.K_SPACE:
            jeff.jump(False)
    return jeff, frame
项目:python-fsm    作者:axelhj    | 项目源码 | 文件源码
def __init__(self, gameInstance):
        BaseController.__init__(self, gameInstance)

        keys = ( \
            pygame.K_LEFT, #left
            pygame.K_RIGHT,#right
            pygame.K_UP,   #acc
            pygame.K_DOWN, #brake
            pygame.K_LCTRL,#reverse
            pygame.K_r,    #restart
            #pygame.K_ESC,  #endGame
            pygame.K_RCTRL,
            #pygame.K_SPACE,
            \
            )

        self.keyToAction = dict()
        for key, action in zip(keys, self.gameInterface.gameInstance.actionsList):
            self.keyToAction.update({key: action})
        self.keyToAction[pygame.K_RCTRL] = self.keyToAction[pygame.K_LCTRL]
项目:OfMagesAndMagic    作者:munnellg    | 项目源码 | 文件源码
def handle_event(self, event):
        if event.type == pygame.KEYDOWN:
            if event.key == pygame.K_ESCAPE:
                self.root.trigger_exit_to_main()
            elif event.key == pygame.K_p:
                self.toggle_pause()
            elif not self.paused:
                if event.key == pygame.K_SPACE:
                    self.skip_turn = True
                elif event.key == pygame.K_RETURN:
                    self.skip_game = True
                elif event.key in [pygame.K_LEFT, pygame.K_1]:
                    self.parent.battle.award_victory(1)
                    self.skip_game = True
                elif event.key in [pygame.K_RIGHT, pygame.K_2]:
                    self.parent.battle.award_victory(2)
                    self.skip_game = True
项目:Heap-Project-1    作者:stacompsoc    | 项目源码 | 文件源码
def keyboard(self, key):
        """
        Handle keyboard events.

        :key: key pressed
        """
        global SCALE_FACTOR, MIN_MASS
        if key == pygame.K_SPACE:
            self.pause = not self.pause
        elif key == pygame.K_UP:
            self.pos_shift[1] -= int(self.height / 10)
        elif key == pygame.K_DOWN:
            self.pos_shift[1] += int(self.height / 10)
        elif key == pygame.K_LEFT:
            self.pos_shift[0] -= int(self.width / 10)
        elif key == pygame.K_RIGHT:
            self.pos_shift[0] += int(self.width / 10)
        elif key == pygame.K_EQUALS:
            SCALE_FACTOR /= 1.05
        elif key == pygame.K_MINUS:
            SCALE_FACTOR *= 1.05
        MIN_MASS = SCALE_FACTOR ** 3
项目:PhotoPi    作者:JulienLegrand    | 项目源码 | 文件源码
def ShowPhoto(photoFile):
    screen = pygameEngine.GetScreen()
    image = pygame.image.load(photoFile).convert()
    image = pygame.transform.scale(image, (config.WIDTH,config.HEIGHT))
    screen.blit(image, (0,0))
    pygame.display.update()
    sleep(1)
    pygameEngine.ShowNavButtons()

    i = 0
    while True:
        # get one pygame event
        event = pygame.event.poll()

        # handle events
        # Button 1 = Quit
        if (event.type == pygame.MOUSEBUTTONUP and event.button == 1) or (event.type == pygame.KEYDOWN and event.key == pygame.K_SPACE) or GPIO.input(config.GPIO_NUMBER_BUTTON_1):
            return -1
        # Button 2 = Cycle old photos
        if (event.type == pygame.MOUSEBUTTONUP and event.button == 3) or (event.type == pygame.KEYDOWN and event.key == pygame.K_RETURN) or GPIO.input(config.GPIO_NUMBER_BUTTON_2):
            return 1
        # Button Esc or Q = Quit keys
        if event.type == pygame.KEYDOWN and (event.key == pygame.K_ESCAPE or event.key == pygame.K_q) :
            return -1
项目:Python-DataStructuresAndAlgorithms    作者:nikist97    | 项目源码 | 文件源码
def process_input(self, events):
        if not self.end_state[0]:
            for event in events:
                if event.type == pygame.MOUSEBUTTONDOWN:
                    if event.button == 1:
                        mouse_position = pygame.mouse.get_pos()
                        x = int(mouse_position[0] / self.square_width)
                        y = int(mouse_position[1] / self.square_width)
                        if (x, y) not in self.players[1].positions:
                            if self.players[0].add_position(x, y, self.minimax_board):
                                computer_position = pruned_minimax(self.minimax_board)
                                if not end_state(self.minimax_board)[0]:
                                    self.players[1].add_position(computer_position[0][0], computer_position[0][1],
                                                                 self.minimax_board, 1)
        else:
            for event in events:
                if event.type == pygame.KEYDOWN:
                    if event.key == pygame.K_RETURN:
                        self.clear()
                    elif event.key == pygame.K_SPACE:
                        self.clear(True)

    # the update method checks if the board is in an end state:
项目:planet-hopper    作者:reddit-pygame    | 项目源码 | 文件源码
def get_event(self, event):
        if event.type == pg.QUIT:
            self.quit = True
        elif event.type == pg.KEYUP:
            if event.key == pg.K_ESCAPE:
                self.quit = True
            elif event.key == pg.K_SPACE:
                self.running_sim = not self.running_sim
            elif event.key == pg.K_UP:
                if self.tick_index < len(self.tick_lengths) - 1:
                    self.tick_index += 1
                    self.tick_length = self.tick_lengths[self.tick_index]
            elif event.key == pg.K_DOWN:
                if self.tick_index > 0:
                    self.tick_index -= 1
                    self.tick_length = self.tick_lengths[self.tick_index]
项目:ld39    作者:mmalter    | 项目源码 | 文件源码
def welcome():
    pygame.init()
    screen = pygame.display.set_mode((X_SCREEN, Y_SCREEN))
    screen.fill((255,255,255))
    image = pygame.image.load(IMAGE_FOLDER + "/welcome.png")
    screen.blit(image,(0,0))

    clock = pygame.time.Clock()

    while 1:
        deltat = clock.tick(FRAMES_PER_SECOND)
        for event in pygame.event.get():
            if not hasattr(event, 'key'): continue
            #TODO: switch with dict
            if event.key == pygame.K_SPACE:
                main()

        pygame.display.flip()
项目:ld39    作者:mmalter    | 项目源码 | 文件源码
def victory():
    pygame.init()
    #font = pygame.font.Font("bithigh.ttf",15)
    font = pygame.font.SysFont("arial",20)
    pygame.key.set_repeat(1,10)
    screen = pygame.display.set_mode((X_SCREEN, Y_SCREEN))
    screen.fill((255,255,255))
    label = font.render("You won the game, try-hard. Spacebar",1,(0,0,0))
    screen.blit(label,(20,20))

    clock = pygame.time.Clock()

    while 1:
        deltat = clock.tick(FRAMES_PER_SECOND)
        for event in pygame.event.get():
            if not hasattr(event, 'key'): continue
            #TODO: switch with dict
            if event.key == pygame.K_SPACE:
                main()

        pygame.display.flip()
项目:aaai-platformer    作者:WarwickMasson    | 项目源码 | 文件源码
def control_update(self):
        ''' Uses input from the keyboard to control the player. '''
        keys_pressed = pygame.key.get_pressed()
        action_map = {
            pygame.K_SPACE: ('hop', INITIAL_HOP),
            pygame.K_l: ('leap', INITIAL_LEAP),
            pygame.K_d: ('run', 2),
        }
        action = ('run', 0)
        for key in action_map:
            if keys_pressed[key]:
                action = action_map[key]
                break
        reward, end_episode = self.simulator.update(action, DT, True)
        self.total += reward
        if end_episode:
            print 'Episode Reward:', self.total
            self.total = 0.0
            self.simulator = Simulator()
项目:c64-remakes    作者:DealPete    | 项目源码 | 文件源码
def get_input():
    for event in pygame.event.get():
        if event.type == pygame.QUIT: sys.exit()
        if event.type == pygame.KEYDOWN:
            if state.state == "playing":
                if event.key == pygame.K_LEFT:
                    if valid(state.X - 1, state.Y, state.piece.forms[state.form]):
                        state.X -= 1
                if event.key == pygame.K_RIGHT:
                    if valid(state.X + 1, state.Y, state.piece.forms[state.form]):
                        state.X += 1
                if event.key == pygame.K_SPACE:
                    new_form = state.form - 1
                    if new_form < 0: new_form = 3
                    if valid(state.X, state.Y, state.piece.forms[new_form]):
                        state.form = new_form
                if event.key == pygame.K_DOWN:
                    state.state = "falling"
            if state.state == "lost":
                if event.key in [pygame.K_SPACE, pygame.K_RETURN]:
                    state.start_game()
项目:alien_invasion    作者:samnew    | 项目源码 | 文件源码
def check_keydown_events(event, ai_settings, screen, stats, sb, ship, aliens, bullets):
    """????"""
    if event.key == pygame.K_RIGHT:
        ship.moving_right = True
    if event.key == pygame.K_LEFT:
        ship.moving_left = True
    elif event.key == pygame.K_SPACE:
        fire_bullet(ai_settings, screen, ship, bullets)
    elif event.key == pygame.K_q:
            stats.save_high_score()
            sys.exit() 
    elif event.key == pygame.K_p and not stats.game_active:
        start_game(ai_settings, screen, stats, sb, ship, aliens, bullets)
项目:project_xcape    作者:OthmanEmpire    | 项目源码 | 文件源码
def handleEvent(self, event):
        self.collisionEngine.eventHandler(event)
        self.scene.handleEvent(event)

        if event.type == pg.KEYDOWN:
            if event.key == pg.K_RETURN:
                self.camera.duration = 0
            if event.key == pg.K_SPACE:
                self._swapCameraFollow()

        if event.type == self.SCENE_EVENT:
            if event.category == "complete":
                self._nextScene()
            if event.category == "transition":
                self._handleTransition(event)
            if event.category == "unpause":
                self._loadUI(self.maxLives, self.lives)
            if event.category == "death":
                self._handleDeath(event)
            if event.category == "revive":
                self._handleRevive()

            if event.category == "pause":
                isAlive = all([live != 0 for live in self.lives])
                if isAlive:
                    self.pause = True
                    self.messageMenu("transition", "pause_menu")
            if event.category == "unpause":
                self.pause = False
                self._loadUI(self.maxLives, self.lives)
项目:Galaxian-Against-COMP140    作者:tomjlw    | 项目源码 | 文件源码
def check_keydown_events(event, ai_settings, screen, ship, bullets):
    if event.key == pygame.K_RIGHT:
        ship.moving_right = True
    elif event.key == pygame.K_LEFT:
        ship.moving_left = True
    elif event.key == pygame.K_SPACE:
        fire_bullet(ai_settings, screen, ship, bullets)
    elif event.key == pygame.K_ESCAPE:
        sys.exit()
项目:BusStopPi    作者:LoveBootCaptain    | 项目源码 | 文件源码
def loop():

    update_data()

    running = True

    while running:

        draw_to_tft()

        for event in pygame.event.get():

            if event.type == pygame.QUIT:

                running = False

                quit_all()

            elif event.type == pygame.KEYDOWN:

                if event.key == pygame.K_ESCAPE:

                    running = False

                    quit_all()

                elif event.key == pygame.K_SPACE:

                    print('\nSPACE')

    quit_all()
项目:LD39    作者:Bobsleigh    | 项目源码 | 文件源码
def notify(self, event):
        if self.isActivated:
            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_UP:
                    pass
                elif event.key == pygame.K_DOWN:
                    pass
                elif event.key == pygame.K_SPACE:
                    self.isActivated = False
                elif event.key == pygame.K_RETURN:
                    pass
项目:LD39    作者:Bobsleigh    | 项目源码 | 文件源码
def notify(self, event):
        if self.selected:
            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_UP:
                    self.optionList[self.selector.vPos].deselect()
                    self.selector.moveUp()
                    self.optionList[self.selector.vPos].select()
                elif event.key == pygame.K_DOWN:
                    self.optionList[self.selector.vPos].deselect()
                    self.selector.moveDown()
                    self.optionList[self.selector.vPos].select()
                elif event.key == pygame.K_SPACE:
                    self.optionList[self.selector.vPos].doOption()
                elif event.key == pygame.K_RETURN:
                    self.optionList[self.selector.vPos].doOption()
项目:oficina2017    作者:helioh2    | 项目源码 | 文件源码
def trata_tecla(vaca, tecla):
    if tecla == pg.K_SPACE:
        vaca.dx = -vaca.dx
    return vaca
项目:python-kinect    作者:jgerschler    | 项目源码 | 文件源码
def run(self):
        self.score = 0
        while not self.finished:
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    self.finished = True
                if event.type == pygame.KEYUP and event.key == pygame.K_SPACE:
                    self.start_ticks = pygame.time.get_ticks()
                    self.new_round()

        self._kinect.close()
        pygame.quit()
项目:python-kinect    作者:jgerschler    | 项目源码 | 文件源码
def run(self):
        self.score = 0
        while not self.finished:
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    self.finished = True
                if event.type == pygame.KEYUP and event.key == pygame.K_SPACE:
                    self.start_ticks = pygame.time.get_ticks()
                    self.new_round()

        self._kinect.close()
        pygame.quit()
项目:pytetris    作者:catalinc    | 项目源码 | 文件源码
def process_input(self):
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                sys.exit()
            if event.type == pygame.KEYDOWN:
                if self.state.paused:
                    if event.key == pygame.K_r:
                        self.state.paused = False
                if self.state.game_over:
                    if event.key == pygame.K_r:
                        self.state = State(self.ROWS, self.COLS)
                    if event.key == pygame.K_ESCAPE:
                        sys.exit()
                if self.state.running:
                    if event.key == pygame.K_DOWN:
                        self.state.move_piece(board.DIRECTION_DOWN)
                    if event.key == pygame.K_LEFT:
                        self.state.move_piece(board.DIRECTION_LEFT)
                    if event.key == pygame.K_RIGHT:
                        self.state.move_piece(board.DIRECTION_RIGHT)
                    if event.key == pygame.K_x:
                        self.state.rotate_piece()
                    if event.key == pygame.K_z:
                        self.state.rotate_piece(True)
                    if event.key == pygame.K_SPACE:
                        self.state.drop_piece()
                    if event.key == pygame.K_p:
                        self.state.paused = True
项目:solarwolf    作者:pygame    | 项目源码 | 文件源码
def __pygamebox(title, message):
    try:
        import pygame
        pygame.quit() #clean out anything running
        pygame.display.init()
        pygame.font.init()
        screen = pygame.display.set_mode((460, 140))
        pygame.display.set_caption(title)
        font = pygame.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()
        pygame.display.flip()
        stopkeys = pygame.K_ESCAPE, pygame.K_SPACE, pygame.K_RETURN, pygame.K_KP_ENTER
        while 1:
            e = pygame.event.wait()
            if e.type == pygame.QUIT or \
                       (e.type == pygame.KEYDOWN and e.key in stopkeys) or \
                       (e.type == pygame.MOUSEBUTTONDOWN and okbox.collidepoint(e.pos)):
                break
        pygame.quit()
    except pygame.error:
        raise ImportError
项目:solarwolf    作者:pygame    | 项目源码 | 文件源码
def __pygame(title, message):
    try:
        import pygame, pygame.font
        pygame.quit() #clean out anything running
        pygame.display.init()
        pygame.font.init()
        screen = pygame.display.set_mode((460, 140))
        pygame.display.set_caption(title)
        font = pygame.font.Font(None, 18)
        foreg = 0, 0, 0
        backg = 200, 200, 200
        liteg = 255, 255, 255
        ok = font.render('Ok', 1, foreg)
        screen.fill(backg)
        okbox = ok.get_rect().inflate(20, 10)
        okbox.centerx = screen.get_rect().centerx
        okbox.bottom = screen.get_rect().bottom - 10
        screen.fill(liteg, okbox)
        screen.blit(ok, okbox.inflate(-20, -10))
        pos = [20, 20]
        for text in message.split('\n'):
            msg = font.render(text, 1, foreg)
            screen.blit(msg, pos)
            pos[1] += font.get_height()

        pygame.display.flip()
        while 1:
            e = pygame.event.wait()
            if (e.type == pygame.QUIT or e.type == pygame.MOUSEBUTTONDOWN or
                        pygame.KEYDOWN and e.key
                        in (pygame.K_ESCAPE, pygame.K_SPACE, pygame.K_RETURN)):
                break
        pygame.quit()
    except pygame.error:
        raise ImportError
项目:Pythonlearn    作者:godzoco    | 项目源码 | 文件源码
def check_keydown_events(event, ai_settings, screen,ship,bullets):
    """Respond to keypresses."""
    if event.key == pygame.K_RIGHT:
        ship.moving_right = True
    elif event.key == pygame.K_LEFT:
        ship.moving_left = True
    elif event.key == pygame.K_SPACE:    
        fire_bullet(ai_settings, screen,ship,bullets)
    elif event.key == pygame.K_q:
        sys.exit()
项目:Pythonlearn    作者:godzoco    | 项目源码 | 文件源码
def check_keydown_events(event, ai_settings, screen,ship,bullets):
    """Respond to keypresses."""
    if event.key == pygame.K_RIGHT:
        ship.moving_right = True
    elif event.key == pygame.K_LEFT:
        ship.moving_left = True
    elif event.key == pygame.K_SPACE:    
        fire_bullet(ai_settings, screen,ship,bullets)
    elif event.key == pygame.K_q:
        sys.exit()
项目:Pythonlearn    作者:godzoco    | 项目源码 | 文件源码
def check_keydown_events(event, ai_settings, screen,ship,bullets):
    """Respond to keypresses."""
    if event.key == pygame.K_RIGHT:
        ship.moving_right = True
    elif event.key == pygame.K_LEFT:
        ship.moving_left = True
    elif event.key == pygame.K_SPACE:    
        fire_bullet(ai_settings, screen,ship,bullets)
    elif event.key == pygame.K_q:
        sys.exit()
项目:Pythonlearn    作者:godzoco    | 项目源码 | 文件源码
def check_keydown_events(event, ai_settings, screen,ship,bullets):
    """Respond to keypresses."""
    if event.key == pygame.K_RIGHT:
        ship.moving_right = True
    elif event.key == pygame.K_LEFT:
        ship.moving_left = True
    elif event.key == pygame.K_SPACE:    
        fire_bullet(ai_settings, screen,ship,bullets)
    elif event.key == pygame.K_q:
        sys.exit()
项目:Pythonlearn    作者:godzoco    | 项目源码 | 文件源码
def check_keydown_events(event, ai_settings, screen,ship,bullets):
    """Respond to keypresses."""
    if event.key == pygame.K_RIGHT:
        ship.moving_right = True
    elif event.key == pygame.K_LEFT:
        ship.moving_left = True
    elif event.key == pygame.K_SPACE:    
        fire_bullet(ai_settings, screen,ship,bullets)
    elif event.key == pygame.K_q:
        sys.exit()
项目:Pythonlearn    作者:godzoco    | 项目源码 | 文件源码
def check_keydown_events(event, ai_settings, screen,ship,bullets):
    """Respond to keypresses."""
    if event.key == pygame.K_RIGHT:
        ship.moving_right = True
    elif event.key == pygame.K_LEFT:
        ship.moving_left = True
    elif event.key == pygame.K_SPACE:    
        fire_bullet(ai_settings, screen,ship,bullets)
    elif event.key == pygame.K_q:
        sys.exit()
项目:Pythonlearn    作者:godzoco    | 项目源码 | 文件源码
def check_keydown_events(event, ai_settings, screen,ship,bullets):
    """Respond to keypresses."""
    if event.key == pygame.K_RIGHT:
        ship.moving_right = True
    elif event.key == pygame.K_LEFT:
        ship.moving_left = True
    elif event.key == pygame.K_SPACE:    
        fire_bullet(ai_settings, screen,ship,bullets)
    elif event.key == pygame.K_q:
        sys.exit()
项目:Pythonlearn    作者:godzoco    | 项目源码 | 文件源码
def check_keydown_events(event, ai_settings, screen,ship,bullets):
    """Respond to keypresses."""
    if event.key == pygame.K_RIGHT:
        ship.moving_right = True
    elif event.key == pygame.K_LEFT:
        ship.moving_left = True
    elif event.key == pygame.K_SPACE:    
        fire_bullet(ai_settings, screen,ship,bullets)
    elif event.key == pygame.K_q:
        sys.exit()
项目:Pythonlearn    作者:godzoco    | 项目源码 | 文件源码
def check_keydown_events(event, ai_settings, screen,ship,bullets):
    """Respond to keypresses."""
    if event.key == pygame.K_RIGHT:
        ship.moving_right = True
    elif event.key == pygame.K_LEFT:
        ship.moving_left = True
    elif event.key == pygame.K_SPACE:    
        fire_bullet(ai_settings, screen,ship,bullets)
    elif event.key == pygame.K_q:
        sys.exit()
项目:Pythonlearn    作者:godzoco    | 项目源码 | 文件源码
def check_keydown_events(event, ai_settings, screen,ship,bullets):
    """Respond to keypresses."""
    if event.key == pygame.K_RIGHT:
        ship.moving_right = True
    elif event.key == pygame.K_LEFT:
        ship.moving_left = True
    elif event.key == pygame.K_SPACE:    
        fire_bullet(ai_settings, screen,ship,bullets)
    elif event.key == pygame.K_q:
        sys.exit()
项目:Pythonlearn    作者:godzoco    | 项目源码 | 文件源码
def check_keydown_events(event, ai_settings, screen,ship,bullets):
    """Respond to keypresses."""
    if event.key == pygame.K_RIGHT:
        ship.moving_right = True
    elif event.key == pygame.K_LEFT:
        ship.moving_left = True
    elif event.key == pygame.K_SPACE:    
        fire_bullet(ai_settings, screen,ship,bullets)
项目:Pythonlearn    作者:godzoco    | 项目源码 | 文件源码
def check_keydown_events(event, ai_settings, screen, ship, bullets):
    """Respond to keypresses."""
    if event.key == pygame.K_RIGHT:
        ship.moving_right = True
    elif event.key == pygame.K_LEFT:
        ship.moving_left = True
    elif event.key == pygame.K_SPACE:
        fire_bullet(ai_settings, screen, ship, bullets)
    elif event.key == pygame.K_q:
        sys.exit()
项目:Pythonlearn    作者:godzoco    | 项目源码 | 文件源码
def check_keydown_events(event, ai_settings, screen, ship, bullets):
    """Respond to keypresses."""
    if event.key == pygame.K_RIGHT:
        ship.moving_right = True
    elif event.key == pygame.K_LEFT:
        ship.moving_left = True
    elif event.key == pygame.K_SPACE:
        fire_bullet(ai_settings, screen, ship, bullets)
项目:Pythonlearn    作者:godzoco    | 项目源码 | 文件源码
def check_keydown_events(event, ai_settings, screen,ship,bullets):
    """Respond to keypresses."""
    if event.key == pygame.K_RIGHT:
        ship.moving_right = True
    elif event.key == pygame.K_LEFT:
        ship.moving_left = True

        #??????? ?? ???????????? ???add ???bullets ??????
    elif event.key == pygame.K_SPACE:
        if len(bullets)<ai_settings.bullets_allowed:
        #?????? ????? bullets?
            new_bullet =Bullet(ai_settings, screen,ship)
            bullets.add(new_bullet)
项目:Pythonlearn    作者:godzoco    | 项目源码 | 文件源码
def check_keydown_events(event, ai_settings, screen,ship,bullets):
    """Respond to keypresses."""
    if event.key == pygame.K_RIGHT:
        ship.moving_right = True
    elif event.key == pygame.K_LEFT:
        ship.moving_left = True

        #??????? ?? ???????????? ???add ???bullets ??????
    elif event.key == pygame.K_SPACE:
        if len(bullets)<ai_settings.bullets_allowed:
        #?????? ????? bullets?
            new_bullet =Bullet(ai_settings, screen,ship)
            bullets.add(new_bullet)
项目:Pythonlearn    作者:godzoco    | 项目源码 | 文件源码
def check_keydown_events(event, ai_settings, screen,ship,bullets):
    """Respond to keypresses."""
    if event.key == pygame.K_RIGHT:
        ship.moving_right = True
    elif event.key == pygame.K_LEFT:
        ship.moving_left = True
    elif event.key == pygame.K_SPACE:    
        fire_bullet(ai_settings, screen,ship,bullets)
项目:Pythonlearn    作者:godzoco    | 项目源码 | 文件源码
def check_keydown_events(event, ai_settings, screen, ship, bullets):
    """Respond to keypresses."""
    if event.key == pygame.K_RIGHT:
        ship.moving_right = True
    elif event.key == pygame.K_LEFT:
        ship.moving_left = True
    elif event.key == pygame.K_SPACE:
        fire_bullet(ai_settings, screen, ship, bullets)
项目:Pythonlearn    作者:godzoco    | 项目源码 | 文件源码
def check_keydown_events(event, ai_settings, screen, ship, bullets):
    """Respond to keypresses."""
    if event.key == pygame.K_RIGHT:
        ship.moving_right = True
    elif event.key == pygame.K_LEFT:
        ship.moving_left = True
    elif event.key == pygame.K_SPACE:
        # Create a new bullet and add it to the bullets group.
        new_bullet = Bullet(ai_settings, screen, ship)
        bullets.add(new_bullet)
项目:Pythonlearn    作者:godzoco    | 项目源码 | 文件源码
def check_keydown_events(event, ai_settings, screen, ship, bullets):
    """Respond to keypresses."""
    if event.key == pygame.K_RIGHT:
        ship.moving_right = True
    elif event.key == pygame.K_LEFT:
        ship.moving_left = True
    elif event.key == pygame.K_SPACE:
        fire_bullet(ai_settings, screen, ship, bullets)
    elif event.key == pygame.K_q:
        sys.exit()
项目:Pythonlearn    作者:godzoco    | 项目源码 | 文件源码
def check_keydown_events(event, ai_settings, screen,ship,bullets):
    """Respond to keypresses."""
    if event.key == pygame.K_RIGHT:
        ship.moving_right = True
    elif event.key == pygame.K_LEFT:
        ship.moving_left = True
    elif event.key == pygame.K_SPACE:    
        fire_bullet(ai_settings,screen,ship,bullets)
    elif event.key == pygame.K_q:
        sys.exit()
项目:Pythonlearn    作者:godzoco    | 项目源码 | 文件源码
def check_keydown_events(event, ai_settings, screen,ship,bullets):
    """Respond to keypresses."""
    if event.key == pygame.K_RIGHT:
        ship.moving_right = True
    elif event.key == pygame.K_LEFT:
        ship.moving_left = True
    elif event.key == pygame.K_SPACE:    
        fire_bullet(ai_settings,screen,ship,bullets)
    elif event.key == pygame.K_q:
        sys.exit()
项目:Pythonlearn    作者:godzoco    | 项目源码 | 文件源码
def check_keydown_events(event, ai_settings, screen,ship,bullets):
    """Respond to keypresses."""
    if event.key == pygame.K_RIGHT:
        ship.moving_right = True
    elif event.key == pygame.K_LEFT:
        ship.moving_left = True
    elif event.key == pygame.K_SPACE:    
        fire_bullet(ai_settings, screen,ship,bullets)
    elif event.key == pygame.K_q:
        sys.exit()
项目:Pythonlearn    作者:godzoco    | 项目源码 | 文件源码
def check_keydown_events(event, ai_settings, screen,ship,bullets):
    """Respond to keypresses."""
    if event.key == pygame.K_RIGHT:
        ship.moving_right = True
    elif event.key == pygame.K_LEFT:
        ship.moving_left = True
    elif event.key == pygame.K_SPACE:    
        fire_bullet(ai_settings,screen,ship,bullets)
    elif event.key == pygame.K_q:
        sys.exit()
项目:Pythonlearn    作者:godzoco    | 项目源码 | 文件源码
def check_keydown_events(event, ai_settings, screen,ship,bullets):
    """Respond to keypresses."""
    if event.key == pygame.K_RIGHT:
        ship.moving_right = True
    elif event.key == pygame.K_LEFT:
        ship.moving_left = True
    elif event.key == pygame.K_SPACE:    
        fire_bullet(ai_settings, screen,ship,bullets)
    elif event.key == pygame.K_q:
        sys.exit()
项目:Pythonlearn    作者:godzoco    | 项目源码 | 文件源码
def check_keydown_events(event, ai_settings, screen,ship,bullets):
    """Respond to keypresses."""
    if event.key == pygame.K_RIGHT:
        ship.moving_right = True
    elif event.key == pygame.K_LEFT:
        ship.moving_left = True
    elif event.key == pygame.K_SPACE:    
        fire_bullet(ai_settings, screen,ship,bullets)
    elif event.key == pygame.K_q:
        sys.exit()