示例#1
0
文件: V2.py 项目: jQwotos/Python3Game
def Main():
    while True:
        for event in pi.event.get():
            if event.type == pi.QUIT():
                pi.quit()
                exit()
            if event.type == pi.KEYDOWN:
                if event.key == pi.K_SPACE:
                    player.jump()
                if event.key == pi.K_d:
                    player.right = True
                if event.key == pi.K_a:
                    player.left = True
            if event.type == pi.KEYUP:
                if event.key == pi.K_d:
                    player.right = False
                if event.key == pi.K_a:
                    player.left = False

        player.move()

        if player.jumping > 0:
            player.jump()
示例#2
0
            elif currentPowerUp < 2:  # tennisBallPowerUp
                if tennisBallPowerUp.readyToGo == True:
                    tennisBallPowerUp.setGo()
                if pygame.sprite.collide_rect(player, tennisBallPowerUp):
                    stats.score += 2500
                    currentPowerUp = 2 * random()
                    tennisBallPowerUp.setReady()

            event = pygame.event.poll()
            # print event	# for debugging purposes
            if event.type == QUIT:
                sys.exit(0)

            if event.type == KEYDOWN:
                if event.key == K_UP:
                    player.jump()
                elif event.key == K_ESCAPE:
                    pause_menu.menu(screen, clock)
                elif event.key == K_LEFT:
                    player.moveHoriz(-15)
                elif event.key == K_RIGHT:
                    player.moveHoriz(15)
                    # if event.key == K_b:
                    # test.setAnim(0,test._endFrame%4+1)
                    # print "test._startFrame=",test._startFrame," test._endFrame=",test._endFrame

                    # update and draw objects

            level_one.update()
            level_one.draw(screen)
示例#3
0
        'intent': 'aggressive',
    },

    'ability_cleave': {
        'name': 'Cleave',
        'description': 'Make an attack against all adjacent enemies',
        'targeting': 'override',
        'function': common.cleave_attack,
        'cooldown': 0,
        'intent': 'aggressive',
    },

    'ability_jump': {
        'name': 'Jump',
        'targeting': 'self',
        'function': lambda a,t,_: player.jump(a,2),
        'intent': 'aggressive'
    },

    'ability_attack': {
        'name': 'Attack',
        'targeting': 'override',
        'description': 'Attack an enemy with your held weapon',
        'function': lambda a,t,_: common.attack(),
        'cooldown': 0,
        'intent': 'aggressive',
    },

    'ability_pommel_strike': {
        'name': 'Pommel Strike',
        'description': 'Smash your opponent with your sword pommel for extra damage and shred at the expense of'
示例#4
0
    if keys[pygame.K_ESCAPE]:
        run = False

    if keys[pygame.K_LEFT]:
        player.moveLeft()
    elif keys[pygame.K_RIGHT]:
        player.moveRight()
    else:
        player.standing()

    if not player.isJumping:
        if keys[pygame.K_UP]:  # SPACE]:
            player.isJumping = True

    else:
        player.jump()

    # Enemy movement with w,a,s,d keys

    if keys[pygame.K_a]:
        enemy.moveLeft()
    elif keys[pygame.K_d]:
        enemy.moveRight()
    else:
        enemy.standing()

    if keys[pygame.K_h]:
        player.hitboxShown = not player.hitboxShown
        enemy.hitboxShown = not enemy.hitboxShown

    if not enemy.isJumping: