Exemplo n.º 1
0
 def newPlayerBullet(self, putBulletPattern):
     playerBullet = PlayerBullet(name = "playerBullet", \
                                 image = self.playerBulletImage[0], \
                                 bulletRadius = 5, \
                                 bulletDamage = self.playerDamage[0], \
                                 putBulletPattern = putBulletPattern, \
                                 shootBulletPattern = self.shootBulletPattern[0])
     parameter.getAllSprites().add(playerBullet)
     parameter.getPlayerBulletSprites().add(playerBullet)
Exemplo n.º 2
0
 def newPlayerBullet_tracking(self, putBulletPattern, shootBulletPattern):
     playerBullet = PlayerBullet_tracking(name = "playerBullet_tracking", \
                                          image = self.playerBulletImage[1], \
                                          bulletRadius = 5, \
                                          bulletDamage = self.playerDamage[1], \
                                          putBulletPattern = putBulletPattern, \
                                          shootBulletPattern = shootBulletPattern, \
                                          playerRectCenter = self.rect.center)
     parameter.getAllSprites().add(playerBullet)
     parameter.getPlayerBulletSprites().add(playerBullet)
Exemplo n.º 3
0
 def newEnemy_4():
     enemy = classes.Enemy(name = "enemy", \
                         Hp = 4000, \
                         image = enemyImgList[0], \
                         movePattern = custom.enemyMovePattern_4, \
                         enemyBulletImage = [enemyBulletImgList[9]], \
                         putBulletPattern = [custom.enemyPutBulletPattern_4], \
                         shootBulletPattern = [custom.enemyshootBulletPattern_4], \
                         dropItem = (8, 10))
     parameter.getAllSprites().add(enemy)
     parameter.getEnemySprites().add(enemy)
Exemplo n.º 4
0
 def newEnemy_3():
     enemy = classes.Enemy(name = "enemy", \
                         Hp = 30, \
                         image = enemyImgList[1], \
                         movePattern = custom.enemyMovePattern_3, \
                         enemyBulletImage = [enemyBulletImgList[8]], \
                         putBulletPattern = [custom.enemyPutBulletPattern_3], \
                         shootBulletPattern = [custom.enemyshootBulletPattern_3], \
                         dropItem = (1, 4))
     parameter.getAllSprites().add(enemy)
     parameter.getEnemySprites().add(enemy)
Exemplo n.º 5
0
 def generateBoss(self):
     if not self.ifGenerateBoss:
         self.boss = Enemy(name = self.order, \
                         Hp = self.Hp, \
                         image = self.bossImage, \
                         movePattern = self.bossMovement, \
                         enemyBulletImage = self.bossBulletImage, \
                         putBulletPattern = self.bossPutBulletPattern, \
                         shootBulletPattern = self.bossShootBulletPattern, \
                         dropItem = self.dropItem)
         parameter.getEnemySprites().add(self.boss)
         parameter.getBossSprites().add(self.boss)
         parameter.getAllSprites().add(self.boss)
         self.ifGenerateBoss = True
Exemplo n.º 6
0
 def kill(self):
     # Generate new bullet when killed
     for i in range(self.generateBulletNumber):
         x = self.deathGenerate["putPattern"][0]
         y = self.deathGenerate["putPattern"][1]
         enemyBullet = EnemyBullet(name = "enemyBullet", \
                                 image = self.deathGenerateImage, \
                                 bulletRadius = 1, \
                                 bulletDamage = None, \
                                 putBulletPattern = (x + self.rect.center[0], \
                                                     y + self.rect.center[1]), \
                                 shootBulletPattern = self.deathGenerate["shootPattern"]((x, y)))
         parameter.getAllSprites().add(enemyBullet)
         parameter.getEnemyBulletSprites().add(enemyBullet)
     super().kill()
Exemplo n.º 7
0
def startGameScreen(background, bgm, topleft):
    background_rect = background.get_rect(topleft=topleft)
    windowSurface.blit(background, background_rect)
    pygame.display.update()
    pygame.mixer.music.load(bgm)
    pygame.mixer.music.set_volume(0.4)
    pygame.mixer.music.play(loops=1)

    waiting = True
    while waiting:

        for event in pygame.event.get():
            if event.type == QUIT:
                terminate()
            if event.type == KEYUP:
                if event.key == K_ESCAPE:
                    terminate()
                if event.key == K_z:
                    pygame.mixer.music.stop()
                    waiting = False

        mainClock.tick(FPS)

    # Clear parameter
    for i in parameter.getAllSprites():
        i.kill()
    parameter.clearTimer()
    parameter.clearPoint()
Exemplo n.º 8
0
 def shoot(self):
     now = parameter.getTimer()
     for j in range(len(self.enemyBulletImage)):
         if now - self.generateTime > self.putBulletPattern[j](
                 now - self.generateTime)["delateTime"]:
             if now - self.lastShootingTime[j] > self.putBulletPattern[j](
                     now - self.generateTime)["intermediateTime"]:
                 sound.bullet_SE_list[2].play()
                 for i in range(self.putBulletPattern[j](now)["numbers"]):
                     x = self.putBulletPattern[j](now)["position"][i][0]
                     y = self.putBulletPattern[j](now)["position"][i][1]
                     if "tracking" in self.putBulletPattern[j](now).keys():
                         enemyBullet = EnemyBullet_tracking(name = "enemyBullet", \
                                                            image = self.enemyBulletImage[j], \
                                                            bulletRadius = 1, \
                                                            bulletDamage = None, \
                                                            putBulletPattern = (x + self.rect.center[0], \
                                                                                y + self.rect.center[1]), \
                                                            shootBulletPattern = self.shootBulletPattern[j]((x, y)))
                         parameter.getAllSprites().add(enemyBullet)
                         parameter.getEnemyBulletSprites().add(enemyBullet)
                     elif "deathGenerate" in self.putBulletPattern[j](
                             now).keys():
                         enemyBullet = EnemyBullet_deathGenerate(name = "enemyBullet", \
                                                            image = self.enemyBulletImage[j], \
                                                            bulletRadius = 1, \
                                                            bulletDamage = None, \
                                                            putBulletPattern = (x + self.rect.center[0], \
                                                                                y + self.rect.center[1]), \
                                                            shootBulletPattern = self.shootBulletPattern[j]((x, y)), \
                                                            death = self.putBulletPattern[j](now)["generateBullet"])
                         parameter.getAllSprites().add(enemyBullet)
                         parameter.getEnemyBulletSprites().add(enemyBullet)
                     elif "decay" in self.putBulletPattern[j](now).keys():
                         enemyBullet = EnemyBullet_decay(name = "enemyBullet", \
                                                            image = self.enemyBulletImage[j], \
                                                            bulletRadius = 1, \
                                                            bulletDamage = None, \
                                                            putBulletPattern = (x + self.rect.center[0], \
                                                                                y + self.rect.center[1]), \
                                                            shootBulletPattern = self.shootBulletPattern[j]((x, y)))
                         parameter.getAllSprites().add(enemyBullet)
                         parameter.getEnemyBulletSprites().add(enemyBullet)
                     else:
                         enemyBullet = EnemyBullet(name = "enemyBullet", \
                                                   image = self.enemyBulletImage[j], \
                                                   bulletRadius = 1, \
                                                   bulletDamage = None, \
                                                   putBulletPattern = (x + self.rect.center[0], \
                                                                       y + self.rect.center[1]), \
                                                   shootBulletPattern = self.shootBulletPattern[j]((x, y)))
                         parameter.getAllSprites().add(enemyBullet)
                         parameter.getEnemyBulletSprites().add(enemyBullet)
                 self.lastShootingTime[j] = now
Exemplo n.º 9
0
def generateItem(enemy, number, name, image):
    while True:
        check = True
        itemList = []
        for i in range(number):
            item = classes.Item(name = name, \
                                image = image, \
                                generatePosition = (enemy.rect.center[0] + random.randint(-enemy.rect.width * 1, enemy.rect.width *1), \
                                                    enemy.rect.center[1] + random.randint(-enemy.rect.height *1, enemy.rect.height *1)))
            itemList.append(item)
        for i in range(len(itemList)):
            for j in range(len(itemList) - i - 1):
                if pygame.sprite.collide_rect(itemList[i],
                                              itemList[i + j + 1]):
                    check = False
        if check:
            break
    for i in range(len(itemList)):
        parameter.getAllSprites().add(itemList[i])
        parameter.getItemSprites().add(itemList[i])
Exemplo n.º 10
0
            parameter.getAllSprites().add(enemy)
            parameter.getEnemySprites().add(enemy)

        def newEnemy_3():
            enemy = classes.Enemy(name = "enemy", \
                                Hp = 30, \
                                image = enemyImgList[1], \
                                movePattern = custom.enemyMovePattern_3, \
                                enemyBulletImage = [enemyBulletImgList[8]], \
                                putBulletPattern = [custom.enemyPutBulletPattern_3], \
                                shootBulletPattern = [custom.enemyshootBulletPattern_3], \
                                dropItem = (1, 4))
            parameter.getAllSprites().add(enemy)
            parameter.getEnemySprites().add(enemy)

        parameter.getAllSprites().add(player)
        parameter.getAllSprites().add(player.collisionBox)

        def newEnemy_4():
            enemy = classes.Enemy(name = "enemy", \
                                Hp = 4000, \
                                image = enemyImgList[0], \
                                movePattern = custom.enemyMovePattern_4, \
                                enemyBulletImage = [enemyBulletImgList[9]], \
                                putBulletPattern = [custom.enemyPutBulletPattern_4], \
                                shootBulletPattern = [custom.enemyshootBulletPattern_4], \
                                dropItem = (8, 10))
            parameter.getAllSprites().add(enemy)
            parameter.getEnemySprites().add(enemy)

        parameter.getAllSprites().add(player)