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


Python Player.fall方法代码示例

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


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

示例1: main

# 需要导入模块: import Player [as 别名]
# 或者: from Player import fall [as 别名]
def main():
    menu = True
    pygame.init()
    deathcounter = 0
    textcounter = 0
    fpsClock = pygame.time.Clock()
    message = ""
    windowSurfaceObj = pygame.display.set_mode((1280,720), DOUBLEBUF)
    pygame.display.set_caption("William Wallace Castle Defender X-Treme 2140")
    soundObjectExplosion = pygame.mixer.Sound('explosion.wav')
    soundDecoy = pygame.mixer.Sound('decoy.wav')
    soundPwp = pygame.mixer.Sound('powerup.wav')
    soundShld = pygame.mixer.Sound('zap2.wav')
    desertBackground = pygame.image.load(os.path.join(os.curdir, 'desert-background.jpg')).convert_alpha()
    SurfaceObjLife = pygame.image.load("life.png")
    level = pygame.image.load(os.path.join(os.curdir, 'LEVEL.png')).convert_alpha()
    player = Player()
    ArrowList = []
    missileList = []
    ShieldList = []
    BombList = []
    PowerUpList = []
    #EXPLOSION
    exploList = []

    #Enemy variables
    maxEnemies = 50
    enemyList = []

    #Castle HP
    HP = 100
    points = 0
    if menu == True:
        Menu(menu, windowSurfaceObj, fpsClock, desertBackground)
    pygame.key.set_repeat(1,50)
    playing = True
    gravityLimit = False

    soundObjectExplosion = pygame.mixer.Sound("explosion.wav")
    soundObjectArrow = pygame.mixer.Sound("arrow.wav")
    pygame.mixer.music.load("BackgroundMusic.mp3")
    pygame.mixer.music.play(-1)

    gravityLimit = False
    #Main Loop
    LifeUp = 1
    while playing:
        windowSurfaceObj.blit(desertBackground,(0,0))
        windowSurfaceObj.blit(level,(0,0))
        mousex = player.x
        mousey = player.y

        #DRAW EXLPLOSIONS
        count = len(exploList) - 1
        while(count >= 0):
            windowSurfaceObj.blit(exploList[count].images[exploList[count].image], exploList[count].rect)
            if(exploList[count].updateEnemyPos()):
                exploList.pop(count)
            count = count - 1
        if(textcounter > 0):
                #print message
                textMessage = fontObj.render(str(message), False, pygame.Color(0,0,0))
                windowSurfaceObj.blit(textMessage, ((1280-textMessage.get_rect().width)/2*1,670))
                textcounter -= 1
        if(deathcounter > 0):
            if(player.Lives <= 0):
                player.fall()
                player.updatePlayerSprite(21,1)
            else:
                player.updatePlayerSprite(20,1)
            deathcounter -= 1
            windowSurfaceObj.blit(player.images[player.image],player.rect)
            pygame.display.flip()
            fpsClock.tick(30)

        else:
            if(player.Lives <= 0):
                retry = gameOver(points, windowSurfaceObj,fpsClock, desertBackground)
                playing = False
            #Enemy code
            enemyGenerator(enemyList, maxEnemies,points)
            count = len(enemyList) - 1
            while(count >= 0):
                windowSurfaceObj.blit(enemyList[count].images[enemyList[count].image], enemyList[count].rect)


                enx = enemyList[count].x
                eny = enemyList[count].y
                chance = 1
                if enemyList[count].boss:
                    chance = 5
                if random.randint(0,100) < chance: #1% chance that an enemy shoots
                    if enemyList[count].right:
                        speed = -enemyList[count].speed
                    else:
                        speed = enemyList[count].speed
                    tmp = random.randint(0,100)
                    if player.DecoyCounter > 0:
                        playerX = player.DecoyX
                        playerY = player.DecoyY
#.........这里部分代码省略.........
开发者ID:KyleMagocs,项目名称:osgcc5-WilliamWallaceCastleDefender,代码行数:103,代码来源:Main.py

示例2: range

# 需要导入模块: import Player [as 别名]
# 或者: from Player import fall [as 别名]
            for i in range(count):
                fbList[i].motion(donkey.getPosition(),draw_layout.get_Matrix())
                pos = fbList[i].getPosition()
                if player.checkCollision(pos,draw_layout.get_Matrix()):
                    br=1
                    score -=5
                    life -=1
                    break
            if br:
                break
            if player.collision_donkey(donkey.getPosition(),draw_layout.get_Matrix()):
                score -=5
                life -=1
                break

            player.fall(player.getPosition(),draw_layout.get_Matrix())

            if it % 100 == 41:
                if count < 4 + level:
                    fb = FireBalls(donkey.getPosition(),draw_layout.get_Matrix())
                    fbList.append(fb)
                    count = count + 1
                donkey.randomize_direction()
                start_time = time.time()

            player_position = player.getPosition()
            if (player_position[0] == 1):
                os.system('clear')
                level = level+1
                score +=10
                if (level == 3):
开发者ID:anirudhdahiya9,项目名称:Open-data-projecy,代码行数:33,代码来源:game.py


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