Beispiel #1
0
    def bulletCollide(self, bullet):
        utility.playSound(self.bulletSound,BAAKE_CHANNEL)

        if bullet.collideStyle == COLLIDE_STYLE_HURT:
            bullet.die()
        
        elif bullet.collideStyle == COLLIDE_STYLE_REFLECT:
            if bullet.position.x < self.position.x - 64:
                bullet.position = vector.vector2d(self.position.x - 112,bullet.position.y)
                bullet.velocity *= [-1.0, 1.0]
            elif bullet.position.x > self.position.x + 64:
                bullet.position = vector.vector2d(self.position.x + 112,bullet.position.y)
                bullet.velocity *= [-1.0, 1.0]
            if bullet.position.y < self.position.y - 64:
                bullet.position = vector.vector2d(bullet.position.x, self.position.y - 14)
                bullet.velocity *= [1.0, -1.0]
            elif bullet.position.y > self.position.y + 64:
                bullet.position = vector.vector2d(bullet.position.x, self.position.y + 140)
                bullet.velocity *= [1.0, -1.0]

        elif bullet.collideStyle == COLLIDE_STYLE_NOVA:
            if not self.stunned:
                self.stunned = 2 * FRAMES_PER_SECOND
                self.hurt(1)
                self.eye.kill()
Beispiel #2
0
    def collide(self):
        if self.objectCollidedWith.actorType == ACTOR_BULLET:
            utility.playSound(Baake.bulletSound,BAAKE_CHANNEL)

        elif self.objectCollidedWith.actorType == ACTOR_PLAYER:
                if self.objectCollidedWith.position.x < self.position.x - 64:
                    self.objectCollidedWith.position = vector.vector2d((self.position.x - 94),
                                                                         self.objectCollidedWith.position.y)
                    if self.objectCollidedWith.velocity:
                        self.objectCollidedWith.velocity *= [-1.0, 1.0]
                           
                elif self.objectCollidedWith.position.x > self.position.x + 64:
                    self.objectCollidedWith.position = vector.vector2d((self.position.x + 94),
                                                                         self.objectCollidedWith.position.y)
                    if self.objectCollidedWith.velocity:
                        self.objectCollidedWith.velocity *= [-1.0, 1.0]
                        
                if self.objectCollidedWith.position.y < self.position.y - 32:
                    self.objectCollidedWith.position = vector.vector2d(self.objectCollidedWith.position.x,
                                                                         self.position.y - 76)
                    if self.objectCollidedWith.velocity:
                        self.objectCollidedWith.velocity *= [1.0, -1.0]
                        
                elif self.objectCollidedWith.position.y > self.position.y + 32:
                    self.objectCollidedWith.position = vector.vector2d(self.objectCollidedWith.position.x,
                                                                         self.position.y + 108)
                    if self.objectCollidedWith.velocity:
                        self.objectCollidedWith.velocity *= [1.0, -1.0]
Beispiel #3
0
    def incrementScore(self, value, textPosition, textGroup):
        if self.comboBonus and value <= 250:
            self.comboBonus += int(.2 * FRAMES_PER_SECOND)
            self.comboKills += 1
            tempImage = text.Text(FONT_PATH, 30, FONT_COLOR, "x" + str(self.comboKills) + "!").image
            
            helpBubble = infoBubble.infoBubble(tempImage, self,0.5 * FRAMES_PER_SECOND)
            helpBubble.offSet = vector.vector2d(0.0, -100.0)
            self.bulletGroup.add(helpBubble)


        if self.pointBonus:
            value *= 2

        tempText = text.Text(FONT_PATH, 36, FONT_COLOR, str(value), 15)
        tempText.setAlign(CENTER_MIDDLE)
        tempText.position = vector.vector2d(textPosition)
        textGroup.add(tempText)

        self.score += value
        self.scoreBoard.setText(self.score)
        
        if self.score >= self.nextBonus:
            utility.playSound(self.extraLifeSound, OW_CHANNEL)
            tempImage = text.TextSurface(FONT_PATH, 30, FONT_COLOR, "Extra Life!").image
            
            helpBubble = infoBubble.infoBubble(tempImage, self,1.5 * FRAMES_PER_SECOND)
            helpBubble.offSet = vector.vector2d(0.0, -100.0)
            textGroup.add(helpBubble)

            self.lives += 1
            self.lifeBoard.setText('x' + str(self.lives))
            self.nextBonus += 50000
Beispiel #4
0
    def hurt(self,damage):
        self.health -= damage
        self.animationList.play("hurt")
        utility.playSound(self.hurtSound,BOSS_CHANNEL)

        if self.health <= 0:
            for actor in self.enemyGroup:
                actor.leaveScreen = True
Beispiel #5
0
 def hurt(self, value):
     if self.stunTimer <= 0:
         self.animationList.play("HurtIdle", self.animationList.currentFrame)
         self.lives -= value
         soundToPlay = random.randint(0,2)
         if self.lives != 0:
             utility.playSound(self.loseLifeSound[soundToPlay],OW_CHANNEL)
         self.lifeBoard.setText('x' + str(self.lives))
         self.stunTimer = 1.5 * FRAMES_PER_SECOND            
Beispiel #6
0
    def hurt(self,damage):
        self.health -= damage
        utility.playSound(self.hurtSound,BOSS_CHANNEL)
        self.animationList.play("hurt")

        if self.health <= self.world.level and self.health != 0:
            self.enemyGroup.add(yurei.Yurei(self.groupList))

        if self.health <= 0:
            for actor in self.enemyGroup:
                actor.leaveScreen = True
Beispiel #7
0
    def die(self):
        utility.playSound(self.deathSound)

        particle.deathEmitter(self.position, self.effectsGroup).run()

        self.itemDrop()

        self.active = False
        self.emitter = None
        self.deathEmitter = None
        self.kill()
        del self
Beispiel #8
0
    def die(self):
        utility.playSound(self.deathSound)

        particle.deathEmitter(self.position, self.effectsGroup).run()

        if self.dropBalloon:
            self.powerupGroup.add(balloon.Bonus250(self.position, self.textGroup))
        elif self.dropReflect:
            self.powerupGroup.add(gem.Reflect(self.position, self.textGroup))
        else:
            self.itemDrop()

        self.kill()
        del self
Beispiel #9
0
    def incrementScoreNoText(self,value):
        self.score += value
        self.scoreBoard.setText(self.score)
        
        if self.score > self.nextBonus:
            utility.playSound(self.extraLifeSound, OW_CHANNEL)
            tempImage = text.TextSurface(FONT_PATH, 30, FONT_COLOR, "Extra Life!").image
            
            helpBubble = infoBubble.infoBubble(tempImage, self,1.5 * FRAMES_PER_SECOND)
            helpBubble.offSet = vector.vector2d(0.0, -100.0)
            self.effectsGroup.add(helpBubble)

            self.lives += 1
            self.lifeBoard.setText('x' + str(self.lives))
            self.nextBonus += 50000
Beispiel #10
0
    def actorUpdate(self):
        utility.playMusic(self.music, True)
        if not self.active and self.health > 0:
            self.active = True

        if self.lifeTimer <= 30 * FRAMES_PER_SECOND and  self.health == (self.world.level + 1) * 25:
            if self.lifeTimer == 30 * FRAMES_PER_SECOND:
                tempImage = self.howToKill
                
                helpBubble = infoBubble.infoBubble(tempImage, self.target,5 * FRAMES_PER_SECOND)
                helpBubble.offSet = vector.vector2d(0.0, -100.0)
                self.textGroup.add(helpBubble)
            self.lifeTimer += 1

        if self.active:
            if self.stunned:
                if self.charging:
                    self.speed -= 0.2
                    if self.speed <= 1.75:
                        self.speed = 1.75
                        self.charging = False
                        self.timeUntilCharge = 10 * FRAMES_PER_SECOND
                
                    self.velocity.makeNormal()
                    self.velocity *= self.speed

                self.stunned -= 1

                self.animationList.play("vulnerable")
                
                if not self.stunned:
                    utility.playSound(self.shieldRestore, PICKUP_CHANNEL)
                    self.animationList.play("idle")
                
            else:
                self.currentSequence = 0
                self.processAI()

        if self.health <= 0:
            self.active = False
            self.die()
            
            if not self.gaveBonus:
                self.world.giveBonus()
                self.gaveBonus = True
Beispiel #11
0
    def fire(self):        
        if self.stunTimer:
            self.animationList.play("HurtFire", self.animationList.currentFrame)
        else:
            self.animationList.play("Fire")

        if (self.fireTimer <= 0):
            utility.playSound(self.fireSound[random.randint(0,2)],PLAYER_CHANNEL)
            if self.velocity:
                bulletVelocity = vector.vector2d(self.velocity)
                bulletVelocity.setMagnitude(self.bulletSpeed)
                
                newBullet = bullet.Bullet((self.position),
                                          (bulletVelocity),
                                          self.effectsGroup,
                                          self.bulletDamage,
                                          self.bulletBoundStyle,
                                          self.bulletCollideStyle)
                newBullet.setOwner(self)
                if self.reflectBonus and self.damageBonus:
                    newBullet.animationList.play("DamageReflect")
                elif self.bulletCollideStyle == COLLIDE_STYLE_REFLECT: newBullet.animationList.play("Reflect")
                elif self.bulletDamage > 1: newBullet.animationList.play("Damage")

                self.bulletGroup.add(newBullet)
                self.fireTimer = self.resetFireTimer

            if self.duelShot:
                if self.velocity:
                    bulletVelocity = vector.vector2d(self.velocity * -1)
                    bulletVelocity.setMagnitude(self.bulletSpeed)
                    
                    newBullet = bullet.Bullet((self.position),
                                              (bulletVelocity),
                                              self.effectsGroup,
                                              self.bulletDamage,
                                              self.bulletBoundStyle,
                                              self.bulletCollideStyle)
                    newBullet.setOwner(self)
                    if self.reflectBonus and self.damageBonus:
                        newBullet.animationList.play("DamageReflect")
                    elif self.bulletCollideStyle == COLLIDE_STYLE_REFLECT: newBullet.animationList.play("Reflect")
                    elif self.bulletDamage > 1: newBullet.animationList.play("Damage")

                    self.bulletGroup.add(newBullet)
Beispiel #12
0
 def bulletCollide(self, bullet):
     if not self.stunned:
         utility.playSound(self.bulletSound,BAAKE_CHANNEL)
         if bullet.collideStyle == COLLIDE_STYLE_HURT:
             bullet.die()
         
         elif bullet.collideStyle == COLLIDE_STYLE_REFLECT:
             if bullet.position.x < self.position.x - 64:
                 bullet.position = vector.vector2d(self.position.x - 112,bullet.position.y)
                 bullet.velocity *= [-1.0, 1.0]
             elif bullet.position.x > self.position.x + 64:
                 bullet.position = vector.vector2d(self.position.x + 112,bullet.position.y)
                 bullet.velocity *= [-1.0, 1.0]
             if bullet.position.y < self.position.y - 64:
                 bullet.position = vector.vector2d(bullet.position.x, self.position.y - 14)
                 bullet.velocity *= [1.0, -1.0]
             elif bullet.position.y > self.position.y + 64:
                 bullet.position = vector.vector2d(bullet.position.x, self.position.y + 140)
                 bullet.velocity *= [1.0, -1.0]
 
         elif bullet.collideStyle == COLLIDE_STYLE_NOVA:
             utility.playSound(self.shieldBreak, BAAKE_CHANNEL)
             self.stunned = 2 * FRAMES_PER_SECOND
             self.animationList.play("vulnerable")
             
             starsToCreate = 15
             
             while starsToCreate:
                 starsToCreate -= 1
                 tempBullet = particle.starParticle()
                 tempVector = vector.vector2d(120,0)
                 tempVector.setAngle(starsToCreate * 24)
                 tempBullet.position = vector.vector2d(self.position + tempVector)
                 tempBullet.lifeTimer = .5 * FRAMES_PER_SECOND
                 tempBullet.velocity = vector.vector2d(3.0, 0.0)
                 tempBullet.velocity.setAngle(starsToCreate * 24)
                 
                 
                 self.effectsGroup.add(tempBullet)
     
     elif bullet.collideStyle != COLLIDE_STYLE_NOVA:
             bullet.die()
             self.hurt(1)
Beispiel #13
0
 def die(self):
     if self.dying == 0:
         deathType = int(random.random() * 3)
         
         #print deathType
         if deathType == 0:
             tempImage = text.TextSurface(FONT_PATH, 30, FONT_COLOR, "Blast!").image
             utility.playSound(self.deathSound[0], OW_CHANNEL)
         elif deathType == 1:
             tempImage = text.TextSurface(FONT_PATH, 30, FONT_COLOR, "Oh No!").image
             utility.playSound(self.deathSound[1], OW_CHANNEL)
         elif deathType == 2:
             tempImage = text.TextSurface(FONT_PATH, 30,FONT_COLOR, "Bother!").image
             utility.playSound(self.deathSound[2], OW_CHANNEL)
         
         self.animationList.play("Die")
         self.bounds = [-1000, -1000, SCREEN_WIDTH + 1000, SCREEN_HEIGHT + 32]
         self.boundStyle = BOUND_STYLE_CUSTOM
             
         helpBubble = infoBubble.infoBubble(tempImage, self, 5 * FRAMES_PER_SECOND)
         helpBubble.offSet = vector.vector2d(0.0, -100.0)
         self.bulletGroup.add(helpBubble)
     
     self.dying += 1
     
     if settingList[PARTICLES] and not self.dying % 2:
         puffsToCreate = 4
         
         while puffsToCreate:
             puffsToCreate -= 1
             tempPuff = particle.smokeParticle(self.position,
                                               [1,0])
             tempPuff.velocity.setAngle(359 * random.random())
             self.effectsGroup.add(tempPuff)
Beispiel #14
0
 def collide(self):
     if self.objectCollidedWith.actorType == ACTOR_PLAYER:
         utility.playSound(self.pickupSound, PICKUP_CHANNEL)
         self.displayText()
         self.giveBonus()
         self.die()
Beispiel #15
0
 def collide(self):
     if self.objectCollidedWith.actorType == ACTOR_PLAYER:
         utility.playSound(self.pickupSound)
         self.die()
Beispiel #16
0
    def displayMenu(self):
        
        self.menuSelectionPointer[self.currentSelection].setFont(48, FONT_COLOR, FONT_PATH)
        pygame.mouse.get_rel()
        mouseTimeout = 10
        sampleMouse = True
        
        while True:
            """Music Stuff"""
            utility.playMusic(self.musicList)

            """Drawing Stuff"""
            self.screen.fill(FILL_COLOR)
            self.menuGroup.update()
            self.menuTooltipGroup.update()
            self.cursorGroup.update()
            try:
                self.screen.blit(self.backgroundImage, self.backgroundImage.get_rect())
            except:
                self.backgroundImage.draw(self.screen)
            
            self.menuGroup.draw(self.screen)
            self.menuTooltipPointer[self.currentSelection].draw(self.screen)
            self.cursorGroup.draw(self.screen)
            
            pygame.display.flip()
            
            self.cursor.position = vector.vector2d(pygame.mouse.get_pos()) + vector.vector2d(32,32)
            
            """Event Handling Stuff"""
            for event in pygame.event.get():
                if event.type == pygame.KEYDOWN and (event.key == pygame.K_SPACE or event.key == pygame.K_RETURN):
                    utility.playSound(self.menuForward)
                    return self.menuDictionary.keys()[self.currentSelection]
                
                elif event.type == pygame.MOUSEBUTTONDOWN and event.button == 1:
                    utility.playSound(self.menuForward)
                    return self.menuDictionary.keys()[self.currentSelection]
    
                elif event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
                    utility.playSound(self.menuBack)
                    return False
                
                elif event.type == pygame.MOUSEBUTTONDOWN and event.button == 3:
                    utility.playSound(self.menuBack)
                    return False
                
                elif event.type == pygame.KEYDOWN and event.key == pygame.K_UP:
                    self.menuSelectionPointer[self.currentSelection].setFont(32, FONT_INACTIVE_COLOR, FONT_PATH)
                    self.currentSelection -= 1
                    if self.currentSelection < 0:
                        self.currentSelection = len(self.menuDictionary) - 1
                    self.menuSelectionPointer[self.currentSelection].setFont(48, FONT_COLOR, FONT_PATH)
                    utility.playSound(self.menuBeep)

                elif event.type == pygame.KEYDOWN and event.key == pygame.K_DOWN:
                    self.menuSelectionPointer[self.currentSelection].setFont(32, FONT_INACTIVE_COLOR, FONT_PATH)
                    self.currentSelection += 1
                    if self.currentSelection > len(self.menuDictionary) - 1:
                        self.currentSelection = 0
                    self.menuSelectionPointer[self.currentSelection].setFont(48, FONT_COLOR, FONT_PATH)
                    utility.playSound(self.menuBeep)
                    
                elif event.type == pygame.MOUSEMOTION:
                    for element in self.menuGroup:
                        if element.mouseOver():
                            if (element.textIndex != self.currentSelection):
                                self.menuSelectionPointer[self.currentSelection].setFont(32, FONT_INACTIVE_COLOR, FONT_PATH)
                                mouseSelection = element.textIndex
                                self.currentSelection = mouseSelection
                                self.menuSelectionPointer[self.currentSelection].setFont(48, FONT_COLOR, FONT_PATH)
                                utility.playSound(self.menuBeep)
            #
                    
                
                """elif event.type == pygame.KEYDOWN and event.key == pygame.K_q:
                    for element in self.menuTooltipGroup:
                        print "ELEMENT: ", element.textIndex
                        element.mouseOverDump()"""
                    
                """elif event.type == pygame.MOUSEMOTION:
                    mouseInput = list(pygame.mouse.get_rel())
                    if sampleMouse:
                        if mouseInput[1] < -10:
                            self.menuSelectionPointer[self.currentSelection].setFont(32, FONT_INACTIVE_COLOR, FONT_PATH)
                            self.currentSelection -= 1
                            if self.currentSelection < 0:
                                self.currentSelection = len(self.menuDictionary) - 1
                            self.menuSelectionPointer[self.currentSelection].setFont(48, FONT_COLOR, FONT_PATH)
                            sampleMouse = False
                            utility.playSound(self.menuBeep)
                                                
                        elif mouseInput[1] > 10:
                            self.menuSelectionPointer[self.currentSelection].setFont(32, FONT_INACTIVE_COLOR, FONT_PATH)
                            self.currentSelection += 1
                            if self.currentSelection > len(self.menuDictionary) - 1:
                                self.currentSelection = 0
                            self.menuSelectionPointer[self.currentSelection].setFont(48, FONT_COLOR, FONT_PATH)
                            sampleMouse = False       
                            utility.playSound(self.menuBeep)   """                  
                            

                    
            if not sampleMouse:
                mouseTimeout -= 1
                
            if mouseTimeout == 0:
                sampleMouse = True
                mouseTimeout = 3
                
            self.timer.tick(30)