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


Python Effect.healthchange方法代码示例

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


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

示例1: addHealth

# 需要导入模块: from effect import Effect [as 别名]
# 或者: from effect.Effect import healthchange [as 别名]
 def addHealth(self, n):
     self.health += n
     ef = Effect(self.g, "health", (self.rect.x, self.rect.y - 10))
     ef.healthchange = n
     if self.health > self.healthmax:
         self.health = self.healthmax
     self.g.saveData["health"] = self.health
开发者ID:torleif,项目名称:Dystopian-Future,代码行数:9,代码来源:player.py

示例2: touch

# 需要导入模块: from effect import Effect [as 别名]
# 或者: from effect.Effect import healthchange [as 别名]
    def touch(self, e):
        if self.imortal == 0:
            self.g.hurt.play()
            self.imortal = 10
            self.health -= e.get_damage()
            ef = Effect(self.g, "health", (self.rect.x, self.rect.y))
            ef.healthchange = -e.get_damage()
            # drop some skyberries
            if "weapon" in self.g.saveData:
                if self.g.saveData["weapon"] >= 1:
                    wpnstr = "shot" + str(self.g.saveData["weapon"]) + "_lvl"
                    if self.g.saveData[wpnstr] > 1:
                        self.g.saveData[wpnstr] -= 1
                        if self.g.saveData[wpnstr] == 9:
                            Effect(self.g, "msg", (self.rect.x, self.rect.y), "Level Down")
                        if self.g.saveData[wpnstr] == 19:
                            Effect(self.g, "msg", (self.rect.x, self.rect.y), "Level Down")
                        sb = Inventory(self.g, "skyberry", (self.rect.x, self.rect.y))
                        sb.canget = 0
                        sb = Inventory(self.g, "skyberry", (self.rect.x, self.rect.y))
                        sb.canget = 0
                        sb = Inventory(self.g, "skyberry", (self.rect.x, self.rect.y))
                        sb.canget = 0

            self.g.player.gravity = 15
            self.g.player.jumping = 1
            if self.g.saveData["weapon"] != 0:
                shotType = "shot" + str(self.g.saveData["weapon"])
                self.g.saveData[shotType] -= 1
            self.g.saveData["health"] = self.health
开发者ID:torleif,项目名称:Dystopian-Future,代码行数:32,代码来源:player.py

示例3: backup_attack_loop

# 需要导入模块: from effect import Effect [as 别名]
# 或者: from effect.Effect import healthchange [as 别名]
    def backup_attack_loop(self):
        g = self.g
        self.image = self.orginalImage.subsurface((160, 0, 32, 32))

        speed = self.walktimer
        self.walktimer += 1
        if self.walktimer > 6:
            self.walktimer = 6


        self.timer += 1
        timergate = self.timer % 100
        if timergate >= 80:
            if timergate == 80:
                self.face_the_player()
            if timergate == 85:
                Shot(g, self.direction, (self.rect.x + 16, self.rect.y + 8), 'shot8', 'enemy')
            self.walking = 0
        else:
            self.walking = 1
        if timergate % 100 == 0:
            self.face_the_player()

        dx = self.rect.x - g.player.rect.x
        if dx <40 and dx > -40:
            if self.dy == 10.0:
                self.dy = -10.0

        if self.walking:
            self.rect.x += (1 - (self.direction * 2)) * speed
            framen = self.timer / 2  % 3
            self.image = self.orginalImage.subsurface((32 + framen * 32, 0, 32, 32))
        else:
            self.walktimer = 0

        self.dy += .5
        if self.dy > 10.0:
            self.dy = 10.0
        self.rect.y += self.dy

        if self.rect.x < 416:
            self.direction = 0

        
        self.image = pygame.transform.flip(self.image, self.direction, 0)
        # hitting the bullets and player
        s = Rect(self.rect)
        if s.colliderect (g.player.rect):
            g.player.touch(self)
        for b in g.bullets:
            if b.owner == 'player':
                drect = (b.rect.x + 30, b.rect.y )
                if s.collidepoint(drect):
                    b.destroy()
                    self.health -= b.get_damage()
                    e = Effect(self.g, 'health', (self.rect.x, self.rect.y))
                    e.healthchange = -b.get_damage()
                    self.image = g.make_image_white(self.image)
开发者ID:torleif,项目名称:Dystopian-Future,代码行数:60,代码来源:character.py

示例4: mushroom_attack_loop

# 需要导入模块: from effect import Effect [as 别名]
# 或者: from effect.Effect import healthchange [as 别名]
    def mushroom_attack_loop(self):
        g = self.g
        if self.health <= 0:
            if self.feeling != 'dead':
                self.feeling = 'dead'
                self.timer = 0
                
        if self.feeling == 'dead':
            if self.timer > 70:
                self.image = pygame.Surface((1, 1), SRCALPHA)
                self.dead = 1
                return
            if self.timer % 10 == 0:
                self.exp2.play()
            if self.timer % 3 == 0:
                # flash on and off
                self.image = pygame.Surface((1, 1), SRCALPHA)
            else:
                x = random.randint(0, 256)
                y = random.randint(0, 256)
                e = Effect(self.g, 'explosion', (self.rect.x + x, self.rect.y + y))
            return


        if self.timer % 20 == 1:
            if self.timer % 200 < 100:
                c = random.randint(0, 20)
                s = Shot(self.g, self.direction, (self.rect.x + 128, self.rect.y + 128 + c), 'shot5', 'enemy')
                s.callback = self.create_slime_monster
                self.squirt2.play()

        s = Rect(self.rect)
        s.x += 80
        s.width -= 100
        s.y += 100
        s.height -= 180
        if s.colliderect (g.player.rect):
            g.player.touch(self)

        for b in g.bullets:
            if b.owner == 'player':
                drect = (b.rect.x + 30, b.rect.y )
                if s.collidepoint(drect):
                    b.destroy()
                    self.health -= b.get_damage()
                    e = Effect(self.g, 'health', (self.rect.x, self.rect.y))
                    e.healthchange = -b.get_damage()
                    tmp = pygame.Surface((256, 256), SRCALPHA)
                    tmp.blit(self.image, (0,0))
                    tmp.blit(self.secondImage, (0,0))
                    self.image = tmp
                    self.hitme.play()
                    
        speed = 2
        self.rect.x += (1 - (self.direction * 2)) * speed
        self.draw_health_meter()
开发者ID:torleif,项目名称:Dystopian-Future,代码行数:58,代码来源:character.py

示例5: robot_attack_loop

# 需要导入模块: from effect import Effect [as 别名]
# 或者: from effect.Effect import healthchange [as 别名]
    def robot_attack_loop(self):
        g = self.g
        self.timer += 1
        speed = 9
        attackphase = self.timer % 70
        self.image = self.orginalImage.subsurface((0, 32, 32, 32))
        if attackphase == 1: # lunge at the player
            self.face_the_player()
            self.attacking = 2 # 2 = lunging
        elif attackphase == 50: # fire a ball of death at the player
            Shot(self.g, self.direction, (self.rect.x + 16, self.rect.y + 20), 'shot8', 'enemy')
        if attackphase >= 50 and attackphase <= 65: # fire a ball of death at the player
            self.image = self.orginalImage.subsurface((64, 32, 32, 32))

        # lunging
        if self.attacking == 2:
            self.image = self.orginalImage.subsurface((32, 32, 32, 32))
            if self.rect.colliderect (self.g.player.rect):
                self.g.player.touch(self)
            self.rect.x += speed
            if self.direction:
                self.rect.x -= speed*2

        # loop through bullets and see if I die
        for b in g.bullets:
            if b.owner == 'player':
                drect = (b.rect.x + 30, b.rect.y )
                if self.rect.collidepoint(drect):
                    b.destroy()
                    self.health -= b.get_damage()
                    e = Effect(self.g, 'health', (self.rect.x, self.rect.y))
                    e.healthchange = -b.get_damage()
                    self.image = g.make_image_white(self.image, (32, 32))
        self.image = pygame.transform.flip(self.image, not self.direction, 0)

        if self.health <= 0:
            self.feeling = 'dead'
            self.attacking = 0
            self.dontwalk = 1
开发者ID:torleif,项目名称:Dystopian-Future,代码行数:41,代码来源:character.py

示例6: loop_hit_death

# 需要导入模块: from effect import Effect [as 别名]
# 或者: from effect.Effect import healthchange [as 别名]
    def loop_hit_death(self, g, r, canbehit, canhitplayer):
        self.timer += 1
        self.image = pygame.transform.flip(self.image, self.direction, 0)

        s = Rect(self.rect)
        if self.mode != 'death':
            if s.colliderect (g.player.rect):
                if canhitplayer:
                    g.player.touch(self)

        if canbehit:
            for b in g.bullets:
                if b.owner == 'player':
                    drect = (b.rect.x, b.rect.y)
                    if s.collidepoint(drect):
                        b.destroy()
                        self.health -= b.get_damage()
                        e = Effect(self.g, 'health', (self.rect.x, self.rect.y))
                        e.healthchange = -b.get_damage()
                        if self.mode != 'ouch':
                            self.birdhit.play()
                        self.mode = 'ouch'
                        self.btimer = 0
            #k = Rect(b.rect)
            #k.x -= g.view.x
            #k.y -= g.view.y
            #pygame.draw.rect(g.screen, (0,255,255), k)
        #s.x -= g.view.x
        #s.y -= g.view.y
        #pygame.draw.rect(g.screen, (255,0,255), s)
        

        # dead
        if self.health <= 0:
            if self.mode != 'death':
                self.mode = 'death'
                self.btimer = 0
开发者ID:torleif,项目名称:Dystopian-Future,代码行数:39,代码来源:enemy.py

示例7: fox_attack_loop

# 需要导入模块: from effect import Effect [as 别名]
# 或者: from effect.Effect import healthchange [as 别名]
    def fox_attack_loop(self):
        g = self.g

        if self.health <= 0:
            self.feeling = 'sad'
            self.health = 0
            if self.attacking == 3:
                self.feeling = 'dead'
                self.rect.y += 3
            else:
                self.attacking = 0
            self.walking = 0
            self.jumping = 0
            self.walktopos = (self.rect.x, self.rect.y)
            return
        
        self.timer += 1

        if self.jumping == 1:
            self.rect.y += self.jumpvec
            self.jumpvec += 1

        # if timer is in the minus, you're firing for a while
        if self.timer < 0:
            self.walking = 0
            if self.timer < -10:
                self.feeling = 'shooting'
                if self.attacking == 1:# first battle
                    if self.timer % 2 == 0:
                        s = Shot(g, self.direction, (self.rect.x + 44, self.rect.y + 35), 'shot3', 'enemy')
                elif self.attacking == 2: # second battle
                    if self.timer % 4 == 0:
                        s = Shot(g, self.direction, (self.rect.x + 44, self.rect.y + 35), 'shot3', 'enemy')
                        s.keep_alive = 6
                elif self.attacking == 3: # last
                    if self.timer % 10 == 0:
                        s = Shot(g, self.direction, (self.rect.x + 44, self.rect.y + 35), 'shot8', 'enemy')
        else:
            self.feeling = 'normal'
            speed = 4
            if self.attacking == 2:
                speed = 5
            self.rect.x += (1 - (self.direction * 2)) * speed
            self.rect.y += 2 # gravity
            if self.walktopos == (self.rect.x, self.rect.y) : # walking into something
                self.jumping = 1
                self.jumpvec = -10
            if self.attacking == 1: # first battle with fox
                if self.timer == 2:
                    self.jumping = 1
                    self.jumpvec = -10
                # shooting every random interval
                if random.randint(0, 70) == 0 and self.framecount > 10:
                    self.timer = -30
            if self.attacking == 2 or self.attacking == 3: # second battle with Fox
                dv = self.rect.x - self.g.player.rect.x
                if dv > 200:
                    self.direction = 1
                if dv < -200:
                    self.direction = 0
                if self.jumping == 0:
                    # jumping every 30 frames
                    if self.framecount % 40 == 0 and self.jumping == 0:
                        self.jumping = 1
                        self.jumpvec = -10
                        if self.attacking == 3:
                            self.jumpvec = -15
                    # shooting every random interval
                    elif random.randint(0, 15) == 0 and self.framecount > 10:
                        self.timer = -30
            self.framecount += 1
            self.walking = 1
            self.walktopos = (self.rect.x, self.rect.y)
        
        # hitting the bullets and player
        s = Rect(self.rect)
        if s.colliderect (g.player.rect):
            g.player.touch(self)
        for b in g.bullets:
            if b.owner == 'player':
                drect = (b.rect.x + 30, b.rect.y )
                if s.collidepoint(drect):
                    b.destroy()
                    self.health -= b.get_damage()
                    e = Effect(self.g, 'health', (self.rect.x, self.rect.y))
                    e.healthchange = -b.get_damage()
                    if self.feeling != 'sad':
                        self.hitme.play()
                    self.feeling = 'sad'
                    self.image = g.make_image_white(self.image, (96, 64))
开发者ID:torleif,项目名称:Dystopian-Future,代码行数:92,代码来源:character.py

示例8: loop

# 需要导入模块: from effect import Effect [as 别名]
# 或者: from effect.Effect import healthchange [as 别名]

#.........这里部分代码省略.........
            if rightarmlength == 10:
                rightarmspnning = ((self.timer % 1000) - 600) / 40 + 1
            dead = 0
            if self.health <= 0:
                leftarmlength = 0
                rightarmlength = 0
                self.feeling = 'dead'
                self.image.blit(self.imagel, (0,0))
                dead = 1
            else:
                self.image.blit(self.imageh, (0,0))
            if self.feeling == 'walking':
                m = (self.timer / 2) % 2 == 0
                if m == 1:
                    self.image.blit(self.imagee, (0,0)) # wonky tracks 2
                else:
                    self.image.blit(self.imagef, (0,0)) # wonky tracks 1
            else:
                self.image.blit(self.imageg, (0,0)) # normal tracks

            # getting hit by a bullet
            s = Rect(self.rect)
            s.x += 50
            s.y += 40
            s.width -= 120
            s.height -= 140
            for b in g.bullets:
                if b.owner == 'player':
                    drect = (b.rect.x , b.rect.y )
                    if s.collidepoint(drect) and not dead and rightarmspnning == 0:
                        dmg = b.get_damage()
                        self.health -= dmg
                        e = Effect(self.g, 'health', (self.rect.x + 128, self.rect.y + 60))
                        e.healthchange = -dmg
                        self.hitme.play()
                        self.image.blit(self.imagek, (0,0)) # white flash hit
                        b.destroy()
                        if self.health <= 0:
                            self.timer = 0

            # blit the right arm
            if rightarmspnning == 0:
                if rightarmlength == 4 or leftarmlength == 4:
                    self.attack.play()
                if rightarmlength == 0 or rightarmlength == 2:
                    self.image.blit(self.imagec, (0,0))
                elif rightarmlength == 1 or rightarmlength == 3:
                    self.image.blit(self.imagei, (0,0))
                else:
                    self.image.blit(self.imagec, (0,(rightarmlength - 4) * 20))
                if rightarmlength >= 0 and rightarmlength <= 3:
                    rpos = (0,0)
                    armr = self.imagea
                elif rightarmlength == 4:
                    rpos = (-50,-65)
                    armr = pygame.transform.rotate(self.imagea, -27)
                elif rightarmlength == 5: # there's no way to rotate around a point in pygame.
                    rpos = (-55,-90)
                    armr = pygame.transform.rotate(self.imagea, -45)
                else: # there's no way to rotate around a point in pygame.
                    rpos = (-55,-90)
                    armr = pygame.transform.rotate(self.imagea, -50)
                self.image.blit(armr, rpos)
            else:
                # covering the cross from player fire
                if rightarmspnning == 1 or rightarmspnning >= 9:
开发者ID:torleif,项目名称:Dystopian-Future,代码行数:70,代码来源:character.py


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