예제 #1
0
        bullet_sound.play()
        if Rab.left:
            facing = -1
        else:
            facing = 1
        if len(bullets) < 5:
            bullets.append(
                Projectile(round(Rab.x + Rab.width // 2),
                           round(Rab.y + Rab.height // 2), 6, (0, 0, 0),
                           facing))

        shoot_loop = 1

    if keys[pygame.K_LEFT] and Rab.x > Rab.vel:
        Rab.x -= Rab.vel
        Rab.left = True
        Rab.right = False
        Rab.standing = False

    elif keys[pygame.K_RIGHT] and Rab.x < 500 - Rab.width - Rab.vel:
        Rab.x += Rab.vel
        Rab.right = True
        Rab.left = False
        Rab.standing = False

    else:
        Rab.standing = True
        Rab.walk_count = 0

    if not Rab.is_jump:
        if keys[pygame.K_UP]:
예제 #2
0
        if hero.up:
            direction = 'up'
        if hero.down:
            direction = 'down'

        if len(fireballs) < 100:
            fireballs.append(
                Projectile(round(hero.x + hero.width // 2),
                           round(hero.y + hero.height // 2), (255, 0, 0), 5,
                           direction))

    #-----character movement-----

    if keys[pygame.K_LEFT] and hero.x > hero.vel:
        hero.x -= hero.vel
        hero.left = True
        hero.right = False
        hero.up = False
        hero.down = False
        hero.standing = False

    elif keys[pygame.K_RIGHT] and hero.x < 500 - hero.width - hero.vel:
        hero.x += hero.vel
        hero.left = False
        hero.right = True
        hero.up = False
        hero.down = False
        hero.standing = False

    elif keys[pygame.K_UP] and hero.y > hero.vel:
        hero.y -= hero.vel