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


Python animation.Animation类代码示例

本文整理汇总了Python中animation.Animation的典型用法代码示例。如果您正苦于以下问题:Python Animation类的具体用法?Python Animation怎么用?Python Animation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: update_config

 def update_config(self, **kwargs):
     Animation.update_config(self, **kwargs)
     if "path_arc" in kwargs:
         self.path_func = path_along_arc(
             kwargs["path_arc"],
             kwargs.get("path_arc_axis", OUT)
         )
开发者ID:PythonJedi,项目名称:manim,代码行数:7,代码来源:transform.py

示例2: Bomb

class Bomb(object):
    def __init__(self, i, j, player):
        self.i = i
        self.j = j
        self.player = player
        self.timer = globals.b_timer
        self.animation = Animation(globals.b_images[player.player_number-1])

    def update(self):
        self.timer -= globals.clock.get_time()
        if self.timer < 0:
            self.explode()
        self.animation.update()

    def explode(self):
        self.remove()

        # rewrite for loops
        for i in range(
                max(0,
                    int(self.i - self.player.bomb_radious)),
                min(globals.squares_per_line,
                    int(self.i+1 + self.player.bomb_radious))):
            for j in range(
                    max(0,
                        int(self.j - self.player.bomb_radious)),
                    min(globals.squares_per_line,
                        int(self.j+1 + self.player.bomb_radious))):
                center = (self.i, self.j)
                square = (i, j)

                if utils.distance(center, square) <= self.player.bomb_radious:

                    # delete powerup in that square, if any
                    for powerup in globals.powerups:
                        if powerup.i == square[0] and \
                           powerup.j == square[1]:
                            globals.powerups.remove(powerup)
                            break

                    # delete bomb in that square, if any
                    for bomb in globals.bombs:
                        if bomb.i == square[0] and \
                           bomb.j == square[1]:
                            bomb.remove()
                            break

                    if globals.squares[i][j].owner != self.player:
                        globals.squares[i][j].change_owner(self.player)
                    globals.explosions.append(Explosion(i, j))

    def remove(self):
        globals.bombs.remove(self)
        self.player.current_bombs -= 1

    def render(self):
        self.animation.render(
            self.i * globals.square_size,
            self.j * globals.square_size,
        )
开发者ID:joaodelgado,项目名称:bomber,代码行数:60,代码来源:bomb.py

示例3: Powerup

class Powerup(object):
    def __init__(self, i, j):
        global powerups
        init_powerups()
        self.i = i
        self.j = j
        self.timer = globals.pw_timer
        self.powerup = choice(powerups)
        index = powerups.index(self.powerup)
        player = globals.squares[i][j].owner.player_number-1
        self.animation = Animation(globals.pw_images[index][player])

    def update(self):
        self.timer -= globals.clock.get_time()
        if self.timer < 0:
            globals.powerups.remove(self)

        self.animation.update()

    def pickup(self, player):
        self.powerup(player)
        globals.powerups.remove(self)

    def render(self):
        self.animation.render(
            self.i * globals.square_size,
            self.j * globals.square_size,
        )
开发者ID:joaodelgado,项目名称:bomber,代码行数:28,代码来源:powerup.py

示例4: __init__

    def __init__(self, speed, starting_position, texture, window_rectangle, collision_manager):
        self.window_rectangle = window_rectangle
        self.starting_position = starting_position
        self.speed = speed
        self.collision_manager = collision_manager
        self.direction = 1 if speed > 0 else -1

        # Plane
        fly_anim = Animation()
        fly_anim.texture = texture
        fly_anim.add_frame(sf.Rectangle((0, 0), (88, 73)))
        fly_anim.add_frame(sf.Rectangle((88, 0), (88, 73)))
        fly_anim.add_frame(sf.Rectangle((176, 0), (88, 73)))
        fly_anim.add_frame(sf.Rectangle((88, 0), (88, 73)))

        self.plane = AnimatedSprite(sf.seconds(0.2), False, True)
        self.plane.play(fly_anim)
        self.plane.size = sf.Vector2(self.plane.global_bounds.width / 2, self.plane.global_bounds.height / 2)
        self.plane.origin = self.plane.global_bounds.width / 2.0, self.plane.global_bounds.height / 2.0
        self.plane.scale((self.direction * 0.5, 0.5))

        self.plane.position = self.starting_position
        self.plane_speed = sf.Vector2(speed, 0)

        self.is_dead = False
        self.jump_time = None
        self.plane_jumped = False

        self.immortal = None

        self.bullets = set()

        SoundManager.play_player_appear_sound()
开发者ID:Valian,项目名称:IGK2015,代码行数:33,代码来源:player.py

示例5: __init__

 def __init__(self, AnimationClass, mobjects, **kwargs):
     centers = [mob.get_center() for mob in mobjects]
     kwargs["mobject"] = Mobject().add_points(centers)
     self.centers_container = AnimationClass(**kwargs)
     kwargs.pop("mobject")
     Animation.__init__(self, Mobject(*mobjects), **kwargs)
     self.name = str(self) + AnimationClass.__name__
开发者ID:Rubixdarcy,项目名称:manim,代码行数:7,代码来源:simple_animations.py

示例6: __init__

    def __init__(self):
        super(Splash, self).__init__()
        self.next_state = "SHOOTING"
        self.animations = pg.sprite.Group()
        with open(os.path.join("resources", "clay_spots.json"), "r") as f:
            skeet_spots = json.load(f)
        self.all_sprites = pg.sprite.LayeredUpdates()
        self.clays = pg.sprite.OrderedUpdates()
        delay = 0
        duration = 500
        depth = 5000
        for spot in skeet_spots:
            clay = ClayPigeon((640, 750), 7, 0, False, self.clays, self.all_sprites)
            clay.rect.center = 640, 750
            clay.z = depth
            x, y = spot
            ani = Animation(centerx=x, centery=y, duration=duration, delay=delay, round_values=True)
            ani.start(clay.rect)
            self.animations.add(ani)

            delay += 15
            depth -= 1

        self.world = World(False)
        for s in self.all_sprites:
            self.all_sprites.change_layer(s, -s.z)
        try:
            with open(os.path.join("resources", "high_scores.json"), "r") as f:
                high_scores = json.load(f)
        except IOError:
            with open(os.path.join("resources", "high_scores.json"), "w") as f:
                json.dump([], f)
开发者ID:metulburr,项目名称:skeet-shoot-challenge,代码行数:32,代码来源:splash.py

示例7: UpgradeFactory

class UpgradeFactory(Building):
    def __init__(self):
        self.ico_pic = pygame.image.load("sprites/factory_ico.png")
        self.image = Animation()
        self.image.setup("factory")
        self.supic = pygame.image.load("sprites/icons/spu.png")
        self.mupic = pygame.image.load("sprites/icons/mup.png")
        self.size = 50
        
    def draw_hud(self, target):
        target.screen.blit(self.ico_pic, (230, 500))
        target.draw_hudbuttons(2)
        target.screen.blit(self.supic, target.hud.all_coords[0])
        target.screen.blit(self.mupic, target.hud.all_coords[1])
        
    def detectact(self, target, curpos):
        if curpos.get_distance(vec2d(646, 456)) <= 15:
            if target.buildings[0].inventory[1][1] > 40000:
                target.buildings[0].inventory[1][1] -= 40000
                Drone.speed = 6
                print("Drone speed upgraded by 20%.")
                for drone in target.drones:
                    drone.speed = 6
            else:
                print("You need 40 000 ore to buy speed upgrade!")
        if curpos.get_distance(vec2d(696, 456)) <= 15:
            if target.buildings[0].inventory[1][1] > 40000:
                target.buildings[0].inventory[1][1] -= 40000
                Drone.mining_speed = 2
                print("Drone mining speed increased by 100%")
                for drone in target.drones:
                    drone.mining_speed = 2
            else:
                print("You need 40 000 ore to buy mining speed upgrade!")
开发者ID:Lordmordevil,项目名称:BotWars,代码行数:34,代码来源:buildings.py

示例8: startup

 def startup(self, persistent):
     self.persist = persistent
     self.shade_alpha = 255
     ani = Animation(shade_alpha=0, duration=3000,
                             round_values=True, transition="linear")
     ani.start(self)
     self.animations.add(ani)
开发者ID:reddit-pygame,项目名称:pumpkin-carving-challenge,代码行数:7,代码来源:carving.py

示例9: Medbay

class Medbay(Building):
    def __init__(self):
        self.ico_pic = pygame.image.load("sprites/generator_ico.png")
        self.image = Animation()
        self.image.setup("medbay")
        self.ico_medic = pygame.image.load("sprites/icons/mup.png")
        self.ico_medshop = pygame.image.load("sprites/icons/mup.png")
        self.size = 50

    def draw_hud(self, target):        
        target.screen.blit(self.ico_pic, (230, 500))
        target.draw_hudbuttons(2)
        target.screen.blit(self.ico_medic, target.hud.all_coords[0])
        target.screen.blit(self.ico_medshop, target.hud.all_coords[1])
        
    def detectact(self, target, curpos):
        if curpos.get_distance(vec2d(646, 456)) <= 15:
            if target.buildings[0].inventory[1][1] > 20000:
                target.buildings[0].inventory[1][1] -= 20000

                print("Medic ready for duty!")

            else:
                print("You need 20 000 ore to buy this unit!")
        if curpos.get_distance(vec2d(696, 456)) <= 15:
            if target.buildings[0].inventory[1][1] > 40000:
                target.buildings[0].inventory[1][1] -= 40000

                print("Battery truck ready for duty!")

            else:
                print("You need 40 000 ore to buy this unit!")
开发者ID:Lordmordevil,项目名称:BotWars,代码行数:32,代码来源:buildings.py

示例10: upgrade

 def upgrade(self):
     self.level = 1
     self.target = self.pos
     self.fire_target = self.pos
     tempimage = Animation()
     tempimage.setup("upoutpost")
     self.image = tempimage
开发者ID:Lordmordevil,项目名称:BotWars,代码行数:7,代码来源:buildings.py

示例11: Outpost

class Outpost(Building):
    def __init__(self):
        self.ico_pic = pygame.image.load("sprites/generator_ico.png")
        self.up_ico = pygame.image.load("sprites/icons/up_ico.png")
        self.image = Animation()
        self.image.setup("outpost")
        self.size = 35
        self.level = 0
        self.target = vec2d(0, 0)
        self.fire_target = vec2d(0, 0)
        
    def draw_hud(self, target):
        target.screen.blit(self.ico_pic, (230, 500))
        target.draw_hudbuttons(1)
        target.screen.blit(self.up_ico, target.hud.all_coords[0])

    def detectact(self, target, curpos):
        if curpos.get_distance(vec2d(646, 456)) <= 15:
            self.upgrade()
            
    def upgrade(self):
        self.level = 1
        self.target = self.pos
        self.fire_target = self.pos
        tempimage = Animation()
        tempimage.setup("upoutpost")
        self.image = tempimage
开发者ID:Lordmordevil,项目名称:BotWars,代码行数:27,代码来源:buildings.py

示例12: shoot

 def shoot(self, bullets, turkeys, all_sprites, animations):
     """
     Fire a bullet if the player has enough ammo and enough time has passed
     since the last shot.
     """
     if self.cooldown_timer >= self.cooldown_time:
         self.stop_walking()
         if self.shells <= 0:
             prepare.SFX["gunclick"].play()
         else:
             self.shells -= 1
             prepare.SFX["gunshot"].play()
             pos = project(self.pos, (self.angle - .1745) % (2 * pi), 42) #end of rifle at 96x96
             bullet  = Bullet(pos, self.angle, bullets, all_sprites)
             distance = 2000.
             x, y  = project(pos, self.angle, distance)
             ani = Animation(centerx=x, centery=y, duration=distance/bullet.speed, round_values=True)
             ani.callback = bullet.kill
             ani.start(bullet.rect)
             animations.add(ani)
             scare_rect = self.collider.inflate(1200, 1200)
             scared_turkeys = [t for t in turkeys if scare_rect.colliderect(t.collider)]
             for scared in scared_turkeys:
                 task = Task(scared.flee, 750, args=(self,))
                 self.animations.add(task)
         task = Task(self.flip_state, 120, args=("idle",))
         animations.add(task)
         self.cooldown_timer = 0
         self.flip_state("shoot")
开发者ID:reddit-pygame,项目名称:turkey-shoot-challenge,代码行数:29,代码来源:hunter.py

示例13: __init__

    def __init__(self, mobject1, mobject2, 
                 run_time = DEFAULT_TRANSFORM_RUN_TIME,
                 interpolation_function = straight_path,
                 black_out_extra_points = False,
                 *args, **kwargs):
        self.interpolation_function = interpolation_function
        count1, count2 = mobject1.get_num_points(), mobject2.get_num_points()
        if count2 == 0:
            mobject2 = Point((SPACE_WIDTH, SPACE_HEIGHT, 0))
            count2 = mobject2.get_num_points()
        Mobject.align_data(mobject1, mobject2)
        Animation.__init__(self, mobject1, run_time = run_time, *args, **kwargs)
        self.ending_mobject = mobject2
        self.mobject.SHOULD_BUFF_POINTS = \
            mobject1.SHOULD_BUFF_POINTS and mobject2.SHOULD_BUFF_POINTS
        self.reference_mobjects.append(mobject2)
        self.name += "To" + str(mobject2)

        if black_out_extra_points and count2 < count1:
            #Ensure redundant pixels fade to black
            indices = np.arange(
                0, count1-1, float(count1) / count2
            ).astype('int')
            temp = np.zeros(mobject2.points.shape)
            temp[indices] = mobject2.rgbs[indices]
            mobject2.rgbs = temp
            self.non_redundant_m2_indices = indices
开发者ID:nachinius,项目名称:animations,代码行数:27,代码来源:transform.py

示例14: update_mobject

 def update_mobject(self, alpha):
     Animation.update_mobject(self, alpha)
     axes = [self.axis] if self.axis is not None else self.axes
     if self.in_place:
         method = self.mobject.rotate_in_place
     else:
         method = self.mobject.rotate           
     method(alpha*self.radians, axes = axes)     
开发者ID:scottopell,项目名称:manim,代码行数:8,代码来源:simple_animations.py

示例15: __init__

 def __init__(self, value_function, **kwargs):
     """
     Value function should return a real value 
     depending on the state of the surrounding scene    
     """
     digest_config(self, kwargs, locals())
     self.update_mobject()
     Animation.__init__(self, self.mobject, **kwargs)
开发者ID:PythonJedi,项目名称:manim,代码行数:8,代码来源:numerals.py


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