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


Python Ship.switchIndex方法代码示例

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


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

示例1: Controller

# 需要导入模块: import Ship [as 别名]
# 或者: from Ship import switchIndex [as 别名]

#.........这里部分代码省略.........
                                                                outputFile.write(string)
                                                                inserted = True
                                                outputFile.write(line)
                                            File.close()
                                            outputFile.close()
                                            os.remove(inputPath)
                                            os.rename(outputPath, inputPath)
                                        break
                                    # blit txtbx on the sceen
                                    txtbx.draw(self.screen)
                                    # refresh the display
                                    pygame.display.flip()
                                time.sleep(1)
                                return "Exit"
                            
                if event.type == USEREVENT+2:
                    self.spaceGroup.update()

                if event.type == USEREVENT+3:
                    self.ship.canShoot = True

                if event.type == USEREVENT+4:
                    powerUp = self.powerUpGroup.sprites()
                    for x in range(len(self.powerUpGroup)):
                        if pygame.sprite.collide_circle(self.ship, powerUp[x]):
                            powerUp[x].power(self.ship)
                            powerUp[x].kill()
                            shipPowerUp.play()
                    
                    self.shipGroup.update()
                    self.enemyGroup.update()
                    self.bossGroup.update()

                if event.type == USEREVENT+5:
                    enemyList = self.enemyGroup.sprites()
                    for i in range(len(enemyList)):
                        enemyList[i].shoot()
                    bossList = self.bossGroup.sprites()
                    for boss in bossList:
                        boss.shoot()

                if event.type == USEREVENT+6:
                    sType = randint(0, 1)
                    path = "images\\Enemy_" + str(sType) + ".png"
                    initX = randint(100, 400)
                    initDX = randint(-1, 1)
                    initDY = randint(1, 1)
                    enemy = Enemy(path, initX, 0, initDX, initDY, sType, self)
                    self.enemyGroup.add(enemy)

                if event.type == USEREVENT+7:
                    xcoord = randint(100, 400)
                    ycoord = randint(100, 450)
                    pType = randint(0, 2)
                    pUp = PowerUp((xcoord, ycoord), pType)
                    self.powerUpGroup.add(pUp)

                if event.type == USEREVENT:
                    boss = Boss(0, self)
                    self.bossGroup.add(boss)
                    pygame.time.set_timer(pygame.USEREVENT+6, 0)
                    pygame.time.set_timer(pygame.USEREVENT, 0)

                if event.type == KEYDOWN:
                    if event.key == K_w and gCount == 0:
                        gCount = 1
                    if event.key == K_a and gCount == 1:
                        gCount = 2
                    if event.key == K_l and gCount == 2:
                        gCount = 3
                    if event.key == K_r and gCount == 3:
                        gCount = 4
                    if event.key == K_i and gCount == 4:
                        gCount = 5
                    if event.key == K_d and gCount == 5:
                        gCount = 6
                    if event.key == K_e and gCount == 6:
                        gCount = 7
                    if event.key == K_r and gCount == 7:
                        sc = 999999999999999
                        gCount = 8

                keys = pygame.key.get_pressed()
                if keys[K_ESCAPE]:
                    pauseMenu = PauseMenu.Menu(self)
                    action = pauseMenu.pause(self)
                    if action != "Continue":
                        return action

            if self.ship.invincible and time.time() - self.ship.invincTime >= self.ship.duration:
                self.ship.switchIndex(0)
                self.ship.invincible = False
            if self.ship.shotNumber == 3 and time.time() - self.ship.triShotTime >= self.ship.duration1:
                self.ship.changeShotSingle()
                
            pygame.display.update()

            self.repaint()
            self.screen.blit(scRendered, (500-scRendered.get_rect().right-2, 2)) #score
            self.screen.blit(mtRendered, (500-mtRendered.get_rect().right-2, 28)) #multiplier
开发者ID:Wesleywa7,项目名称:Operation-Catapult-Bullet-Hell,代码行数:104,代码来源:Controller.py


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